fix ability to undefine default aliases in zsh
The ability to not define default aliases in the `.git.scmbrc` file
leading to not having those aliases not present worked fine in bash.
However, this seems to still have thrown an error in zsh. For example,
if you commented out the line:
git_checkout_alias="gco"
then when sourcing scm_breeze aliases.sh would throw an error.
This applied only to aliases defined with the `_alias()` function and
not those with the `_git_alias()` function.
To fix this, I wrapped `_alias()` in a similar check to the one
`_git_alias()` has, where it passes the portions as arguments and
verifies the first is present before proceeding.
I'm not 100% certain why seperate functions exist for these two things
to begin with (as far as I can tell from a cursory examination the main
difference is `_git_aliases()` defines a tab completion?) but I believe
my change has fixed the ability to comment out aliases in `.git.scmbrc`
in zsh for users who do not want them (I'm in this boat, there are too
many for me and I get confused).
I tested manually in both bash and zsh and it appears to work, however
you might want to review this before merging given my relative
unfamiliarity with the codebase.
This commit is contained in:
@@ -37,7 +37,7 @@ function git(){
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
_alias $git_alias='git'
|
_alias "$git_alias" "git"
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
@@ -75,14 +75,14 @@ __git_alias () {
|
|||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# SCM Breeze functions
|
# SCM Breeze functions
|
||||||
_alias $git_status_shortcuts_alias="git_status_shortcuts"
|
_alias "$git_status_shortcuts_alias" "git_status_shortcuts"
|
||||||
_alias $git_add_shortcuts_alias="git_add_shortcuts"
|
_alias "$git_add_shortcuts_alias" "git_add_shortcuts"
|
||||||
_alias $exec_scmb_expand_args_alias="exec_scmb_expand_args"
|
_alias "$exec_scmb_expand_args_alias" "exec_scmb_expand_args"
|
||||||
_alias $git_show_files_alias="git_show_affected_files"
|
_alias "$git_show_files_alias" "git_show_affected_files"
|
||||||
_alias $git_commit_all_alias='git_commit_all'
|
_alias "$git_commit_all_alias" "git_commit_all"
|
||||||
|
|
||||||
# Git Index alias
|
# Git Index alias
|
||||||
_alias $git_index_alias="git_index"
|
_alias "$git_index_alias" "git_index"
|
||||||
|
|
||||||
# Only set up the following aliases if 'git_setup_aliases' is 'yes'
|
# Only set up the following aliases if 'git_setup_aliases' is 'yes'
|
||||||
if [ "$git_setup_aliases" = "yes" ]; then
|
if [ "$git_setup_aliases" = "yes" ]; then
|
||||||
@@ -139,16 +139,17 @@ if [ "$git_setup_aliases" = "yes" ]; then
|
|||||||
|
|
||||||
|
|
||||||
# Compound/complex commands
|
# Compound/complex commands
|
||||||
_alias $git_fetch_all_alias="git fetch --all"
|
_alias "$git_fetch_all_alias" "git fetch --all"
|
||||||
_alias $git_pull_then_push_alias="git pull && git push"
|
_alias "$git_pull_then_push_alias" "git pull && git push"
|
||||||
_alias $git_fetch_and_rebase_alias='git fetch && git rebase'
|
_alias "$git_fetch_and_rebase_alias" "git fetch && git rebase"
|
||||||
_alias $git_commit_amend_alias='git commit --amend'
|
_alias "$git_commit_amend_alias" "git commit --amend"
|
||||||
|
|
||||||
# Add staged changes to latest commit without prompting for message
|
# Add staged changes to latest commit without prompting for message
|
||||||
_alias $git_commit_amend_no_msg_alias='git commit --amend -C HEAD'
|
_alias "$git_commit_amend_no_msg_alias" "git commit --amend -C HEAD"
|
||||||
_alias $git_commit_no_msg_alias='git commit -C HEAD'
|
_alias "$git_commit_no_msg_alias" "git commit -C HEAD"
|
||||||
_alias $git_log_stat_alias='git log --stat --max-count=5'
|
_alias "$git_log_stat_alias" "git log --stat --max-count=5"
|
||||||
_alias $git_log_graph_alias='git log --graph --max-count=5'
|
_alias "$git_log_graph_alias" "git log --graph --max-count=5"
|
||||||
_alias $git_add_all_alias='git add --all .'
|
_alias "$git_add_all_alias" "git add --all ."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -168,4 +169,3 @@ if [ $shell = "bash" ]; then
|
|||||||
else
|
else
|
||||||
compdef _git_index_tab_completion git_index $git_index_alias
|
compdef _git_index_tab_completion git_index $git_index_alias
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ enable_nullglob() { if [ $shell = "zsh" ]; then setopt NULL_GLOB; else shopt
|
|||||||
disable_nullglob() { if [ $shell = "zsh" ]; then unsetopt NULL_GLOB; else shopt -u nullglob; fi; }
|
disable_nullglob() { if [ $shell = "zsh" ]; then unsetopt NULL_GLOB; else shopt -u nullglob; fi; }
|
||||||
|
|
||||||
# Alias wrapper that ignores errors if alias is not defined.
|
# Alias wrapper that ignores errors if alias is not defined.
|
||||||
_alias(){ alias "$@" 2> /dev/null; }
|
_safe_alias(){ alias "$@" 2> /dev/null; }
|
||||||
|
_alias() {
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
local alias_str="$1"; local cmd="$2"
|
||||||
|
_safe_alias $alias_str="$cmd"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
find_binary(){
|
find_binary(){
|
||||||
if [ $shell = "zsh" ]; then
|
if [ $shell = "zsh" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user