aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/completions
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2014-09-19 19:00:29 -0700
committerGravatar Kevin Ballard <kevin@sb.org>2014-09-19 19:19:59 -0700
commita381ac2691b7c1d52ec7436a7c97ba91b3d496aa (patch)
tree94c6e053aa90a21a3e02014498c2c1abaf2406c2 /share/completions
parente2be71cbe4cd5f5eae3ebd9ffec90ba47e0ec860 (diff)
Complete custom git commands in $PATH
Git treats executables in $PATH that start with "git-" as custom subcommands. Add completion support for them. Fixes #1680.
Diffstat (limited to 'share/completions')
-rw-r--r--share/completions/git.fish21
1 files changed, 21 insertions, 0 deletions
diff --git a/share/completions/git.fish b/share/completions/git.fish
index 0c774cd0..5fda2935 100644
--- a/share/completions/git.fish
+++ b/share/completions/git.fish
@@ -91,6 +91,24 @@ function __fish_git_aliases
command git config --get-regexp '^alias\.' | sed -n "s/^alias\.\([^ ]*\).*/\1/p"
end
+function __fish_git_custom_commands
+ # complete all commands starting with git-
+ # however, a few builtin commands are placed into $PATH by git because
+ # they're used by the ssh transport. We could filter them out by checking
+ # if any of these completion results match the name of the builtin git commands,
+ # but it's simpler just to blacklist these names. They're unlikely to change,
+ # and the failure mode is we accidentally complete a plumbing command.
+ set -l IFS \n
+ for name in (builtin complete -Cgit- | sed 's/^git-\([^[:space:]]*\).*/\1/')
+ switch $name
+ case cvsserver receive-pack shell upload-archive upload-pack
+ # skip these
+ case \*
+ echo $name
+ end
+ end
+end
+
# general options
complete -f -c git -n 'not __fish_git_needs_command' -l help -d 'Display the manual of a git command'
@@ -392,3 +410,6 @@ complete -f -c git -n '__fish_git_needs_command' -a whatchanged -d 'Show logs wi
## Aliases (custom user-defined commands)
complete -c git -n '__fish_git_needs_command' -a '(__fish_git_aliases)' -d 'Alias (user-defined command)'
+
+## Custom commands (git-* commands installed in the PATH)
+complete -c git -n '__fish_git_needs_command' -a '(__fish_git_custom_commands)' -d 'Custom command'