DEV Community

drmikecrowe
drmikecrowe

Posted on

What bash aliases can't you live without?

Here's some of mine:

Change up 1, 2 or 3 directories:

alias .....='cd ../../../..'
alias ....='cd ../../..'
alias ...='cd ../..'
alias ..='cd ..
Enter fullscreen mode Exit fullscreen mode

Example:

mcrowe in /tmp/level-1/level-2/level-3/level-4/level-5 
$ ....
mcrowe in /tmp/level-1/level-2 
$ 
Enter fullscreen mode Exit fullscreen mode

Grep history:

alias gh='history | grep --colour=auto'
Enter fullscreen mode Exit fullscreen mode

Strip line numbers from history "history cut"

alias hc="history | cut -b 8-
Enter fullscreen mode Exit fullscreen mode

ps commands:

alias psa='ps faux'
alias psag='ps faux | grep
Enter fullscreen mode Exit fullscreen mode

psa: shows detailed output:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         2  0.0  0.0      0     0 ?        S    Jan15   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        I<   Jan15   0:00  \_ [rcu_gp]
root         4  0.0  0.0      0     0 ?        I<   Jan15   0:00  \_ [rcu_par_gp]
Enter fullscreen mode Exit fullscreen mode

psag: Grep psa output:

$ psag nemo
mcrowe   15096  0.0  1.8 1095252 454104 tty2   Sl+  Jan16   3:12              |       \_ nemo
mcrowe   26147  0.0  0.0  17532   868 pts/1    S+   11:19   0:00              |       |               \_ grep --color --exclude-dir=.svn --exclude-dir=.git nemo
mcrowe    2366  0.0  0.1 822992 42108 tty2     Sl+  Jan15   0:17              \_ nemo-desktop
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
osde8info profile image
Clive Da