8

We have so many useful folders, which are in different path, for our working in Linux.

For example :

  1. $ cd ~/Documents/Courses/EDX/physics2013/
  2. $ cd ~/Documents/Company/OpenGL/Proj/...
  3. $ cd ~/Documents/Freelance/Android/Proj/...

....

How to create some short paths which can be used like

  1. $ cd edxPhy2013
  2. $ cd cglProj-v-2.13
  3. $ cd flAndrProj-v-1.1
1
  • I strongly recommend the tools that @slm mentions over the link or alias suggestions. Not having to specify and remember your shorthand names really lightens your memory burden. ("Was that edxPhy2013 or EDXphy2013 or Phy2013???" who needs that?)
    – msw
    Commented Sep 30, 2013 at 22:01

4 Answers 4

10

You might find symbolic links useful:

ln -s ~/Documents/Courses/EDX/physics2013/ ~/edxPhy2013

Or possibly an alias:

alias cde='cd ~/Documents/Courses/EDX/physics2013/'
1
  • I like the link idea if you have some particular aversion to aliases. However, if you really want to go 'all in', you would 1) NFS export the directories 2) Mount the NFS exports to sub-directories under the user's home with names like "edxPhy2013" or more simply "phy".
    – Andrew
    Commented Sep 30, 2013 at 21:04
2

Aliases

Rather than fill up your file system with links you might want to just make aliases to these directories, and store them in your ~/.bashrc file. You can then just type things like this:

alias edxPhy2013="cd ~/Documents/Courses/EDX/physics2013/"
alias cglProj-v-2.13="cd ~/Documents/Company/OpenGL/Proj/..."
alias flAndrProj-v-1.1="cd ~/Documents/Freelance/Android/Proj/..."

Now when you login, these will just work from any shell that makes use of the ~/.bashrc file.

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.

1
  • +1 for mention of the vastly underrated autojump. Typing $ j phys to get to …EDX/physics2013/ has become one of the few shell enhancements I rely upon. As the autojump author notes from an informal survey 10–20% of shell commands are cd.
    – msw
    Commented Sep 30, 2013 at 21:54
1

Put aliases into the user's profile (.bashrc file). I like even shorter abbreviations than you suggest:

alias cdOP="cd ~/Documents/Company/OpenGL/Proj/"
alias cdAP="cd ~/Documents/Freelance/Android/Proj/"

When the user types cdOP they go to the Company OpenGL Proj folder, if they cdAP they go to the Freelance Android Project directory.

1

What about a variable? In your .bashrc:

export p2013=~/Documents/Courses/EDX/physics2013/

And then in bash:

cd $p2013

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .