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 using the linux shell. Who like to type the same thing too many times ;-)

Use aliases and bash functions to speed up your work!

#!/bin/bash
## file: /etc/profile.d/99_aliases.sh

## 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 "[email protected]"
}; export -f emerge_world

emerge_depclean() {
    emerge --depclean -Dva "[email protected]"
}; export -f emerge_depclean

## Nextcloud specifics
occ() {
    sudo -u apache MAGICK_THREAD_LIMIT="4" nice -n20 php -f /var/www/domains/example.com/htdocs/nextcloud/occ "[email protected]"
}; export -f occ

## Wordpress specifics
wp() {
    sudo -u apache php -f /opt/wp-cli/wp-cli.phar "[email protected]"
}; export -f  wp

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