mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-13 11:21:13 +02:00
37665: Completion: New helper _absolute_command_paths.
This commit is contained in:
parent
9df6c728e8
commit
c6fc6f80cd
4 changed files with 43 additions and 4 deletions
|
@ -1,5 +1,9 @@
|
|||
2016-01-20 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||
|
||||
* 37665: Completion/Unix/Command/_git,
|
||||
Completion/Unix/Type/_absolute_command_paths, Doc/Zsh/compsys.yo:
|
||||
Completion: New helper _absolute_command_paths.
|
||||
|
||||
* 37664: Completion/Unix/Type/_path_commands, Doc/Zsh/compsys.yo:
|
||||
docs: Document the completion function _command_names.
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
29
Completion/Unix/Type/_absolute_command_paths
Normal file
29
Completion/Unix/Type/_absolute_command_paths
Normal file
|
@ -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 "$@"
|
|
@ -3461,6 +3461,12 @@ completion has been tried. A function will only be called once unless
|
|||
it explicitly reinserts itself into the array.
|
||||
|
||||
startitem()
|
||||
findex(_absolute_command_paths)
|
||||
item(tt(_absolute_command_paths))(
|
||||
This function completes external commands as absolute paths (unlike
|
||||
tt(_command_names -e) which completes their basenames). It takes no
|
||||
arguments.
|
||||
)
|
||||
findex(_all_labels)
|
||||
item(tt(_all_labels) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(command) var(arg) ... ])(
|
||||
This is a convenient interface to the tt(_next_label) function below,
|
||||
|
|
Loading…
Reference in a new issue