My favourite aliases

Martin Riedel on November 12, 2018

Inspired by Daniels Blogpost, I had a look in my alias.zsh file, that i use to keep all aliases in one place. alias for all the aliases... [Read Full]
markdown guide
 

I'm not sure, but if you are using ZSH you don't need a special alias for listing all aliases, just type alias in the terminal, and you should get the list of all active aliases. Cool list tho :)

Here are a few of mine (Manjaro & OSX, zsh):

# those are for linux
alias h="history"
alias work='cd /work/'
alias keybhr='setxkbmap hr'
alias keybus='setxkbmap us'
alias rem-orphans=' pacman -Rs $(pacman -Qqdt)'
alias nxt="playerctl -p spotify next"
alias prv="playerctl -p spotify previous"
alias pp="playerctl -p spotify play-pause"
alias bootservices="systemctl list-unit-files | grep enabled"
alias fixit='sudo rm -f /var/lib/pacman/db.lck && sudo pacman-mirrors -g && sudo pacman -Syyuu  && sudo pacman -Suu'

# Reload the shell (i.e. invoke as a login shell)
alias reload="exec $SHELL -l"

# Set custom aliases
alias c="clear"
alias ping=" ping -c 5"
alias mkdir="mkdir -p"
alias sudo="sudo " #makes sudo recognize aliases.
alias help='tldr'

# Git aliases
alias gst='git status --short --branch'
alias gpoh='git push origin HEAD'
alias gits='git status -uno'
# View abbreviated SHA, description, history graph, time and author
alias glog='git log --color --graph --date=iso --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset" --abbrev-commit --'
# Show a formatted commit tree
alias gtree="git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
# Show unmodified tracked files
alias gunm='echo -e "$(git ls-files --modified)\n$(git ls-files)" | sort | uniq -u'
# Nuke files from repo history
alias gnuke='sh ~/.dotfiles/scripts/git-nuke.sh'

alias nvp='npm version patch'

alias grep='grep --color=tty -d skip'
alias cp="cp -i"                          # confirm before overwriting something
alias df='df -h'                          # human-readable sizes
alias free='free -m'                      # show sizes in MB

# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"

# Yarn aliases
alias ya="yarn add"
alias yrm="yarn remove"
alias yanl="yarn add --no-lockfile"
alias yrn="yarn run"
alias ycc="yarn cache clean"
alias yh="yarn help"
alias yo="yarn outdated"
alias yui="yarn upgrade-interactive"
 

In bash alias command works to, but cat will give you more information, if you have good comments in your alias file :D

 

I was writing the same!

I use grep on my bashrc files, this captures the comments inline with the alias too😁

 

holy cow. today i learned. thanks! I'm using zsh indeed - and did not know 'bout that.

also quite a nice list you got there - i'm diggin df and your spotify-controls!

 

These have saved me a lot of time:

alias .. = '../'
alias ... = '../../'
alias .... = '../../../'
alias ..... = '../../../../'

# cd after mkdir
function mcd {
    mkdir -p "$@" && builtin cd "$@"
}

# ls after cd
function cd {
    builtin cd "$@" && ls -G
}
 

the first time tried I use same as you, but when typing '..?', it will make me need to count how many dot and then it can hurt my eye. So better I switch to something like this:

alias cd2 = '../../'
alias cd3 = '../../../'
alias cd4 = '../../../../'

less typo, easy to remember so it better

 
 

I've done something similar as well.

alias ..="cd .."
alias ...="cd .. && cd .."

It's a time saver for sure!

code of conduct - report abuse