mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-13 16:04:08 +08:00
refactor(git): convert functions to aliases for improved readability and performance
This commit is contained in:
parent
e9fc134236
commit
f312e24997
@ -101,14 +101,8 @@ function work_in_progress() {
|
|||||||
|
|
||||||
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
|
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
|
||||||
|
|
||||||
function ggpnp() {
|
alias ggpnp='command git pull origin "$(git_current_branch)" && command git push origin "$(git_current_branch)"'
|
||||||
if [[ $# == 0 ]]; then
|
compdef _git ggpnp=git-push
|
||||||
ggl && ggp
|
|
||||||
else
|
|
||||||
ggl "${*}" && ggp "${*}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
compdef _git ggpnp=git-checkout
|
|
||||||
|
|
||||||
alias ggpur='ggu'
|
alias ggpur='ggu'
|
||||||
alias g='git'
|
alias g='git'
|
||||||
@ -218,14 +212,12 @@ alias gdcw='git diff --cached --word-diff'
|
|||||||
alias gds='git diff --staged'
|
alias gds='git diff --staged'
|
||||||
alias gdw='git diff --word-diff'
|
alias gdw='git diff --word-diff'
|
||||||
|
|
||||||
function gdv() { git diff -w "$@" | view - }
|
alias gdv='command git diff -w | view -'
|
||||||
compdef _git gdv=git-diff
|
compdef _git gdv=git-diff
|
||||||
|
|
||||||
alias gdup='git diff @{upstream}'
|
alias gdup='git diff @{upstream}'
|
||||||
|
|
||||||
function gdnolock() {
|
alias gdnolock='command git diff -- ":(exclude)package-lock.json" ":(exclude)*.lock"'
|
||||||
git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock"
|
|
||||||
}
|
|
||||||
compdef _git gdnolock=git-diff
|
compdef _git gdnolock=git-diff
|
||||||
|
|
||||||
alias gdt='git diff-tree --no-commit-id --name-only -r'
|
alias gdt='git diff-tree --no-commit-id --name-only -r'
|
||||||
@ -279,11 +271,7 @@ alias gprv='git pull --rebase -v'
|
|||||||
alias gpra='git pull --rebase --autostash'
|
alias gpra='git pull --rebase --autostash'
|
||||||
alias gprav='git pull --rebase --autostash -v'
|
alias gprav='git pull --rebase --autostash -v'
|
||||||
|
|
||||||
function ggu() {
|
alias ggu='command git pull --rebase origin "$(git_current_branch)"'
|
||||||
local b
|
|
||||||
[[ $# != 1 ]] && b="$(git_current_branch)"
|
|
||||||
git pull --rebase origin "${b:-$1}"
|
|
||||||
}
|
|
||||||
compdef _git ggu=git-pull
|
compdef _git ggu=git-pull
|
||||||
|
|
||||||
alias gprom='git pull --rebase origin $(git_main_branch)'
|
alias gprom='git pull --rebase origin $(git_main_branch)'
|
||||||
@ -292,15 +280,7 @@ alias gprum='git pull --rebase upstream $(git_main_branch)'
|
|||||||
alias gprumi='git pull --rebase=interactive upstream $(git_main_branch)'
|
alias gprumi='git pull --rebase=interactive upstream $(git_main_branch)'
|
||||||
alias ggpull='git pull origin "$(git_current_branch)"'
|
alias ggpull='git pull origin "$(git_current_branch)"'
|
||||||
|
|
||||||
function ggl() {
|
alias ggl='command git pull origin "$(git_current_branch)"'
|
||||||
if [[ $# != 0 ]] && [[ $# != 1 ]]; then
|
|
||||||
git pull origin "${*}"
|
|
||||||
else
|
|
||||||
local b
|
|
||||||
[[ $# == 0 ]] && b="$(git_current_branch)"
|
|
||||||
git pull origin "${b:-$1}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
compdef _git ggl=git-pull
|
compdef _git ggl=git-pull
|
||||||
|
|
||||||
alias gluc='git pull upstream $(git_current_branch)'
|
alias gluc='git pull upstream $(git_current_branch)'
|
||||||
@ -308,11 +288,7 @@ alias glum='git pull upstream $(git_main_branch)'
|
|||||||
alias gp='git push'
|
alias gp='git push'
|
||||||
alias gpd='git push --dry-run'
|
alias gpd='git push --dry-run'
|
||||||
|
|
||||||
function ggf() {
|
alias ggf='command git push --force origin "$(git_current_branch)"'
|
||||||
local b
|
|
||||||
[[ $# != 1 ]] && b="$(git_current_branch)"
|
|
||||||
git push --force origin "${b:-$1}"
|
|
||||||
}
|
|
||||||
compdef _git ggf=git-push
|
compdef _git ggf=git-push
|
||||||
|
|
||||||
alias gpf!='git push --force'
|
alias gpf!='git push --force'
|
||||||
@ -320,11 +296,7 @@ is-at-least 2.30 "$git_version" \
|
|||||||
&& alias gpf='git push --force-with-lease --force-if-includes' \
|
&& alias gpf='git push --force-with-lease --force-if-includes' \
|
||||||
|| alias gpf='git push --force-with-lease'
|
|| alias gpf='git push --force-with-lease'
|
||||||
|
|
||||||
function ggfl() {
|
alias ggfl='command git push --force-with-lease origin "$(git_current_branch)"'
|
||||||
local b
|
|
||||||
[[ $# != 1 ]] && b="$(git_current_branch)"
|
|
||||||
git push --force-with-lease origin "${b:-$1}"
|
|
||||||
}
|
|
||||||
compdef _git ggfl=git-push
|
compdef _git ggfl=git-push
|
||||||
|
|
||||||
alias gpsup='git push --set-upstream origin $(git_current_branch)'
|
alias gpsup='git push --set-upstream origin $(git_current_branch)'
|
||||||
@ -336,15 +308,7 @@ alias gpoat='git push origin --all && git push origin --tags'
|
|||||||
alias gpod='git push origin --delete'
|
alias gpod='git push origin --delete'
|
||||||
alias ggpush='git push origin "$(git_current_branch)"'
|
alias ggpush='git push origin "$(git_current_branch)"'
|
||||||
|
|
||||||
function ggp() {
|
alias ggp='command git push origin "$(git_current_branch)"'
|
||||||
if [[ $# != 0 ]] && [[ $# != 1 ]]; then
|
|
||||||
git push origin "${*}"
|
|
||||||
else
|
|
||||||
local b
|
|
||||||
[[ $# == 0 ]] && b="$(git_current_branch)"
|
|
||||||
git push origin "${b:-$1}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
compdef _git ggp=git-push
|
compdef _git ggp=git-push
|
||||||
|
|
||||||
alias gpu='git push upstream'
|
alias gpu='git push upstream'
|
||||||
@ -421,7 +385,7 @@ alias gwtls='git worktree list'
|
|||||||
alias gwtmv='git worktree move'
|
alias gwtmv='git worktree move'
|
||||||
alias gwtrm='git worktree remove'
|
alias gwtrm='git worktree remove'
|
||||||
alias gstu='gsta --include-untracked'
|
alias gstu='gsta --include-untracked'
|
||||||
alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl'
|
alias gtl='command git tag --sort=-v:refname -n --list'
|
||||||
alias gk='\gitk --all --branches &!'
|
alias gk='\gitk --all --branches &!'
|
||||||
alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
|
alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user