Skip to content

Instantly share code, notes, and snippets.

@camerond
Created March 13, 2023 15:23
Show Gist options
  • Save camerond/f9701b48a4f18ea0513fe2deb2fdac22 to your computer and use it in GitHub Desktop.
Save camerond/f9701b48a4f18ea0513fe2deb2fdac22 to your computer and use it in GitHub Desktop.
git aliases
# from https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/git.zsh
function git_current_branch() {
local ref
ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo.
ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
}
alias vim='nvim'
alias gst="git status"
alias gd="git diff"
alias gup="git pull --rebase"
alias gco="git checkout"
alias gp="git push"
alias gpsup='git push --set-upstream origin $(git_current_branch)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment