tl;dr My favourite bash aliases help me tremendously to shortcut commands I can't or don't want to remember.
A bash alias is a shortcut to avoid the need to type or remember other commands.
Instead of typing ls -alh
to print a nicely readable list of files and
directories, you could create the alias la
to do the same.
To add a personal alias open the file ~/.bash_aliases
and add a line with
the following schema:
alias shortname-of-the-alias="command --with-arguments"
These are my favourite bash aliases:
Shorten even short commands
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
Avoid typos
alias sl='ls'
alias got='git'
alias gut='git'
alias vmi='vim'
Don't remember tar arguments
alias ctar='tar -czf'
alias xtar='tar -xzf'
Use speaking aliases for commands with angular arguments
alias copy='xclip -sel clip'
alias directorysize='du -hc --max-depth=1'
alias password='pwgen -s 32 -1'
alias runrepeatedly='watch -n 1'
alias shrinkimages='mogrify -resize 1024x *.JPG'
alias unixtime='date +%s'
Run the last command again with sudo
alias please='sudo $(history -p \!\!)'
I made a Gist with my current .bash_aliases file which I update from time to time.
Update: I added some more commands to this post and the Gist.