How to set environmental variables in Unix

I often use SubVersion from the command line to manage my projects and I quickly became tired of typing in the full urls to repositories. I'm now storing these long paths in environmental variables. So for example I previously had to type
svn copy http://repo/svn/spoonermedia/projectname/trunk http://repo/svn/spoonermedia/projectname/branch/feature1 to make a branch. After setting up an environmental variable I only have to type

svn copy $R/trunk $R/branch/feature1

Okay if your sold on Environmental Variables this is how you do it.

  1. Look in "/Users/your-user-name" for a .profile or .bash_login file. If you have both then open up .bash_login or if you have neither create a .profile file.
  2. In that file you can use the export command to set all the variables you need. Each of these variables should be in uppercase.
    export W=/Users/jspooner/Documents/veoh/FlashPlayer/branches/wolverine
    export T=/Users/jspooner/Documents/veoh/FlashPlayer/tags
    export B=/Users/jspooner/Documents/veoh/FlashPlayer/branches
    export SVNROOT=http://repo/svn/src/FlashPlayer/
    

You can also use alias and functions to do other task like open and close projects. Here are some of the other shortcuts I have.

## Open my current project
alias wolverine="cd /Users/jspooner/Documents/veoh/FlashPlayer/branches/wolverine && pwd && echo WELCOME TO WOLVERINE"
# mate
alias edithost="mate /private/etc/hosts"

alias stopmysql="sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist"
alias startmysql="sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist"
#
# # functions
# # change directories. echo PWD and show a list
cdd () { cd ${1}; echo $PWD; ls; }

Comments are closed.