How to make an “alias” for a long path?

Since it’s an environment variable (alias has a different definition in bash), you need to evaluate it with something like:

cd "${myFold}"


cp "${myFold}/someFile" /somewhere/else

But I actually find it easier, if you just want the ease of switching into that directory, to create a real alias (in one of the bash startup files like .bashrc), so I can save keystrokes:

alias myfold='cd ~/Files/Scripts/Main'

Then you can just use (without the cd):


To get rid of the definition, you use unalias. The following transcript shows all of these in action:

pax> cd ; pwd ; ls -ald footy
drwxr-xr-x 2 pax pax 4096 Jul 28 11:00 footy

pax> footydir=/home/pax/footy ; cd "$footydir" ; pwd

pax> cd ; pwd

pax> alias footy='cd /home/pax/footy' ; footy ; pwd

pax> unalias footy ; footy
bash: footy: command not found

Leave a Comment