I believe what you're asking for is called bookmarking. The 2 approaches I've seen used for doing this are to either maintain a set of aliases or use a tool to "bookmark" some long directory path, and then use this tool to "jump" to a bookmarked directory.
Method #1 - Aliases
You can make aliases to these directories, and store them in your ~/.bashrc
file. You can then just type things like this:
alias dir1="cd ~/path/to/some/deep/deep/dir1"
alias dir2="cd ~/path/to/some/deep/deep/dir2"
Now when you login, aliases such as these will just work from any shell that makes use of the ~/.bashrc
file.
Method #2 - Directory Bookmarking Tools
Take a look at this Q & A titled: Quick directory navigation in the terminal. Tools such as autojump or xd - eXtra fast Directory changer, can be used as well to "bookmark" frequently used directories so that you can easily change to them without having to type long paths.
Context "sensitive" aliases
This would be something that's only available when you're in a specific directory. I'm not aware of any way to do something like this. You'd have to develop your own homegrown solution to facilitate something like this. A script would be the logical method for implementing something like this.
One approach would be to develop a script that checks to see what directory you're in prior to running. If it's not the designated directory, then it would simply exit out. Otherwise it would proceed. This could be implemented as a function in Bash as well.
alias ls='df --human-readable'
, which make thedf
output as readable as possible. – slackmart Feb 18 '14 at 00:40