Blog/Bash Aliases

From Forza's ramblings

2020-08-06: Bash Aliases[edit | edit source]

So this is just a small tip to save some keystrokes while using the Linux command line - who like to type the same thing way too many times ;-)

Use aliases and bash functions to speed up your work. I'm especially fond of the cd.. and .. aliases!

This is Bash centric but should work with some tweaking with other shells.

# nano /etc/profile.d/

## Misc aliases
alias cp='cp --reflink=auto -v' 
alias df='df -h'
alias ll='ls -laF'
alias dir='ls -laF'
alias 'cd..'='cd ..'
alias '..'='cd ..'
alias srr='screen -rxd'
alias sr='screen'
alias iotop="iotop -o"
## Btrfs specifics
alias scrub-status="btrfs scrub status -d"
alias scrub-start="btrfs scrub start"
## Gentoo Linux Portage/emerge specifics
emerge_world() {
    emerge @world -uDvaN "$@"
}; export -f emerge_world
emerge_depclean() {
    emerge --depclean -Dva "$@"
}; export -f emerge_depclean
## Nextcloud specifics
occ() {
    sudo -u apache MAGICK_THREAD_LIMIT="4" nice -n20 php -f /var/www/domains/ "$@"
}; export -f occ
## Wordpress specifics
wp() {
    sudo -u apache php -f /opt/wp-cli/wp-cli.phar "$@"
}; export -f  wp

Note: You can also use ~/.bash_profile for user specific aliases.