From bash to zsh and everywhere in between, show me yours and I’ll show you mines. Inspire others or get some feedback.
Simply copy & paste the output of alias in your terminal or add some comments to explain things for others.
Edit: Kbin users, click ‘More’ on a comment and use the fediverse link to read responses that have funky formatting
alias upgrade="sudo dnf upgrade --yes && flatpak update && flatpak remove --unused"
Or something like that, also a dnf remove unused command in there. Writing this from my phone so might be written wrong.
A bit long, but here goes:
Start gomuks Matrix Client
alias gomuks=/home/craig/.local/bin/gomuks-linux-arm64
walk: Terminal File Manager
https://github.com/antonmedv/walk
alias walk=“walk --icons”
Weather:https://github.com/chubin/wttr.in
alias weather=“/home/craig/.local/bin/weather.sh”
Onelinershell https://github.com/Onelinerhub/shellhub
alias oh=“/home/craig/.local/bin/oh.sh”
Show open ports
alias ports=‘sudo netstat -tulanp’
Refresh .bashrc
alias bashrc=“source ~/.bashrc”
become root
alias root=‘sudo -i’ alias su=‘sudo su’
Fix which
alias which=‘command -v’
APT User Commands
alias search=‘apt search’ alias file=‘apt-file search’ alias policy=‘apt policy’ alias show=“nala show”
if user is not root, pass all commands via sudo
if [ $UID -ne 0 ]; then alias update=‘sudo apt update’ alias ainstall=‘sudo apt install’ alias apurge=‘sudo apt purge -y --autoremove’ alias upgrade=‘sudo nala upgrade’ alias aremove=‘sudo apt autoremove -y’ alias clean=‘sudo nala clean’ alias reboot=‘sudo reboot’ alias shutdown=“sudo shutdown -P now” fi
Handy-dandy aliases for journalctl and systemctl
alias jc=‘sudo journalctl -b’ alias jca=‘sudo journalctl’ alias jcf=‘sudo journalctl -f’ alias jcr=‘sudo journalctl --list-boots’ alias sc=‘sudo systemctl’
Making files immortal & executable
alias im+=“sudo chattr +i” alias im-=“sudo chattr -i” alias exe=“sudo chmod +x”
#Add safety nets
do not delete / or prompt if deleting more than 3 files at a time
alias rm=‘rm -I --preserve-root’
confirmation
alias mv=‘mv -i’ alias cp=‘cp -i’ alias ln=‘ln -i’
Parenting changing perms on /
alias chown=‘chown --preserve-root’ alias chmod=‘chmod --preserve-root’ alias chgrp=‘chgrp --preserve-root’
copy the current working directory to the clipboard
alias cpwd=‘pwd | xclip -selection clipboard’
Clipboard
alias cpy=“xclip -selection clipboard”
quick directory movement
alias …=‘cd …’ alias …=‘cd …/…’ alias …=‘cd …/…/…’
go to the last directory you were in
alias back=‘cd $OLDPWD’
quickly find files and directory
alias ff=‘find . -type f -name’ alias fd=‘find . -type d -name’
Create Python virtual environment
alias ve=‘python3 -m venv ./venv’ alias va=‘source ./venv/bin/activate’
Ping Commands
Stop after sending count ECHO_REQUEST packets
alias ping=‘ping -c 5’ alias pg=“ping google.com -c 5”
alias shortcuts
alias rpi=“sudo rpi-update” alias rpi-next=“sudo BRANCH=next rpi-update” alias raspi=“sudo raspi-config” alias clr=“clear” alias clrh=“history -c -w ~/.bash_history” alias df=‘df -H’ alias du=‘du -ch’ alias mk=“mkdir -p” alias loading=“sudo dmesg > ~/dmesg.txt”
ls Commands
Colorize the ls output and human readable sizes
alias ls=‘ls --color=auto --human-readable -al’
Use a long listing format
alias ll=‘ls -la’
Show hidden files
alias l.=‘ls -d .* --color=auto’
Listing files in folder
alias listkb=“ls -l --block-size=K” alias listmb=“ls -l --block-size=M”
Colorize the grep command output for ease of use (good for log files)##
alias grep=‘grep --color=auto’ alias egrep=‘egrep --color=auto’ alias fgrep=‘fgrep --color=auto’
Colorize diff output
alias diff=‘colordiff’
Start calculator with math support
alias bc=“bc -l”
Resume wget by default
alias wget=“wget -c”
ps Commands
alias ps=“ps auxf”
Get top process eating cpu
alias pscpu=“ps auxf | sort -nr -k 3” alias pscpu10=“ps auxf | sort -nr -k 3 | head -10”
Get top process eating memory
alias psmem=‘ps auxf | sort -nr -k 4’ alias psmem10=‘ps auxf | sort -nr -k 4 | head -10’
Free and Used Ram
alias meminfo=‘free -l’ alias free=‘free -mt’
Run top in alternate screen
alias top=‘tput smcup; top; tput rmcup’
alias a='alias'
a c='clear'
a p='pwd'
a e='exit'
a q='exit'
a h='history | tail -n20'
# turn off history, use 'set -o history' to turn it on again
a so='set +o history'
a b1='cd ../'
a b2='cd ../../'
a b3='cd ../../../'
a b4='cd ../../../../'
a b5='cd ../../../../../'
a ls='ls --color=auto'
a l='ls -ltrhG'
a la='l -A'
a vi='gvim'
a grep='grep --color=auto'
# open and source aliases
a oa='vi ~/.bash_aliases'
a sa='source ~/.bash_aliases'
# sort file/directory sizes in current directory in human readable format
a s='du -sh -- * | sort -h'
# save last command from history to a file
# tip, add a comment to end of command before saving, ex: ls --color=auto # colored ls output
a sl='fc -ln -1 | sed "s/^\s*//" >> ~/.saved_commands.txt'
# short-cut to grep that file
a slg='< ~/.saved_commands.txt grep'
# change ascii alphabets to unicode bold characters
a ascii2bold="perl -Mopen=locale -Mutf8 -pe 'tr/a-zA-Z/𝗮-𝘇𝗔-𝗭/'"
### functions
# 'command help' for command name and single option - ex: ch ls -A
# see https://github.com/learnbyexample/command_help for a better script version
ch() { whatis $1; man $1 | sed -n "/^\s*$2/,/^$/p" ; }
# add path to filename(s)
# usage: ap file1 file2 etc
ap() { for f in "$@"; do echo "$PWD/$f"; done; }
# simple case-insensitive file search based on name
# usage: fs name
# remove '-type f' if you want to match directories as well
fs() { find -type f -iname '*'"$1"'*' ; }
# open files with default application, don't print output/error messages
# useful for opening docs, pdfs, images, etc from command line
o() { xdg-open "$@" &> /dev/null ; }
# if unix2dos and dos2unix commands aren't available by default
unix2dos() { sed -i 's/$/\r/' "$@" ; }
dos2unix() { sed -i 's/\r$//' "$@" ; }