Cover image for My favourite aliases

My favourite aliases

mrtnrdl profile image Martin Riedel ・2 min read

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

alias aliases="cat ~/.dotfiles/zsh/.zsh/aliases.zsh"

Not sure if you have an alias? Can't remember the specific alias you're looking for? Just aliases and you'll get the list.


For my git workflow, i'm relying heavily on aliases to reduce the typing necessary:

alias gc="git commit"
alias gs="git status"
alias gd="git diff"
alias gf="git fetch"
alias gm="git merge"
alias gma="git merge --abort"
alias gr="git rebase"
alias gp="git push"
alias gpf="git push --force-with-lease"
alias gu="git unstage"
alias gg="git graph"
alias gl="git log --pretty --oneline --graph"
alias gA="git add -A"
alias gri="git rebase -i"
alias grc="git rebase --continue"
alias gra="git rebase --abort"


Currently I'm working with scala and sbt most of the time, and due to that circumstance, I've added several aliases for that.

alias sfmt="sbt scalafmt test:scalafmt sbt:scalafmt"
alias sdt="sbt clean dependencyTree"
alias sdc="sbt clean dependencyCheck"
alias sdu="sbt clean dependencyUpdates"
alias ssg="sbt clean scapegoat"
alias sct="sbt clean test"


Do you know the days, when you barely manage to glimpse the sun? Fear no more - with that alias you're informed about the weather in your <location>!

alias weather="curl http://wttr.in/<location>"

picture credit to kevin ku

Posted on by:

mrtnrdl profile

Martin Riedel


Working as a developer for several years - curiosity led me to information security. I'm either busy building something or trying to break it.


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"

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!


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😁


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!