So far two great have been given in other answers, I have one more possibility:
ln -s /media/prasanth/01D0F888E7BC91801/github/projects ~/mygitfiles
Will create a symlink to the long path in your home.
Symlinks are like shortcuts that point to another file or directory, and most programs will treat them as normal. you can safely rm
the symlink without effecting the path it points to. you can observe where the symlink points to with ls -l
.
You can use the symlink as if it was a real directory and do cd ~/mygitfiles
.
Note that ~ is simply an alias for your home directory, which might be a sensible place for such a symlink.
Be aware that using this symlink ultimately effects your current working directory.
In the general case I would suggest Nicolas Delvaux, or Eduardo Cola's answer, but using a symlink might be just as - or possibly more useful.
. ~/.bashrc
(if in the console or in a terminal) or close / reopen the terminal (if in a terminal). – kos Jan 04 '16 at 15:12cd $mgf/subdir/
. Upvoted – Sergiy Kolodyazhnyy Jan 04 '16 at 19:32.bashrc
limits its usefulness to only bash shells, and is a waste of resources. There's no need to run this on every subshell invocation in~/.bashrc
. It should be in~/.profile
so it is read by any login shell, as explained at What are the functional differences between .profile .bash_profile and .bashrc - Server Fault – nealmcb Jun 17 '18 at 17:46