Sometimes when we have to navigate to deep down directory in the terminal we really wish for shortcuts.
For example,
1 |
cd ~/Downloads/folder1/subfolder2/subfolder3/subfolder3/hello |
Instead, we can just type
1 |
cdhello |
The terminal will change directory to that place automatically if you have defined an alias like this:
1 |
alias cdhello='cd~/Downloads/folder1/subfolder2/subfolder3/subfolder3/hello' |
Either you can just use this in the terminal, and use it until you close the terminal, or if you want to use these
shortcuts all the time you can add it to the system dot files (e.g. ~/.bashrc in Linux and ~/.bash_profile in Mac, and sometimes ~/.profile and so on)
For example here are few lines of my customized .bash_proifle (orĀ .bashrc in Linux):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
##============================== # List ##============================== alias ls='ls -GFS' alias la='ls -Al' # show hidden files alias lsz='ls -lSr' # sort by size alias lu='ls -lur' # sort by access time alias lr='ls -lR' # recursive ls alias lt='ls -ltr' # sort by date alias lm='ls -al |more' # pipe through 'more' alias ll='ls -la' alias l.='ls -d -G .*' alias lshidden='ls -ap | grep -v / | egrep "^\." ' ##============================== # Change Directory ##============================== alias cdd='clear; cd ~/Dropbox; ls' alias cdn='clear; cd ~/Downloads; ls' alias cdr='clear; cd ~/Research; ls' alias cdg='cd ~/github; ls' alias cdgit='clear; cd ~/github; ls' alias cdtmp='clear; cd ~/Temp; ls' alias cdo='clear; cd ~/OneDrive; ls' alias cdj='clear; cd ~/jedisim/jedisim; ls' alias cdscr='cd ~/Dropbox/Screenshots; ls' alias .2='cd ../' alias .3='cd ../../' alias .4='cd ../../../' alias .5='cd ../../../../' alias .6='cd ../../../../../' alias ..='cd ../' alias ...='cd ../../' alias ....='cd ../../../' alias .....='cd ../../../../' alias ......='cd ../../../../../' ##============================== # Mac Aliases ##============================== alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app' alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app' alias rmds='rm -rf .DS_Store */.DS_Store */*/.DS_Store' ##======================================== # Additional programs installed in MAC ##======================================== alias atom='/Users/poudel/Applications/Atom.app/Contents/MacOS/Atom' alias firefox="/Applications/Firefox.app/Contents/MacOS/firefox" alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" alias safari="/Applications/Safari.app/Contents/MacOS/Safari" alias ds9='/Applications/SAOImage\ DS9.app/Contents/MacOS/ds9' alias ds9m='ds9 -multiframe' alias mvim="/Applications/MacVim.app/Contents/MacOS/MacVim" |
Thanks for sharing.