Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
executable file 163 lines (124 sloc) 4.21 KB
alias ..="cd .."
alias ...="cd ../.."
alias ctags="`brew --prefix`/bin/ctags"
alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules"
alias preview="fzf --preview 'bat --color \"always\" {}'"
alias cat='bat --paging always'
# Vim aliases that will open an already running instance of vim
# in the background rather than starting a new instance. No more
# guessing of 'fg' or 'vim'!
# alias vi='if jobs | grep -q nvim; then fg; else command nvim; fi'
# alias vim='if jobs | grep -q nvim; then fg; else command nvim; fi'
alias vi="nvim"
alias vim="nvim"
# Jump to a directory
alias j='fasd_cd -d'
alias v='f -e nvim'
# Tmux
alias tmux="TERM=screen-256color-bce tmux"
alias mux="tmuxinator start"
# Miscellaneous Helpers
alias reload="source ~/.zshrc"
# Set vim as the editor
export EDITOR='nvim'
# List all files colorized in long format, including dot files
alias ls="exa -a --sort=type"
alias ll="exa -la --sort=type --git"
# Git
alias g="git"
# Shorten common commands
alias gst='g status'
alias gpl='g pull'
alias gpu='g push'
alias gf='g fetch'
alias gco='g checkout'
alias grb='g rebase'
alias grbc='g rebase --continue'
alias grba='g rebase --abort'
alias ga='g add'
alias gm='g merge'
alias gsp='git stash push' # Push is implied with `git stash` but push allows a file to be specified without -- separator
alias gspi='git stash push --patch'
alias gspp='git stash pop'
alias gua='git reset HEAD --'
# More succinct status
alias gs='g status -sb'
# Show all branches in the order of last change
show_branches() {
local branches branch
branches=$(git branch -v --sort=-committerdate | grep -v HEAD) &&
branch=$(echo "$branches" | fzf +m) &&
git checkout $(echo "$branch" | awk '{print $1}' | sed "s/.* //")
alias gb='show_branches'
# alias gb='g for-each-ref --sort=committerdate refs/heads/ --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))"'
# Nicer diff
alias gd='g diff --word-diff'
# Delete a branch
alias gdb='g branch -D'
# Fancy git log
alias gl='g log --graph --stat --abbrev-commit --date=relative'
# Push branch and set the upstream
alias gpb='g push --set-upstream origin "$(g rev-parse --abbrev-ref HEAD)"'
# Safer force push
alias gpbf='g push --set-upstream --force-with-lease origin "$(g rev-parse --abbrev-ref HEAD)"'
# Pull the latest from master and rebase
alias gup='g pull --rebase origin master'
# Pull the latest from master and merge
alias gum='g pull origin master'
# Ammend a commit
alias gam='g commit --amend --no-edit'
# Save changes temporarily
alias gwip='g commit --no-verify -m "WIP"'
alias gwipa='g add -A && g commit --no-verify -m "WIP"'
# Undo the last commit
alias gun='g reset HEAD~1 --mixed'
# Super undo using the reflog...careful. Undo your undo.
alias gungun='g reset "HEAD@{1}"'
# Delete all merged branches
alias gcl='g branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'
# Commit
alias gc='g commit -v -m'
# Add all and commit
alias gca='g add -u && g add . && g commit -v'
# Create new branch
alias gcob='g checkout -b'
# Add all
alias gaa='g add -u && g add . && g status'
# Interactive adding
alias gap='g add -p && g status'
# Interactive rebase for squashing commits
alias gir="g rebase -i origin/master"
# Removes all new commits on a branch but keeps all the changes
gclear () {
git reset $(git merge-base master $(git rev-parse --abbrev-ref HEAD))
finder () {
open .
dockerstop () {
docker kill $(docker ps -q)
# dockerclean () {
# docker rm $(docker ps -a -q) && docker rmi $(docker images -q)
# }
# list all docker containers, with all statuses
alias dpa="docker ps -a"
# connect to docker shell
function dockershell {
if [ -n "$2" ]; then
docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -it $1 /bin/bash -c ${*:2}
docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -it $1 /bin/bash
# stop and remove all docker containers
function dockerclean {
COUNT=$(dpa | tail -n +2 | wc -l);
echo "Clearing ${COUNT// /} Docker processes"
for name in $(dpa | awk '{print $NF}'| tail -n +2); do
docker stop $name;
docker rm $name;
done | uniq -c
echo "Done"