Ihr kennt das – mit der Zeit sammeln sich in der bash_aliases gern immer mehr Shortcuts, die nur ihr versteht, aber die ihr auch nie mehr missen wollt. Ich sammle meine hier 🙂
#bashaliases aendern oder neu laden
alias ba="nano ~/.bash_aliases"
alias ba="source ~/.bashrc"
#SSH
## Uberspace
alias us_xx="ssh xx@yy.uberspace.de"
# useful shortcuts
## short apt-get
alias apt-get="sudo apt-get"
alias update='sudo apt-get update && sudo apt-get upgrade'
alias cleanup="sudo apt autoremove && sudo apt clean"
## progress bar on file copy. Useful evenlocal.
alias cpProgress="rsync --progress -ravz"
## change directory
alias cd..="cd .."
alias ..="cd .."
## Disk Usage
alias usage=’du -ch 2> /dev/null |tail -1′
alias totalusage='df -hl --total | grep total'
alias most='du -hsx * | sort -rh | head -10'
alias du="du -ach | sort -h"
alias df="df -Tha --total"
alias free="free -mt"
## find files
alias fhere="find . -name "
## current ip
alias myip="curl http://ipecho.net/plain; echo"
## list open ports
alias ports='netstat -tulanp'
## become root
alias root='sudo -i'
alias su='sudo -i'
## Short for finding a process
alias ps="ps auxf"
alias psg="ps aux | grep -v grep | grep -i -e VSZ -e"
## htop instead of top
alias top="htop"
## Resize Image for Web
alias webify="mogrify -resize 690\> *.png"
#Funktionen
## Extract different archives with one command
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
return 1
else
for n in $@
do
if [ -f "$n" ] ; then
case "${n%,}" in
*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
tar xvf "$n" ;;
*.lzma) unlzma ./"$n" ;;
*.bz2) bunzip2 ./"$n" ;;
*.rar) unrar x -ad ./"$n" ;;
*.gz) gunzip ./"$n" ;;
*.zip) unzip ./"$n" ;;
*.z) uncompress ./"$n" ;;
*.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar)
7z x ./"$n" ;;
*.xz) unxz ./"$n" ;;
*.exe) cabextract ./"$n" ;;
*)
echo "extract: '$n' - unknown archive method"
return 1
;;
esac
else
echo "'$n' - file does not exist"
return 1
fi
done
fi
}
## Search for packages
showpkg () {
apt-cache pkgnames | grep -i "$1" | sort
return;
}
#Verhaltensänderungen
## colored diff
alias diff='colordiff'
## Colorize the ls output ##
alias ls='ls --color=auto'
## Use a long listing format ##
alias ll='ls -la'
## Show hidden files ##
alias l.='ls -d .* --color=auto'
## Create ParentDirs on Demand
alias mkdir='mkdir -pv'
## Mount Readable
alias mount='mount |column -t'
## Time Ping
alias ping="time ping"
## Resume wget by default
alias wget='wget -c'
Quellen
https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html
https://www.tuxarena.com/2014/10/collection-of-useful-bash-functions-and-aliases/
https://www.digitalocean.com/community/tutorials/an-introduction-to-useful-bash-aliases-and-functions