These are the aliases I actually have loaded, kept in ~/.config/fish/functions/aliases.fish and sourced from config.fish. I use fish but the aliases work unchanged in bash or zsh, apart from the zoxide setup line and omfu which are fish-specific.
Getting around
cdb is the one I reach for most: cd - returns to wherever you just were, which comes up far more often than you’d expect.
# Go to previous dir
alias cdb='cd -'
# Clear screen and list dir
alias cls='clear;ls'
# Go up multiple directories
alias ...='cd ../..'
alias ....='cd ../../..'
# Show me files matching "ls grep"
alias lsg='ll | grep'
alias ll='ls -alGh'
alias ls='ls -Gh'
# See the last modified files
alias lh='ls -alt | head'
I use eza as a nicer ls:
alias x='eza'
alias l='eza --long --header -g -a --classify=auto'
# Open dir in ForkLift
alias f='open -a ForkLift'
For jumping to frequently used directories I use zoxide. It isn’t an alias, but --cmd j names its command j, which keeps my old autojump muscle memory working:
zoxide init fish --cmd j | source
Disk usage
# Show human friendly numbers and colors
alias df='df -h'
alias du='du -h -d 2'
GZippin’
alias gz='tar -zcvf'
Git
This is the bulk of it. The pattern is roughly “first letter of each word”, so git commit -m is gcm and git fetch --all --prune is gfap. A few have duplicates because I could never settle on one spelling — gsh, gshw and gshow all run git show.
alias gs='git status -sb'
alias ga='git add -A'
alias gap='git add -p'
alias gc='git commit'
alias gcm='git commit -m'
alias gci='git commit'
alias gcim='git commit -m'
alias gam='git commit --amend --reset-author'
alias gco='git checkout'
alias gcp='git cherry-pick'
alias gd='git diff'
alias gb='git branch'
alias gw='git switch'
alias gnb='git switch -c' # new branch, aka checkout -b
alias gcn='git clone'
alias gi='vim .gitignore'
alias gsh='git show'
alias gshw='git show'
alias gshow='git show'
Undoing things
alias guns='git restore --staged'
alias gunc='git reset --soft HEAD^'
alias grs='git reset'
alias grsh='git reset --hard'
alias gcln='git clean'
alias gclndf='git clean -df'
alias gclndfx='git clean -dfx'
Stashing, merging and rebasing
alias gst='git stash'
alias gsp='git stash pop'
alias gsa='git stash apply'
alias gm='git merge'
alias gms='git merge --squash'
alias gr='git rebase'
alias gra='git rebase --abort'
alias ggrc='git rebase --continue'
alias gbi='git rebase --interactive'
Moving things in and out
alias gf='git fetch'
alias gfch='git fetch'
alias gfp='git fetch --prune'
alias gfa='git fetch --all'
alias gfap='git fetch --all --prune'
alias gp='git push'
alias gps='git push'
alias gpsh='git push -u origin HEAD'
alias gpl='git pull'
alias gplr='git pull --rebase'
alias grv='git remote -v'
alias grr='git remote rm'
alias grad='git remote add'
A prettier log, and some things built on top of it
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
# Show differing commits between master and develop; skip merges
alias gdb='gl --no-merges master..develop'
# Same, for repos that use main
alias gdbm='gl --no-merges main..develop'
# Just the files that differ
alias gdbf='gl --no-merges --name-only main..develop'
# Count differing commits
alias gcnt='git rev-list --count master..develop'
# Differences between local and remote
alias gdr='gl origin/develop..develop'
Staged and cached are the same thing, so these two are identical:
alias gdc='git diff --cached -w'
alias gds='git diff --staged -w'
Submodules, bisecting, and removing merged branches
alias gsm='git submodule'
alias gsmi='git submodule init'
alias gsmu='git submodule update'
alias gbg='git bisect good'
alias gbb='git bisect bad'
# Delete every branch already merged into this one
alias gdmb='git branch --merged | grep -v "\*" | xargs -n 1 git branch -d'
Shell odds and ends
alias less='less -r'
alias tf='tail -f'
alias cl='clear'
alias screen='env TERM=screen screen'
alias k9='kill -9'
alias ka9='killall -9'
# A quick random password
alias genpass='openssl rand -base64 13 | colrm 14'
# Find my IP address
alias myip="curl http://ipecho.net/plain; echo"
macOS
The dock spacer trick is the one people usually ask about — it inserts an invisible tile you can drag around to group your dock icons.
# Add space to the dock
alias dockgap="defaults write com.apple.dock persistent-apps -array-add '{\"tile-type\"=\"spacer-tile\";}'; killall Dock"
alias dockgapsm="defaults write com.apple.dock persistent-apps -array-add '{\"tile-type\"=\"small-spacer-tile\";}'; killall Dock"
# Toggle hidden files in Finder
alias showfiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hidefiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
# Get an app or file's UTI
alias app_uti='mdls /Applications/IINA.app/ | grep kMDItemCFBundleIdentifier'
alias file_uti='mdls ./package.json | grep kMDItemContentType'
Editors
# Sublime Text, current directory
alias s.="subl ."
# Sublime Merge
alias sm='open -a "Sublime Merge"'
Package managers
# Update everything homebrew knows about
alias brewu='brew update && brew upgrade -y && brew upgrade --cask -y && brew cleanup && brew doctor'
# Update Oh My Fish itself
alias omfu='omf update omf'
# Most common NPM commands
alias npmi='npm install'
alias npmd='npm run dev'
alias npmb='npm run build'
alias npma='npm run archive'
# Local Grunt
alias gru='node_modules/grunt/bin/grunt'
A note on fish
In fish, alias defines a function for the current session, so the file is sourced from config.fish on every start:
source ~/.config/fish/functions/aliases.fish
If you want them to persist without re-sourcing, alias --save writes each one out to its own file under ~/.config/fish/functions/. And for anything you’d rather see expanded before you hit enter, fish’s abbr is usually the better tool than alias.