usa il modulo git di ohmyzsh
This commit is contained in:
parent
5d66578c47
commit
206facb01c
1 changed files with 178 additions and 175 deletions
|
@ -1,192 +1,195 @@
|
|||
#
|
||||
# Git aliases.
|
||||
#
|
||||
# Functions
|
||||
# taken from oh-my-zsh project
|
||||
# https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/git/git.plugin.zsh
|
||||
|
||||
#
|
||||
# Settings
|
||||
#
|
||||
|
||||
# Log colour scheme has bold yellow commit hash, bold blue author, cyan date, auto ref names
|
||||
# See https://git-scm.com/docs/pretty-formats
|
||||
_git_log_fuller_format='%C(bold yellow)commit %H%C(auto)%d%n%C(bold)Author: %C(blue)%an <%ae> %C(no-bold cyan)%ai (%ar)%n%C(bold)Commit: %C(blue)%cn <%ce> %C(no-bold cyan)%ci (%cr)%C(reset)%n%+B'
|
||||
_git_log_oneline_format='%C(bold yellow)%h%C(reset) %s%C(auto)%d%C(reset)'
|
||||
_git_log_oneline_medium_format='%C(bold yellow)%h%C(reset) %<(50,trunc)%s %C(bold blue)<%an> %C(no-bold cyan)(%ar)%C(auto)%d%C(reset)'
|
||||
function current_branch() {
|
||||
git_current_branch
|
||||
}
|
||||
|
||||
#
|
||||
# Aliases
|
||||
# (sorted alphabetically)
|
||||
#
|
||||
|
||||
() {
|
||||
local gprefix
|
||||
zstyle -s ':zim:git' aliases-prefix 'gprefix' || gprefix=g
|
||||
alias g='git'
|
||||
|
||||
# Git
|
||||
alias ${gprefix}='git'
|
||||
alias ga='git add'
|
||||
alias gaa='git add --all'
|
||||
alias gapa='git add --patch'
|
||||
alias gau='git add --update'
|
||||
alias gav='git add --verbose'
|
||||
alias gap='git apply'
|
||||
|
||||
# Branch (b)
|
||||
alias ${gprefix}b='git branch'
|
||||
alias ${gprefix}bc='git checkout -b'
|
||||
alias ${gprefix}bl='git branch -vv'
|
||||
alias ${gprefix}bL='git branch --all -vv'
|
||||
alias ${gprefix}bm='git branch --move'
|
||||
alias ${gprefix}bM='git branch --move --force'
|
||||
alias ${gprefix}bs='git show-branch'
|
||||
alias ${gprefix}bS='git show-branch --all'
|
||||
alias ${gprefix}bx='git-branch-delete-interactive'
|
||||
alias ${gprefix}bX='git-branch-delete-interactive --force'
|
||||
alias gb='git branch'
|
||||
alias gba='git branch -a'
|
||||
alias gbd='git branch -d'
|
||||
alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
|
||||
alias gbD='git branch -D'
|
||||
alias gbl='git blame -b -w'
|
||||
alias gbnm='git branch --no-merged'
|
||||
alias gbr='git branch --remote'
|
||||
alias gbs='git bisect'
|
||||
alias gbsb='git bisect bad'
|
||||
alias gbsg='git bisect good'
|
||||
alias gbsr='git bisect reset'
|
||||
alias gbss='git bisect start'
|
||||
|
||||
# Commit (c)
|
||||
alias ${gprefix}c='git commit --verbose'
|
||||
alias ${gprefix}ca='git commit --verbose --all'
|
||||
alias ${gprefix}cm='git commit --message'
|
||||
alias ${gprefix}co='git checkout'
|
||||
alias ${gprefix}cO='git checkout --patch'
|
||||
alias ${gprefix}cf='git commit --amend --reuse-message HEAD'
|
||||
alias ${gprefix}cF='git commit --verbose --amend'
|
||||
alias ${gprefix}cp='git cherry-pick --ff'
|
||||
alias ${gprefix}cP='git cherry-pick --no-commit'
|
||||
alias ${gprefix}cr='git revert'
|
||||
alias ${gprefix}cR='git reset "HEAD^"'
|
||||
alias ${gprefix}cs='git show --pretty=format:"${_git_log_fuller_format}"'
|
||||
alias ${gprefix}cS='git commit -S'
|
||||
alias ${gprefix}cv='git verify-commit'
|
||||
alias gc='git commit -v'
|
||||
alias gc!='git commit -v --amend'
|
||||
alias gcn!='git commit -v --no-edit --amend'
|
||||
alias gca='git commit -v -a'
|
||||
alias gca!='git commit -v -a --amend'
|
||||
alias gcan!='git commit -v -a --no-edit --amend'
|
||||
alias gcans!='git commit -v -a -s --no-edit --amend'
|
||||
alias gcam='git commit -a -m'
|
||||
alias gcsm='git commit -s -m'
|
||||
alias gcb='git checkout -b'
|
||||
alias gcf='git config --list'
|
||||
alias gcl='git clone --recurse-submodules'
|
||||
alias gclean='git clean -id'
|
||||
alias gpristine='git reset --hard && git clean -dfx'
|
||||
alias gcm='git checkout master'
|
||||
alias gcd='git checkout develop'
|
||||
alias gcmsg='git commit -m'
|
||||
alias gco='git checkout'
|
||||
alias gcount='git shortlog -sn'
|
||||
alias gcp='git cherry-pick'
|
||||
alias gcpa='git cherry-pick --abort'
|
||||
alias gcpc='git cherry-pick --continue'
|
||||
alias gcs='git commit -S'
|
||||
|
||||
# Conflict (C)
|
||||
alias ${gprefix}Cl='git --no-pager diff --diff-filter=U --name-only'
|
||||
alias ${gprefix}Ca='git add $(gCl)'
|
||||
alias ${gprefix}Ce='git mergetool $(gCl)'
|
||||
alias ${gprefix}Co='git checkout --ours --'
|
||||
alias ${gprefix}CO='gCo $(gCl)'
|
||||
alias ${gprefix}Ct='git checkout --theirs --'
|
||||
alias ${gprefix}CT='gCt $(gCl)'
|
||||
alias gd='git diff'
|
||||
alias gdca='git diff --cached'
|
||||
alias gdcw='git diff --cached --word-diff'
|
||||
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
|
||||
alias gds='git diff --staged'
|
||||
alias gdt='git diff-tree --no-commit-id --name-only -r'
|
||||
alias gdw='git diff --word-diff'
|
||||
|
||||
# Data (d)
|
||||
alias ${gprefix}d='git ls-files'
|
||||
alias ${gprefix}dc='git ls-files --cached'
|
||||
alias ${gprefix}dx='git ls-files --deleted'
|
||||
alias ${gprefix}dm='git ls-files --modified'
|
||||
alias ${gprefix}du='git ls-files --other --exclude-standard'
|
||||
alias ${gprefix}dk='git ls-files --killed'
|
||||
alias ${gprefix}di='git status --porcelain --short --ignored | sed -n "s/^!! //p"'
|
||||
|
||||
# Fetch (f)
|
||||
alias ${gprefix}f='git fetch'
|
||||
alias ${gprefix}fc='git clone'
|
||||
alias ${gprefix}fm='git pull'
|
||||
alias ${gprefix}fr='git pull --rebase'
|
||||
alias ${gprefix}fu='git fetch --all --prune && git merge --ff-only @\{u\}'
|
||||
alias gf='git fetch'
|
||||
alias gfa='git fetch --all --prune'
|
||||
alias gfo='git fetch origin'
|
||||
|
||||
# Grep (g)
|
||||
alias ${gprefix}g='git grep'
|
||||
alias ${gprefix}gi='git grep --ignore-case'
|
||||
alias ${gprefix}gl='git grep --files-with-matches'
|
||||
alias ${gprefix}gL='git grep --files-without-match'
|
||||
alias ${gprefix}gv='git grep --invert-match'
|
||||
alias ${gprefix}gw='git grep --word-regexp'
|
||||
alias gfg='git ls-files | grep'
|
||||
|
||||
# Index (i)
|
||||
alias ${gprefix}ia='git add'
|
||||
alias ${gprefix}iA='git add --patch'
|
||||
alias ${gprefix}iu='git add --update'
|
||||
alias ${gprefix}id='git diff --no-ext-diff --cached'
|
||||
alias ${gprefix}iD='git diff --no-ext-diff --cached --word-diff'
|
||||
alias ${gprefix}ir='git reset'
|
||||
alias ${gprefix}iR='git reset --patch'
|
||||
alias ${gprefix}ix='git rm --cached -r'
|
||||
alias ${gprefix}iX='git rm --cached -rf'
|
||||
alias gg='git gui citool'
|
||||
alias gga='git gui citool --amend'
|
||||
|
||||
# Log (l)
|
||||
alias ${gprefix}l='git log --topo-order --pretty=format:"${_git_log_fuller_format}"'
|
||||
alias ${gprefix}ls='git log --topo-order --stat --pretty=format:"${_git_log_fuller_format}"'
|
||||
alias ${gprefix}ld='git log --topo-order --stat --patch --full-diff --pretty=format:"${_git_log_fuller_format}"'
|
||||
alias ${gprefix}lo='git log --topo-order --pretty=format:"${_git_log_oneline_format}"'
|
||||
alias ${gprefix}lO='git log --topo-order --pretty=format:"${_git_log_oneline_medium_format}"'
|
||||
alias ${gprefix}lg='git log --graph --pretty=format:"${_git_log_oneline_format}"'
|
||||
alias ${gprefix}lG='git log --graph --pretty=format:"${_git_log_oneline_medium_format}"'
|
||||
alias ${gprefix}lv='git log --topo-order --show-signature --pretty=format:"${_git_log_fuller_format}"'
|
||||
alias ${gprefix}lc='git shortlog --summary --numbered'
|
||||
alias ${gprefix}lr='git reflog'
|
||||
|
||||
# Merge (m)
|
||||
alias ${gprefix}m='git merge'
|
||||
alias ${gprefix}ma='git merge --abort'
|
||||
alias ${gprefix}mC='git merge --no-commit'
|
||||
alias ${gprefix}mF='git merge --no-ff'
|
||||
alias ${gprefix}mS='git merge -S'
|
||||
alias ${gprefix}mv='git merge --verify-signatures'
|
||||
alias ${gprefix}mt='git mergetool'
|
||||
|
||||
# Push (p)
|
||||
alias ${gprefix}p='git push'
|
||||
alias ${gprefix}pf='git push --force-with-lease'
|
||||
alias ${gprefix}pF='git push --force'
|
||||
alias ${gprefix}pa='git push --all'
|
||||
alias ${gprefix}pA='git push --all && git push --tags'
|
||||
alias ${gprefix}pt='git push --tags'
|
||||
alias ${gprefix}pc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"'
|
||||
alias ${gprefix}pp='git pull origin "$(git-branch-current 2> /dev/null)" && git push origin "$(git-branch-current 2> /dev/null)"'
|
||||
|
||||
# Rebase (r)
|
||||
alias ${gprefix}r='git rebase'
|
||||
alias ${gprefix}ra='git rebase --abort'
|
||||
alias ${gprefix}rc='git rebase --continue'
|
||||
alias ${gprefix}ri='git rebase --interactive'
|
||||
alias ${gprefix}rs='git rebase --skip'
|
||||
|
||||
# Remote (R)
|
||||
alias ${gprefix}R='git remote'
|
||||
alias ${gprefix}Rl='git remote --verbose'
|
||||
alias ${gprefix}Ra='git remote add'
|
||||
alias ${gprefix}Rx='git remote rm'
|
||||
alias ${gprefix}Rm='git remote rename'
|
||||
alias ${gprefix}Ru='git remote update'
|
||||
alias ${gprefix}Rp='git remote prune'
|
||||
alias ${gprefix}Rs='git remote show'
|
||||
|
||||
# Stash (s)
|
||||
alias ${gprefix}s='git stash'
|
||||
alias ${gprefix}sa='git stash apply'
|
||||
alias ${gprefix}sx='git stash drop'
|
||||
alias ${gprefix}sX='git-stash-clear-interactive'
|
||||
alias ${gprefix}sl='git stash list'
|
||||
alias ${gprefix}sd='git stash show --patch --stat'
|
||||
alias ${gprefix}sp='git stash pop'
|
||||
alias ${gprefix}sr='git-stash-recover'
|
||||
alias ${gprefix}ss='git stash save --include-untracked'
|
||||
alias ${gprefix}sS='git stash save --patch --no-keep-index'
|
||||
alias ${gprefix}sw='git stash save --include-untracked --keep-index'
|
||||
alias ${gprefix}su='git stash show --patch | git apply --reverse'
|
||||
|
||||
# Submodule (S)
|
||||
alias ${gprefix}S='git submodule'
|
||||
alias ${gprefix}Sa='git submodule add'
|
||||
alias ${gprefix}Sf='git submodule foreach'
|
||||
alias ${gprefix}Si='git submodule init'
|
||||
alias ${gprefix}SI='git submodule update --init --recursive'
|
||||
alias ${gprefix}Sl='git submodule status'
|
||||
alias ${gprefix}Sm='git-submodule-move'
|
||||
alias ${gprefix}Ss='git submodule sync'
|
||||
alias ${gprefix}Su='git submodule foreach git pull origin master'
|
||||
alias ${gprefix}Sx='git-submodule-remove'
|
||||
|
||||
# Tag (t)
|
||||
alias ${gprefix}t='git tag'
|
||||
alias ${gprefix}ts='git tag --sign'
|
||||
alias ${gprefix}tv='git verify-tag'
|
||||
alias ${gprefix}tx='git tag --delete'
|
||||
|
||||
# Working tree (w)
|
||||
alias ${gprefix}ws='git status --short'
|
||||
alias ${gprefix}wS='git status'
|
||||
alias ${gprefix}wd='git diff --no-ext-diff'
|
||||
alias ${gprefix}wD='git diff --no-ext-diff --word-diff'
|
||||
alias ${gprefix}wr='git reset --soft'
|
||||
alias ${gprefix}wR='git reset --hard'
|
||||
alias ${gprefix}wc='git clean --dry-run'
|
||||
alias ${gprefix}wC='git clean -d --force'
|
||||
alias ${gprefix}wx='git rm -r'
|
||||
alias ${gprefix}wX='git rm -rf'
|
||||
|
||||
# Misc
|
||||
alias ${gprefix}..='cd "$(git-root || print .)"'
|
||||
function ggf() {
|
||||
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||
git push --force origin "${b:=$1}"
|
||||
}
|
||||
alias ggpur='ggu'
|
||||
alias ggpull='git pull origin "$(git_current_branch)"'
|
||||
alias ggpush='git push origin "$(git_current_branch)"'
|
||||
|
||||
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
|
||||
alias gpsup='git push --set-upstream origin $(git_current_branch)'
|
||||
|
||||
alias ghh='git help'
|
||||
|
||||
alias gignore='git update-index --assume-unchanged'
|
||||
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
|
||||
|
||||
alias gk='\gitk --all --branches'
|
||||
alias gke='\gitk --all $(git log -g --pretty=%h)'
|
||||
|
||||
alias gl='git pull'
|
||||
alias glg='git log --stat'
|
||||
alias glgp='git log --stat -p'
|
||||
alias glgg='git log --graph'
|
||||
alias glgga='git log --graph --decorate --all'
|
||||
alias glgm='git log --graph --max-count=10'
|
||||
alias glo='git log --oneline --decorate'
|
||||
alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
|
||||
alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat"
|
||||
alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"
|
||||
alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
|
||||
alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all"
|
||||
alias glog='git log --oneline --decorate --graph'
|
||||
alias gloga='git log --oneline --decorate --graph --all'
|
||||
|
||||
alias gm='git merge'
|
||||
alias gmom='git merge origin/master'
|
||||
alias gmt='git mergetool --no-prompt'
|
||||
alias gmtvim='git mergetool --no-prompt --tool=vimdiff'
|
||||
alias gmum='git merge upstream/master'
|
||||
alias gma='git merge --abort'
|
||||
|
||||
alias gp='git push'
|
||||
alias gpd='git push --dry-run'
|
||||
alias gpf='git push --force-with-lease'
|
||||
alias gpf!='git push --force'
|
||||
alias gpoat='git push origin --all && git push origin --tags'
|
||||
alias gpu='git push upstream'
|
||||
alias gpv='git push -v'
|
||||
|
||||
alias gr='git remote'
|
||||
alias gra='git remote add'
|
||||
alias grb='git rebase'
|
||||
alias grba='git rebase --abort'
|
||||
alias grbc='git rebase --continue'
|
||||
alias grbd='git rebase develop'
|
||||
alias grbi='git rebase -i'
|
||||
alias grbm='git rebase master'
|
||||
alias grbs='git rebase --skip'
|
||||
alias grev='git revert'
|
||||
alias grh='git reset'
|
||||
alias grhh='git reset --hard'
|
||||
alias groh='git reset origin/$(git_current_branch) --hard'
|
||||
alias grm='git rm'
|
||||
alias grmc='git rm --cached'
|
||||
alias grmv='git remote rename'
|
||||
alias grrm='git remote remove'
|
||||
alias grs='git restore'
|
||||
alias grset='git remote set-url'
|
||||
alias grss='git restore --source'
|
||||
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
|
||||
alias gru='git reset --'
|
||||
alias grup='git remote update'
|
||||
alias grv='git remote -v'
|
||||
|
||||
alias gsb='git status -sb'
|
||||
alias gsd='git svn dcommit'
|
||||
alias gsh='git show'
|
||||
alias gsi='git submodule init'
|
||||
alias gsps='git show --pretty=short --show-signature'
|
||||
alias gsr='git svn rebase'
|
||||
alias gss='git status -s'
|
||||
alias gst='git status'
|
||||
|
||||
# use the default stash push on git 2.13 and newer
|
||||
autoload -Uz is-at-least
|
||||
is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')" \
|
||||
&& alias gsta='git stash push' \
|
||||
|| alias gsta='git stash save'
|
||||
|
||||
alias gstaa='git stash apply'
|
||||
alias gstc='git stash clear'
|
||||
alias gstd='git stash drop'
|
||||
alias gstl='git stash list'
|
||||
alias gstp='git stash pop'
|
||||
alias gsts='git stash show --text'
|
||||
alias gstall='git stash --all'
|
||||
alias gsu='git submodule update'
|
||||
alias gsw='git switch'
|
||||
alias gswc='git switch -c'
|
||||
|
||||
alias gts='git tag -s'
|
||||
alias gtv='git tag | sort -V'
|
||||
alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl'
|
||||
|
||||
alias gunignore='git update-index --no-assume-unchanged'
|
||||
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
|
||||
alias gup='git pull --rebase'
|
||||
alias gupv='git pull --rebase -v'
|
||||
alias gupa='git pull --rebase --autostash'
|
||||
alias gupav='git pull --rebase --autostash -v'
|
||||
alias glum='git pull upstream master'
|
||||
|
||||
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
|
||||
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"'
|
||||
|
||||
|
|
Loading…
Reference in a new issue