Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add option to turn off setup of shell completion #342

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions git.scmbrc.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export ga_auto_remove="yes"
# Note: Bash tab completion will not be automatically set up for your aliases if you disable this option.
export git_setup_aliases="yes"

# - Set the following option to 'yes' if you want to turn off shell completion setup
# export git_skip_shell_completion="yes"

# Git Index Config
# ----------------------------------------------
Expand Down
36 changes: 20 additions & 16 deletions lib/git/aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ __git_alias () {
fi

alias $alias_str="$cmd_prefix $cmd${cmd_args:+ }${cmd_args[*]}"
if [ "$shell" = "bash" ]; then
__define_git_completion "$alias_str" "$cmd"
complete -o default -o nospace -F _git_"$alias_str"_shortcut "$alias_str"
if [ "$git_skip_shell_completion" != "yes" ]; then
if [ "$shell" = "bash" ]; then
__define_git_completion "$alias_str" "$cmd"
complete -o default -o nospace -F _git_"$alias_str"_shortcut "$alias_str"
fi
fi
fi
}
Expand Down Expand Up @@ -180,17 +182,19 @@ fi


# Tab completion
if [ $shell = "bash" ]; then
# Fix to preload Arch bash completion for git
[[ -s "/usr/share/git/completion/git-completion.bash" ]] && source "/usr/share/git/completion/git-completion.bash"
# new path in Ubuntu 13.04
[[ -s "/usr/share/bash-completion/completions/git" ]] && source "/usr/share/bash-completion/completions/git"
complete -o default -o nospace -F __git_wrap__git_main $git_alias

# Git repo management & aliases.
# If you know how to rewrite _git_index_tab_completion() for zsh, please send me a pull request!
complete -o nospace -F _git_index_tab_completion git_index
complete -o nospace -F _git_index_tab_completion $git_index_alias
else
compdef _git_index_tab_completion git_index $git_index_alias
if [ "$git_skip_shell_completion" != "yes" ]; then
if [ $shell = "bash" ]; then
# Fix to preload Arch bash completion for git
[[ -s "/usr/share/git/completion/git-completion.bash" ]] && source "/usr/share/git/completion/git-completion.bash"
# new path in Ubuntu 13.04
[[ -s "/usr/share/bash-completion/completions/git" ]] && source "/usr/share/bash-completion/completions/git"
complete -o default -o nospace -F __git_wrap__git_main $git_alias

# Git repo management & aliases.
# If you know how to rewrite _git_index_tab_completion() for zsh, please send me a pull request!
complete -o nospace -F _git_index_tab_completion git_index
complete -o nospace -F _git_index_tab_completion $git_index_alias
else
compdef _git_index_tab_completion git_index $git_index_alias
fi
fi
12 changes: 7 additions & 5 deletions lib/git/branch_shortcuts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ __git_alias "$git_branch_delete_alias" "_scmb_git_branch_shortcuts" "-d"
__git_alias "$git_branch_delete_force_alias" "_scmb_git_branch_shortcuts" "-D"

# Define completions for git branch shortcuts
if [ "$shell" = "bash" ]; then
for alias_str in $git_branch_alias $git_branch_all_alias $git_branch_move_alias $git_branch_delete_alias; do
__define_git_completion $alias_str branch
complete -o default -o nospace -F _git_"$alias_str"_shortcut $alias_str
done
if [ "$git_skip_shell_completion" != "yes" ]; then
if [ "$shell" = "bash" ]; then
for alias_str in $git_branch_alias $git_branch_all_alias $git_branch_move_alias $git_branch_delete_alias; do
__define_git_completion $alias_str branch
complete -o default -o nospace -F _git_"$alias_str"_shortcut $alias_str
done
fi
fi
6 changes: 4 additions & 2 deletions lib/git/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ git_swap_remotes() {
echo "Swapped $1 <-> $2"
}
# (use git fetch tab completion)
if [ "$shell" = "bash" ]; then
complete -o default -o nospace -F _git_fetch git_swap_remotes
if [ "$git_skip_shell_completion" != "yes" ]; then
if [ "$shell" = "bash" ]; then
complete -o default -o nospace -F _git_fetch git_swap_remotes
fi
fi


Expand Down
Loading