An "alias" is an abbreviation for a shell command. Your definition alias home='~'
does not work because it does not specify a valid command:
~$ ~
bash: /home/vanadium: Is a directory
This approach, therefore, is not suited to allow you to replace a full pathname by a shorter name for it that you can use in commands.
One way is to define variables instead. There is probably no need to define shortcuts for your home directory and for the previous folders: the build-in abbreviations, ~
and ..
, respectively, are as short as it can get: I advise you to just adopt these.
For other paths, you can define environmental variables, which, similar as aliasses, can be made permanent by including them in .bashrc
:
export work=~/Workstation
which then can be used in a command as
cd $work
and which will work with your other aliases, e.g.
destroy $work
Notes if dealing with pathnames with spaces:
• If the pathname defined in the variable contains spaces, you will need to quote the variable as in
cd "$work"
• If you define a variable with spaces, you need to keep symbols that are expanded by bash, e.g. ~
, unquoted, as in
export work=~"/Pathname with spaces"