1
0
Fork 0
mirror of synced 2024-11-26 09:15:34 -05:00

[git] Allow aliases prefix to be something else than g

There were a couple of reports before about aliases shadowing commands
in #59 and #139. And I was impressed to check how many actually shadow existing commands using Ubuntu's command-not-found:

    'gb'  : apt install gb
    'gc'  : apt install graphviz
    'gcp' : apt install gcp
    'gcs' : apt install opengcs
    'gcv' : apt install scotch
    'gdc' : apt install gdc
    'gfm' : apt install gfm
    'gid' : apt install id-utils
    'gld' : apt install postfix-gld
    'gm'  : apt install graphicsmagick
    'gmt' : apt install gmt
    'gp'  : apt install pari-gp
    'gpa' : apt install gpa
    'gpp' : apt install gpp
    'gpt' : apt install gpt
    'grc' : apt install grc
    'gri' : apt install gri
    'gs'  : apt install ghostscript
    'gsl' : apt install generator-scripting-language
    'gss' : apt install libgss-dev
    'gt'  : apt install genometools
    'gtv' : apt install smpeg-gtv
    'gwc' : apt install geneweb
    'gwd' : apt install geneweb

The ability to customize the prefix fixes this issue. Picking `G` for
example is a good one (Vim's Fugitive uses upper case `G` in the
beginning of is commands, to mention another place where it's used).

Closes zimfw/git#1

Copied from zimfw/git@b2a2ffbd31
This commit is contained in:
Eric Nielsen 2019-01-21 16:27:29 -05:00
parent 38b3b9517e
commit d2c1e613ae
2 changed files with 148 additions and 147 deletions

View file

@ -205,23 +205,21 @@ Aliases
* `g..` changes the current directory to the top level of the working tree. * `g..` changes the current directory to the top level of the working tree.
### Shadows Settings
--------
The following aliases may shadow system commands: By default, all aliases are defined with a `g` prefix, as you can see above. But
some of the default aliases may shadow system commands, like `gpt` for the GUID
* `gb` shadows a [build tool for the Go programming language](https://getgb.io/). partition table maintenance utility.
* `gm` shadows [GraphicsMagick](http://www.graphicsmagick.org/).
* `gpt` shadows the GUID partition table maintenance utility.
* `grc` shadows [Generic Colouriser](https://github.com/garabik/grc).
* `gs` shadows [Ghostscript](https://www.ghostscript.com/).
If you frequently use the above commands, you may wish to disable this module
altogether, or to disable the specific aliases with `unalias` at the bottom of
your `.zshrc`.
You can temporarily bypass an alias by prefixing it with a backward slash: You can temporarily bypass an alias by prefixing it with a backward slash:
`\gpt`. `\gpt`.
Or you can use the following zstyle if you wish to customize the prefix used to
define all aliases:
zstyle ':zim:git' aliases-prefix 'G'
Functions Functions
--------- ---------

View file

@ -8,178 +8,181 @@
# Log colour scheme has bold yellow commit hash, bold blue author, cyan date, auto ref names # Log colour scheme has bold yellow commit hash, bold blue author, cyan date, auto ref names
# See https://git-scm.com/docs/pretty-formats # See https://git-scm.com/docs/pretty-formats
_git_log_medium_format='%C(bold)Commit: %C(yellow)%H%C(reset)%C(auto)%d%n%C(bold)Author:%C(reset) %C(bold blue)%an <%ae>%n%C(bold)Date:%C(reset) %C(cyan)%ai (%ar)%C(reset)%n%+B' _git_log_medium_format='%C(bold)Commit: %C(yellow)%H%C(auto)%d%n%C(bold)Author: %C(blue)%an <%ae>%n%C(bold)Date: %C(no-bold cyan)%ai (%ar)%C(reset)%n%+B'
_git_log_oneline_format='%C(bold)%C(yellow)%h%C(reset) %s%C(auto)%d%C(reset)' _git_log_oneline_format='%C(bold yellow)%h%C(reset) %s%C(auto)%d%C(reset)'
_git_log_oneline_medium_format='%C(bold)%C(yellow)%h%C(reset) %<|(60,trunc)%s %C(bold blue)<%an> %C(reset)%C(cyan)(%ar)%C(auto)%d%C(reset)' _git_log_oneline_medium_format='%C(bold yellow)%h%C(reset) %<|(60,trunc)%s %C(bold blue)<%an> %C(no-bold cyan)(%ar)%C(auto)%d%C(reset)'
# #
# Aliases # Aliases
# #
local gprefix
zstyle -s ':zim:git' aliases-prefix 'gprefix' || gprefix=g
# Git # Git
alias g='git' alias ${gprefix}='git'
# Branch (b) # Branch (b)
alias gb='git branch' alias ${gprefix}b='git branch'
alias gbc='git checkout -b' alias ${gprefix}bc='git checkout -b'
alias gbl='git branch -vv' alias ${gprefix}bl='git branch -vv'
alias gbL='git branch --all -vv' alias ${gprefix}bL='git branch --all -vv'
alias gbm='git branch --move' alias ${gprefix}bm='git branch --move'
alias gbM='git branch --move --force' alias ${gprefix}bM='git branch --move --force'
alias gbs='git show-branch' alias ${gprefix}bs='git show-branch'
alias gbS='git show-branch --all' alias ${gprefix}bS='git show-branch --all'
alias gbx='git-branch-delete-interactive' alias ${gprefix}bx='git-branch-delete-interactive'
alias gbX='git-branch-delete-interactive --force' alias ${gprefix}bX='git-branch-delete-interactive --force'
# Commit (c) # Commit (c)
alias gc='git commit --verbose' alias ${gprefix}c='git commit --verbose'
alias gca='git commit --verbose --all' alias ${gprefix}ca='git commit --verbose --all'
alias gcm='git commit --message' alias ${gprefix}cm='git commit --message'
alias gco='git checkout' alias ${gprefix}co='git checkout'
alias gcO='git checkout --patch' alias ${gprefix}cO='git checkout --patch'
alias gcf='git commit --amend --reuse-message HEAD' alias ${gprefix}cf='git commit --amend --reuse-message HEAD'
alias gcF='git commit --verbose --amend' alias ${gprefix}cF='git commit --verbose --amend'
alias gcp='git cherry-pick --ff' alias ${gprefix}cp='git cherry-pick --ff'
alias gcP='git cherry-pick --no-commit' alias ${gprefix}cP='git cherry-pick --no-commit'
alias gcr='git revert' alias ${gprefix}cr='git revert'
alias gcR='git reset "HEAD^"' alias ${gprefix}cR='git reset "HEAD^"'
alias gcs='git show --pretty=format:"${_git_log_medium_format}"' alias ${gprefix}cs='git show --pretty=format:"${_git_log_medium_format}"'
alias gcS='git commit -S' alias ${gprefix}cS='git commit -S'
alias gcv='git verify-commit' alias ${gprefix}cv='git verify-commit'
# Conflict (C) # Conflict (C)
alias gCl='git --no-pager diff --diff-filter=U --name-only' alias ${gprefix}Cl='git --no-pager diff --diff-filter=U --name-only'
alias gCa='git add $(gCl)' alias ${gprefix}Ca='git add $(gCl)'
alias gCe='git mergetool $(gCl)' alias ${gprefix}Ce='git mergetool $(gCl)'
alias gCo='git checkout --ours --' alias ${gprefix}Co='git checkout --ours --'
alias gCO='gCo $(gCl)' alias ${gprefix}CO='gCo $(gCl)'
alias gCt='git checkout --theirs --' alias ${gprefix}Ct='git checkout --theirs --'
alias gCT='gCt $(gCl)' alias ${gprefix}CT='gCt $(gCl)'
# Data (d) # Data (d)
alias gd='git ls-files' alias ${gprefix}d='git ls-files'
alias gdc='git ls-files --cached' alias ${gprefix}dc='git ls-files --cached'
alias gdx='git ls-files --deleted' alias ${gprefix}dx='git ls-files --deleted'
alias gdm='git ls-files --modified' alias ${gprefix}dm='git ls-files --modified'
alias gdu='git ls-files --other --exclude-standard' alias ${gprefix}du='git ls-files --other --exclude-standard'
alias gdk='git ls-files --killed' alias ${gprefix}dk='git ls-files --killed'
alias gdi='git status --porcelain --short --ignored | sed -n "s/^!! //p"' alias ${gprefix}di='git status --porcelain --short --ignored | sed -n "s/^!! //p"'
# Fetch (f) # Fetch (f)
alias gf='git fetch' alias ${gprefix}f='git fetch'
alias gfc='git clone' alias ${gprefix}fc='git clone'
alias gfm='git pull' alias ${gprefix}fm='git pull'
alias gfr='git pull --rebase' alias ${gprefix}fr='git pull --rebase'
alias gfu='git fetch --all --prune && git merge --ff-only @\{u\}' alias ${gprefix}fu='git fetch --all --prune && git merge --ff-only @\{u\}'
# Grep (g) # Grep (g)
alias gg='git grep' alias ${gprefix}g='git grep'
alias ggi='git grep --ignore-case' alias ${gprefix}gi='git grep --ignore-case'
alias ggl='git grep --files-with-matches' alias ${gprefix}gl='git grep --files-with-matches'
alias ggL='git grep --files-without-match' alias ${gprefix}gL='git grep --files-without-match'
alias ggv='git grep --invert-match' alias ${gprefix}gv='git grep --invert-match'
alias ggw='git grep --word-regexp' alias ${gprefix}gw='git grep --word-regexp'
# Index (i) # Index (i)
alias gia='git add' alias ${gprefix}ia='git add'
alias giA='git add --patch' alias ${gprefix}iA='git add --patch'
alias giu='git add --update' alias ${gprefix}iu='git add --update'
alias gid='git diff --no-ext-diff --cached' alias ${gprefix}id='git diff --no-ext-diff --cached'
alias giD='git diff --no-ext-diff --cached --word-diff' alias ${gprefix}iD='git diff --no-ext-diff --cached --word-diff'
alias gir='git reset' alias ${gprefix}ir='git reset'
alias giR='git reset --patch' alias ${gprefix}iR='git reset --patch'
alias gix='git rm --cached -r' alias ${gprefix}ix='git rm --cached -r'
alias giX='git rm --cached -rf' alias ${gprefix}iX='git rm --cached -rf'
# Log (l) # Log (l)
alias gl='git log --topo-order --pretty=format:"${_git_log_medium_format}"' alias ${gprefix}l='git log --topo-order --pretty=format:"${_git_log_medium_format}"'
alias gls='git log --topo-order --stat --pretty=format:"${_git_log_medium_format}"' alias ${gprefix}ls='git log --topo-order --stat --pretty=format:"${_git_log_medium_format}"'
alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:"${_git_log_medium_format}"' alias ${gprefix}ld='git log --topo-order --stat --patch --full-diff --pretty=format:"${_git_log_medium_format}"'
alias glo='git log --topo-order --pretty=format:"${_git_log_oneline_format}"' alias ${gprefix}lo='git log --topo-order --pretty=format:"${_git_log_oneline_format}"'
alias glO='git log --topo-order --pretty=format:"${_git_log_oneline_medium_format}"' alias ${gprefix}lO='git log --topo-order --pretty=format:"${_git_log_oneline_medium_format}"'
alias glg='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_format}"' alias ${gprefix}lg='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_format}"'
alias glG='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_medium_format}"' alias ${gprefix}lG='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_medium_format}"'
alias glv='git log --topo-order --show-signature --pretty=format:"${_git_log_medium_format}"' alias ${gprefix}lv='git log --topo-order --show-signature --pretty=format:"${_git_log_medium_format}"'
alias glc='git shortlog --summary --numbered' alias ${gprefix}lc='git shortlog --summary --numbered'
alias glr='git reflog' alias ${gprefix}lr='git reflog'
# Merge (m) # Merge (m)
alias gm='git merge' alias ${gprefix}m='git merge'
alias gmC='git merge --no-commit' alias ${gprefix}mC='git merge --no-commit'
alias gmF='git merge --no-ff' alias ${gprefix}mF='git merge --no-ff'
alias gma='git merge --abort' alias ${gprefix}ma='git merge --abort'
alias gmt='git mergetool' alias ${gprefix}mt='git mergetool'
# Push (p) # Push (p)
alias gp='git push' alias ${gprefix}p='git push'
alias gpf='git push --force-with-lease' alias ${gprefix}pf='git push --force-with-lease'
alias gpF='git push --force' alias ${gprefix}pF='git push --force'
alias gpa='git push --all' alias ${gprefix}pa='git push --all'
alias gpA='git push --all && git push --tags' alias ${gprefix}pA='git push --all && git push --tags'
alias gpt='git push --tags' alias ${gprefix}pt='git push --tags'
alias gpc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"' alias ${gprefix}pc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"'
alias gpp='git pull origin "$(git-branch-current 2> /dev/null)" && git push 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) # Rebase (r)
alias gr='git rebase' alias ${gprefix}r='git rebase'
alias gra='git rebase --abort' alias ${gprefix}ra='git rebase --abort'
alias grc='git rebase --continue' alias ${gprefix}rc='git rebase --continue'
alias gri='git rebase --interactive' alias ${gprefix}ri='git rebase --interactive'
alias grs='git rebase --skip' alias ${gprefix}rs='git rebase --skip'
# Remote (R) # Remote (R)
alias gR='git remote' alias ${gprefix}R='git remote'
alias gRl='git remote --verbose' alias ${gprefix}Rl='git remote --verbose'
alias gRa='git remote add' alias ${gprefix}Ra='git remote add'
alias gRx='git remote rm' alias ${gprefix}Rx='git remote rm'
alias gRm='git remote rename' alias ${gprefix}Rm='git remote rename'
alias gRu='git remote update' alias ${gprefix}Ru='git remote update'
alias gRp='git remote prune' alias ${gprefix}Rp='git remote prune'
alias gRs='git remote show' alias ${gprefix}Rs='git remote show'
# Stash (s) # Stash (s)
alias gs='git stash' alias ${gprefix}s='git stash'
alias gsa='git stash apply' alias ${gprefix}sa='git stash apply'
alias gsx='git stash drop' alias ${gprefix}sx='git stash drop'
alias gsX='git-stash-clear-interactive' alias ${gprefix}sX='git-stash-clear-interactive'
alias gsl='git stash list' alias ${gprefix}sl='git stash list'
alias gsd='git stash show --patch --stat' alias ${gprefix}sd='git stash show --patch --stat'
alias gsp='git stash pop' alias ${gprefix}sp='git stash pop'
alias gsr='git-stash-recover' alias ${gprefix}sr='git-stash-recover'
alias gss='git stash save --include-untracked' alias ${gprefix}ss='git stash save --include-untracked'
alias gsS='git stash save --patch --no-keep-index' alias ${gprefix}sS='git stash save --patch --no-keep-index'
alias gsw='git stash save --include-untracked --keep-index' alias ${gprefix}sw='git stash save --include-untracked --keep-index'
alias gsu='git stash show --patch | git apply --reverse' alias ${gprefix}su='git stash show --patch | git apply --reverse'
# Submodule (S) # Submodule (S)
alias gS='git submodule' alias ${gprefix}S='git submodule'
alias gSa='git submodule add' alias ${gprefix}Sa='git submodule add'
alias gSf='git submodule foreach' alias ${gprefix}Sf='git submodule foreach'
alias gSi='git submodule init' alias ${gprefix}Si='git submodule init'
alias gSI='git submodule update --init --recursive' alias ${gprefix}SI='git submodule update --init --recursive'
alias gSl='git submodule status' alias ${gprefix}Sl='git submodule status'
alias gSm='git-submodule-move' alias ${gprefix}Sm='git-submodule-move'
alias gSs='git submodule sync' alias ${gprefix}Ss='git submodule sync'
alias gSu='git submodule foreach git pull origin master' alias ${gprefix}Su='git submodule foreach git pull origin master'
alias gSx='git-submodule-remove' alias ${gprefix}Sx='git-submodule-remove'
# Tag (t) # Tag (t)
alias gt='git tag' alias ${gprefix}t='git tag'
alias gts='git tag --sign' alias ${gprefix}ts='git tag --sign'
alias gtv='git verify-tag' alias ${gprefix}tv='git verify-tag'
alias gtx='git tag --delete' alias ${gprefix}tx='git tag --delete'
# Working tree (w) # Working tree (w)
alias gws='git status --short' alias ${gprefix}ws='git status --short'
alias gwS='git status' alias ${gprefix}wS='git status'
alias gwd='git diff --no-ext-diff' alias ${gprefix}wd='git diff --no-ext-diff'
alias gwD='git diff --no-ext-diff --word-diff' alias ${gprefix}wD='git diff --no-ext-diff --word-diff'
alias gwr='git reset --soft' alias ${gprefix}wr='git reset --soft'
alias gwR='git reset --hard' alias ${gprefix}wR='git reset --hard'
alias gwc='git clean --dry-run' alias ${gprefix}wc='git clean --dry-run'
alias gwC='git clean -d --force' alias ${gprefix}wC='git clean -d --force'
alias gwx='git rm -r' alias ${gprefix}wx='git rm -r'
alias gwX='git rm -rf' alias ${gprefix}wX='git rm -rf'
# Misc # Misc
alias g..='cd "$(git-root || print .)"' alias ${gprefix}..='cd "$(git-root || print .)"'