Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[SHELL] My favourite bash aliases
#!/bin/bash
# alias bashrc='source ~/.bashrc'
alias zshrc='source ~/.zshrc'
alias realias='source ~/.bash_aliases'
alias ..="cd .."
alias chmod="chmod --preserve-root"
alias chown="chown --preserve-root"
alias free="free -h"
alias l='ls -pCFh --color=auto'
alias la='ls -pAFh --color=auto'
alias ll='ls -palFh --color=auto'
alias mkdir="mkdir -pv"
alias ps="ps auxf"
alias psg="ps aux | grep -v grep | grep -i -e VSZ -e"
# alias where="whereis" # zsh builtin
alias duh='du -ha --max-depth=1'
alias sduh='sudo du -ha --max-depth=1'
alias wine='LANG=ru_RU.utf8 wine'
alias is="type -a"
alias upgrade='sudo apt update && sudo apt upgrade -y && sudo snap refresh'
alias untargz="tar -czf"
alias mkcd="mkdir -p $1 && cd $1"
alias cl="cd $1 && ll"
alias myip="curl http://ipecho.net/plain; echo"
alias ports='netstat -tulpan'
alias ssh.pub='cat ~/.ssh/*.pub'
alias gpg.new="gpg --full-generate-key"
alias gpg.pub="gpg --armor --export $@"
alias gpg.list='gpg --list-keys --keyid-format SHORT'
alias docker-prune='docker image prune -f; docker network prune -f; docker container prune -f'
docker-ip() {
if [ "$1" ]; then
if [ "$1" = "-a" ]; then
docker ps -aq \
| xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \
| sed -e 's#^/##' \
| column -t
elif [ "$1" = "-c" ]; then
docker-compose ps -q \
| xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \
| sed -e 's#^/##' \
| column -t
else
docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$1"
docker port "$1"
fi
else
docker ps -q \
| xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \
| sed -e 's#^/##' \
| column -t
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment