Added git_augment_current_aliases option if you just want to wrap your
current git aliases, instead of overriding them all with new ones.
This commit is contained in:
@@ -9,6 +9,11 @@ export gs_max_changes="150"
|
|||||||
# - When using the git_add_shorcuts() command, automatically invoke 'git rm' to remove deleted files?
|
# - When using the git_add_shorcuts() command, automatically invoke 'git rm' to remove deleted files?
|
||||||
export ga_auto_remove="yes"
|
export ga_auto_remove="yes"
|
||||||
|
|
||||||
|
# - Set the following option to 'yes' if you want to augment your existing git aliases,
|
||||||
|
# instead of overwriting them.
|
||||||
|
# Note: Bash tab completion will not be automatically set up for your aliases if you choose this option.
|
||||||
|
export git_augment_current_aliases="no"
|
||||||
|
|
||||||
|
|
||||||
# Git Index Config
|
# Git Index Config
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
|
|||||||
@@ -55,6 +55,12 @@ _alias $exec_git_expand_args_alias="exec_git_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
|
||||||
|
_alias $git_index_alias="git_index"
|
||||||
|
|
||||||
|
# Only set up aliases if git_augment_current_aliases is not 'yes'
|
||||||
|
if [ "$git_augment_current_aliases" != "yes" ]; then
|
||||||
|
|
||||||
# Expand numbers and ranges for commands that deal with paths
|
# Expand numbers and ranges for commands that deal with paths
|
||||||
_exp="exec_git_expand_args"
|
_exp="exec_git_expand_args"
|
||||||
__git_alias "$git_checkout_alias" "$_exp git" "checkout"
|
__git_alias "$git_checkout_alias" "$_exp git" "checkout"
|
||||||
@@ -67,6 +73,9 @@ __git_alias "$git_blame_alias" "$_exp git" "blame"
|
|||||||
__git_alias "$git_diff_alias" "$_exp git" "diff"
|
__git_alias "$git_diff_alias" "$_exp git" "diff"
|
||||||
__git_alias "$git_diff_cached_alias" "$_exp git" "diff" "--cached"
|
__git_alias "$git_diff_cached_alias" "$_exp git" "diff" "--cached"
|
||||||
__git_alias "$git_add_patch_alias" "$_exp git" "add" "-p"
|
__git_alias "$git_add_patch_alias" "$_exp git" "add" "-p"
|
||||||
|
# Custom default format for git log
|
||||||
|
git_log_command="log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
|
||||||
|
__git_alias "$git_log_alias" "$_exp git" "$git_log_command"
|
||||||
|
|
||||||
# Standard commands
|
# Standard commands
|
||||||
__git_alias "$git_clone_alias" "git" 'clone'
|
__git_alias "$git_clone_alias" "git" 'clone'
|
||||||
@@ -85,9 +94,6 @@ __git_alias "$git_rebase_alias_continue" "git" 'rebase' "--continue"
|
|||||||
__git_alias "$git_rebase_alias_abort" "git" 'rebase' "--abort"
|
__git_alias "$git_rebase_alias_abort" "git" 'rebase' "--abort"
|
||||||
__git_alias "$git_merge_alias" "git" 'merge'
|
__git_alias "$git_merge_alias" "git" 'merge'
|
||||||
__git_alias "$git_cherry_pick_alias" "git" 'cherry-pick'
|
__git_alias "$git_cherry_pick_alias" "git" 'cherry-pick'
|
||||||
|
|
||||||
git_log_command="log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
|
|
||||||
__git_alias "$git_log_alias" "git" "$git_log_command"
|
|
||||||
__git_alias "$git_show_alias" "git" 'show'
|
__git_alias "$git_show_alias" "git" 'show'
|
||||||
|
|
||||||
|
|
||||||
@@ -104,9 +110,19 @@ _alias $git_log_graph_alias='git log --graph --max-count=5'
|
|||||||
_alias $git_add_all_alias='git add -A'
|
_alias $git_add_all_alias='git add -A'
|
||||||
_alias $git_branch_all_alias='git branch -a'
|
_alias $git_branch_all_alias='git branch -a'
|
||||||
|
|
||||||
|
# Otherwise, wrap any existing git aliases with 'exec_git_expand_args'
|
||||||
|
else
|
||||||
|
OLDIFS="$IFS"; IFS=$'\n'
|
||||||
|
for git_alias in $(alias | grep "git " --color=never); do
|
||||||
|
# Set up the new alias if not already wrapped with exec_git_expand_args
|
||||||
|
if [[ "$git_alias" != *exec_git_expand_args* ]]; then
|
||||||
|
new_alias=$(echo -n "$git_alias" | sed -e 's/git /exec_git_expand_args git /g')
|
||||||
|
eval "$new_alias"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
fi
|
||||||
|
|
||||||
# Git Index alias
|
|
||||||
_alias $git_index_alias="git_index"
|
|
||||||
|
|
||||||
|
|
||||||
# ZSH tab completion
|
# ZSH tab completion
|
||||||
|
|||||||
Reference in New Issue
Block a user