diff options
author | Niklas Haas <git@haasn.dev> | 2021-05-07 22:18:23 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2021-05-07 22:18:23 +0200 |
commit | ea89e813f730aaf4e97ea6c2b22c6a405d34955c (patch) | |
tree | 35a3f93b0c37fc00774b29f8074c49968f9a2c1a /etc | |
parent | c3ebe7eabdbd41d496169bdcd98efff9d3f0bf87 (diff) | |
download | mpv-ea89e813f730aaf4e97ea6c2b22c6a405d34955c.tar.bz2 mpv-ea89e813f730aaf4e97ea6c2b22c6a405d34955c.tar.xz |
zsh completion: perform globbing on binary path
When trying to use completion for mpv binaries specified with some shell
glob, e.g. ~/dev/mpv/build/mpv, the current code doesn't substitute the
homedir prefix into the path name, resulting in runtime errors about
the file '~/dev/mpv/build/mpv' not being found.
The simple fixed is to use $~var instead of $var whenever expanding the
filename, which performs the same globbing that would otherwise be
performed when executing the command.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/_mpv.zsh | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/etc/_mpv.zsh b/etc/_mpv.zsh index a15bb7c9ed..d7803cedf1 100644 --- a/etc/_mpv.zsh +++ b/etc/_mpv.zsh @@ -42,7 +42,7 @@ function _mpv_generate_arguments { local -a option_aliases=() local list_options_line - for list_options_line in "${(@f)$($words[1] --list-options)}"; do + for list_options_line in "${(@f)$($~words[1] --list-options)}"; do [[ $list_options_line =~ $'^[ \t]+--([^ \t]+)[ \t]*(.*)' ]] || continue @@ -146,7 +146,7 @@ function _mpv_generate_arguments { function _mpv_generate_protocols { _mpv_completion_protocols=() local list_protos_line - for list_protos_line in "${(@f)$($words[1] --list-protocols)}"; do + for list_protos_line in "${(@f)$($~words[1] --list-protocols)}"; do if [[ $list_protos_line =~ $'^[ \t]+(.*)' ]]; then _mpv_completion_protocols+="$match[1]" fi @@ -158,7 +158,7 @@ function _mpv_generate_if_changed { # on the first run and re-generates it if the executable being completed for # is different than the one we used to generate the cached list. typeset -gA _mpv_completion_binary - local current_binary=${words[1]:c} + local current_binary=${~words[1]:c} zmodload -F zsh/stat b:zstat current_binary+=T$(zstat +mtime $current_binary) if [[ $_mpv_completion_binary[$1] != $current_binary ]]; then @@ -207,7 +207,7 @@ case $state in esac local -a values local current - for current in "${(@f)$($words[1] --${option_name}=help)}"; do + for current in "${(@f)$($~words[1] --${option_name}=help)}"; do [[ $current =~ $pattern ]] || continue; local name=${match[name_group]//:/\\:} desc=${match[desc_group]} if [[ -n $desc ]]; then |