.profile: Add git aliases, minor polish

This commit is contained in:
Salt 2019-09-01 21:34:02 -05:00
parent edd21b58cc
commit 4e7965e8aa

View File

@ -115,6 +115,93 @@ if has emerge; then
alias e-cleanup='sudo eclean -d distfiles && sudo eclean -d packages'
fi
fi
if has git; then
# Thanks Bash-it!
alias g='git'
alias ga='git add'
alias gall='git add -A'
alias gap='git add -p'
alias gb='git branch'
alias gbD='git branch -D'
alias gba='git branch -a'
alias gbd='git branch -d'
alias gbm='git branch -m'
alias gbt='git branch --track'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gcam="git commit -v -am"
alias gcb='git checkout -b'
alias gci='git commit --interactive'
alias gcl='git clone'
alias gclean='git clean -fd'
alias gcm='git commit -v -m'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcom='git checkout master'
alias gcount='git shortlog -sn'
alias gcp='git cherry-pick'
alias gcpd='git checkout master; git pull; git branch -D'
alias gcpx='git cherry-pick -x'
alias gcsam="git commit -S -am"
alias gct='git checkout --track'
alias gd='git diff'
alias gdel='git branch -D'
alias gds='git diff --staged'
alias gdv='git diff -w "$@" | vim -R -'
alias get='git'
alias gexport='git archive --format zip --output'
alias gf='git fetch --all --prune'
alias gft='git fetch --all --prune --tags'
alias gftv='git fetch --all --prune --tags --verbose'
alias gfv='git fetch --all --prune --verbose'
alias ggs="gg --stat"
alias ggui="git gui"
alias gh='cd "$(git rev-parse --show-toplevel)"'
alias gl='git pull'
alias gll='git log --graph --pretty=oneline --abbrev-commit'
alias glum='git pull upstream master'
alias gm="git merge"
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master'
alias gmv='git mv'
alias gp='git push'
alias gpatch="git format-patch -1"
alias gpo='git push origin'
alias gpom='git push origin master'
alias gpp='git pull && git push'
alias gpr='git pull --rebase'
alias gpristine='git reset --hard && git clean -dfx'
alias gpu='git push --set-upstream'
alias gpuo='git push --set-upstream origin'
alias gpuoc='git push --set-upstream origin $(git symbolic-ref --short HEAD)'
alias gr='git remote'
alias gra='git remote add'
alias grm='git rm'
alias grv='git remote -v'
alias gs='git status'
alias gsl="git shortlog -sn"
alias gss='git status -s'
alias gst="git stash"
alias gstb="git stash branch"
alias gstd="git stash drop"
alias gstl="git stash list"
alias gstp="git stash pop"
alias gsu='git submodule update --init --recursive'
alias gt="git tag"
alias gta="git tag -a"
alias gtd="git tag -d"
alias gtl="git tag -l"
alias gtls='git tag -l | sort -V'
alias gup='git fetch && git rebase'
alias gus='git reset HEAD'
alias gwc="git whatchanged"
# Add uncommitted and unstaged changes to the last commit
alias gcaa="git commit -a --amend -C HEAD"
# From http://blogs.atlassian.com/2014/10/advanced-git-aliases/
# Show commits since last pull
alias gnew="git log HEAD@{1}..HEAD@{0}"
# Show untracked files
alias gu='git ls-files . --exclude-standard --others'
fi
if has instantmusic; then
alias song='instantmusic -p -s'
alias songp='instantmusic -s'
@ -200,9 +287,6 @@ _ps1() {
/bin/ksh)
prefix="${prefix}${fg_green}"
;;
/bin/sh)
prefix="${prefix}${fg_grey}"
;;
*)
;;
esac
@ -213,7 +297,7 @@ _ps1() {
cpwd="$PWD"
fi
# Alert us if the last command failed
fail=""
unset fail
if ! [ "$exitcode" = "0" ]; then
fail="${fg_bold}${fg_red}?"
fi
@ -227,11 +311,11 @@ case "$_baseshell" in
# Don't do this on ZSH
# I have a custom theme for that
;;
sh|dash)
export PS1='\$ '
*bash|ksh)
export PS1='$(_ps1)'
;;
*)
export PS1='$(_ps1)'
export PS1='[\e[31m\w\e[0m]\e[32m\$\e[0m '
;;
esac