zsh: git: do not fail when aliases are undefined

pull/6/head
bretello 2022-08-18 16:37:24 +02:00
parent b2df319e18
commit 72a02e22e0
Signed by: brethil
GPG Key ID: 876AAC6290170FE7
1 changed files with 12 additions and 5 deletions

View File

@ -75,7 +75,14 @@ function git-show-changes(){
git log --reverse HEAD^..
}
unalias gco
# oh-my-zsh has some aliases which we might want to override
# with functions
function _disable_alias() {
[[ -n $(alias "$1") ]] && unalias "$1"
}
_disable_alias gco
function gco() {
if [[ "$#" -ge 1 ]]; then
g checkout $@
@ -85,7 +92,8 @@ function gco() {
}
unalias gcor
_disable_alias gcor
function gcor() {
if [[ "$#" -ge 1 ]]; then
g checkout $@
@ -95,7 +103,7 @@ function gcor() {
}
unalias gbd
_disable_alias gbd
function gbd() {
if [[ "$#" -ge 1 ]]; then
g branch -d $@
@ -105,7 +113,7 @@ function gbd() {
}
unalias gbD
_disable_alias gbD
function gbD() {
if [[ "$#" -ge 1 ]]; then
g branch -D $@
@ -113,4 +121,3 @@ function gbD() {
g branch -D $(gb | fzf -m)
fi
}