diff options
author | Johannes Altmanninger <aclopte@gmail.com> | 2020-06-25 23:41:11 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-06-25 15:43:30 -0600 |
commit | 06f499994071bb6131244218b25d637103afe1d5 (patch) | |
tree | f5c49194b47d43dfed139dfef789c4d3ca8f7777 | |
parent | e50b18a049c54fb9b8dc2507238c08c1c8bd3fa9 (diff) |
fish-completion: reuse "git" and "grep" completions
This makes fish complete commands starting with "pass git" as if they were
starting with "git".
-rw-r--r-- | src/completion/pass.fish-completion | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/completion/pass.fish-completion b/src/completion/pass.fish-completion index 0c67bf3..3e70af1 100644 --- a/src/completion/pass.fish-completion +++ b/src/completion/pass.fish-completion @@ -52,6 +52,12 @@ function __fish_pass_print_entries_and_dirs __fish_pass_print_entries end +function __fish_pass_git_complete + set -l prefix (__fish_pass_get_prefix) + set -l git_cmd (commandline -opc) (commandline -ct) + set -e git_cmd[1 2] # Drop "pass git". + complete -C"git -C $prefix $git_cmd" +end complete -c $PROG -f -n '__fish_pass_needs_command' -a help -d 'Command: show usage help' complete -c $PROG -f -n '__fish_pass_needs_command' -a version -d 'Command: show program version' @@ -101,13 +107,11 @@ complete -c $PROG -f -n '__fish_pass_uses_command -c' -a "(__fish_pass_print_ent complete -c $PROG -f -n '__fish_pass_uses_command --clip' -a "(__fish_pass_print_entries)" complete -c $PROG -f -n '__fish_pass_needs_command' -a git -d 'Command: execute a git command' -complete -c $PROG -f -n '__fish_pass_uses_command git' -a 'init' -d 'Initialize git repository' -complete -c $PROG -f -n '__fish_pass_uses_command git' -a 'status' -d 'Show status of the repo' -complete -c $PROG -f -n '__fish_pass_uses_command git' -a 'add' -d 'Add changes to the index' -complete -c $PROG -f -n '__fish_pass_uses_command git' -a 'commit' -d 'Commit changes to the repo' -complete -c $PROG -f -n '__fish_pass_uses_command git' -a 'push' -d 'Push changes to remote repo' -complete -c $PROG -f -n '__fish_pass_uses_command git' -a 'pull' -d 'Pull changes from remote repo' -complete -c $PROG -f -n '__fish_pass_uses_command git' -a 'log' -d 'View changelog' - +complete -c $PROG -f -n '__fish_pass_uses_command git' -a '(__fish_pass_git_complete)' complete -c $PROG -f -n '__fish_pass_needs_command' -a find -d 'Command: find a password file or directory matching pattern' complete -c $PROG -f -n '__fish_pass_needs_command' -a grep -d 'Command: search inside of decrypted password files for matching pattern' +complete -c $PROG -f -n '__fish_pass_uses_command grep' -a '(begin + set -l cmd (commandline -opc) (commandline -ct) + set -e cmd[1 2] # Drop "pass grep". + complete -C"grep $cmd" +end)' |