summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2023-09-02 16:00:34 -0700
committerNiklas Haas <github-daiK1o@haasn.dev>2023-09-03 13:44:31 +0200
commita1c8bb2257c40bf2c69daea26cc6b10fde1a258d (patch)
tree9b25464b12aa049e37b2c63b4b75a6c22d2d7f78 /etc
parentf3df6f53bafd8eab864153290655dce102158aad (diff)
downloadmpv-a1c8bb2257c40bf2c69daea26cc6b10fde1a258d.tar.bz2
mpv-a1c8bb2257c40bf2c69daea26cc6b10fde1a258d.tar.xz
{zsh,bash}-completion: use config when autocompleting profiles
We were over-enthusiastic when introducing --no-config into the autocompletions. When autocompleting profiles, you actually need the config, because that's where the profiles come from. zsh is untested - I don't use it.
Diffstat (limited to 'etc')
-rw-r--r--etc/_mpv.zsh5
-rw-r--r--etc/mpv.bash-completion10
2 files changed, 12 insertions, 3 deletions
diff --git a/etc/_mpv.zsh b/etc/_mpv.zsh
index 400e34a0f6..5c2bbf97d6 100644
--- a/etc/_mpv.zsh
+++ b/etc/_mpv.zsh
@@ -192,6 +192,7 @@ case $state in
parse-help-*)
local option_name=${state#parse-help-}
+ local no_config="--no-config"
# Can't do non-capturing groups without pcre, so we index the ones we want
local pattern name_group=1 desc_group=2
case $option_name in
@@ -203,6 +204,8 @@ case $state in
# but would break if a profile name contained spaces. This stricter one
# only breaks if a profile name contains tabs.
pattern=$'^\t([^\t]*)\t(.*)'
+ # We actually want config so we can autocomplete the user's profiles
+ no_config=""
;;
*)
pattern=$'^[ \t]+(--'${option_name}$'=)?([^ \t]+)[ \t]*[-:]?[ \t]*(.*)'
@@ -211,7 +214,7 @@ case $state in
esac
local -a values
local current
- for current in "${(@f)$($~words[1] --no-config --${option_name}=help)}"; do
+ for current in "${(@f)$($~words[1] ${no_config} --${option_name}=help)}"; do
[[ $current =~ $pattern ]] || continue;
local name=${match[name_group]//:/\\:} desc=${match[desc_group]}
if [[ -n $desc ]]; then
diff --git a/etc/mpv.bash-completion b/etc/mpv.bash-completion
index 55eed77ce1..d5d504acf9 100644
--- a/etc/mpv.bash-completion
+++ b/etc/mpv.bash-completion
@@ -26,8 +26,10 @@ _mpv_get_args()
local partial="$2"
local type=$(echo "$doc" | awk '{print $2;}')
+ # We special-case profiles to ensure we read the config
if [ "$1" = "--show-profile" ]; then
- # This is a special case
+ type="ShowProfile"
+ elif [ "$1" = "--profile" ]; then
type="Profile"
fi
@@ -59,7 +61,11 @@ _mpv_get_args()
candidates+=("help")
;;
Profile)
- candidates=($(mpv --no-config $1= | grep -v ':' | awk '{print $1;}'))
+ candidates=($(mpv $1=help | grep -v ':' | awk '{print $1;}'))
+ candidates+=("help")
+ ;;
+ ShowProfile)
+ candidates=($(mpv $1= | grep -v ':' | awk '{print $1;}'))
;;
*)
# There are other categories; some of which we could do something smarter