diff options
author | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-01-18 02:36:59 +0000 |
---|---|---|
committer | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-01-20 07:49:29 +0000 |
commit | c6fc6f80cd960af914400eb3f49c52fc17598ba5 (patch) | |
tree | 0b9b8338901dc0882d45d957dcddb321611bce73 /Completion/Unix | |
parent | 9df6c728e8e43a20e337debbd17c6509f31f570f (diff) | |
download | zsh-c6fc6f80cd960af914400eb3f49c52fc17598ba5.tar.gz zsh-c6fc6f80cd960af914400eb3f49c52fc17598ba5.tar.xz zsh-c6fc6f80cd960af914400eb3f49c52fc17598ba5.zip |
37665: Completion: New helper _absolute_command_paths.
Diffstat (limited to 'Completion/Unix')
-rw-r--r-- | Completion/Unix/Command/_git | 8 | ||||
-rw-r--r-- | Completion/Unix/Type/_absolute_command_paths | 29 |
2 files changed, 33 insertions, 4 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 2a124c18c..ce3521972 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -1941,7 +1941,7 @@ _git-config () { 'branch.*.pushremote:what remote git push should push to::__git_remotes' 'branch.*.rebase:rebase on top of fetched branch::->bool:false' 'browser.*.cmd:browser command to use:browser:_cmdstring' - 'browser.*.path:path to use for the browser:absolute browser path:_files -g "*(*)"' + 'browser.*.path:path to use for the browser:absolute browser path:_absolute_command_paths' clean.requireForce:'require --force for git clean to actually do something::->bool:true' color.branch:'color output of git branch::->color-bool:false' color.branch.current:'color of the current branch::->color' @@ -2013,7 +2013,7 @@ _git-config () { diff.suppressBlankEmpty:'inhibit printing space before empty output lines::->bool:false' diff.tool:'diff tool to use::__git_difftools' 'difftool.*.cmd:command to invoke for the diff tool::_cmdstring' - 'difftool.*.path:path to use for the diff tool:absolute diff tool path:_files -g "*(*)"' + 'difftool.*.path:path to use for the diff tool:absolute diff tool path:_absolute_command_paths' difftool.prompt:'prompt before each invocation of the diff tool::->bool:true' diff.wordRegex:'regex used to determine what a word is when performing word-by-word diff:regular expression:->string' diff.guitool:'diff tool with gui to use::__git_difftools' @@ -2180,7 +2180,7 @@ _git-config () { mailmap.file:'augmenting mailmap file:mailmap file:_files' man.viewer:'man viewer to use for help in man format::__git_man_viewers' 'man.*.cmd:the command to invoke the specified man viewer:man command:_cmdstring' - 'man.*.path:path to use for the man viewer:absolute man tool path:_files -g "*(*)"' + 'man.*.path:path to use for the man viewer:absolute man tool path:_absolute_command_paths' merge.branchdesc:'populate the log message with the branch description text as well::->bool:false' merge.conflictstyle:'style used for conflicted hunks::->merge.conflictstyle:merge' merge.defaultToUpstream:'merge the upstream branches configured for the current branch by default::->bool:true' @@ -2194,7 +2194,7 @@ _git-config () { 'merge.*.name:human-readable name for custom low-level merge driver:name:->string' 'merge.*.driver:command that implements a custom low-level merge driver:merge command:_cmdstring' 'merge.*.recursive:low-level merge driver to use when performing internal merge between common ancestors::__git_builtin_merge_drivers' - 'mergetool.*.path:path to use for the merge tool:absolute merge tool path:_files -g "*(*)"' + 'mergetool.*.path:path to use for the merge tool:absolute merge tool path:_absolute_command_paths' 'mergetool.*.cmd:command to invoke for the merge tool:merge command:_cmdstring' 'mergetool.*.trustExitCode:trust the exit code of the merge tool::->bool:false' mergetool.keepBackup:'keep the original file with conflict markers::->bool:true' diff --git a/Completion/Unix/Type/_absolute_command_paths b/Completion/Unix/Type/_absolute_command_paths new file mode 100644 index 000000000..e9ab17023 --- /dev/null +++ b/Completion/Unix/Type/_absolute_command_paths @@ -0,0 +1,29 @@ +#autoload + +# This function completes 'ls' to '/bin/ls' +_hashed_absolute_command_paths() { + local -aU set_of_dirs_of_hashed_commands=( ${^commands%/*}/ ) + local i + integer ret=1 + for i in $set_of_dirs_of_hashed_commands + do + compadd -M "l:|=$i" "$expl[@]" -a 'commands[(R)${~i}[^/]#]' + ret=0 + done + return ret +} + +# This function completes absolute pathnames of executables, e.g., /etc/rc.local +_typed-in_absolute_command_paths() { + # TODO: the description "full path to an executable" and tag in the caller are ignored by _path_files + _path_files -/ -g '*(-*)' -P / -W / +} + +_absolute_command_paths() { + _alternative \ + 'commands:hashed command by absolute path:_hashed_absolute_command_paths' \ + 'commands:full path to an executable:_typed-in_absolute_command_paths' +} + + +_absolute_command_paths "$@" |