From 9d144e57b60ef4ca543d5b8dd1550d96aa520c59 Mon Sep 17 00:00:00 2001 From: shbernal Date: Mon, 12 Oct 2026 19:18:40 +0200 Subject: [PATCH] bash-completion: complete aliases and list actions like their target Options like --sub-file are aliases for list actions like --sub-files-append, which --list-options shows without a type, so nothing was completed after them. Follow aliases to their target, and complete typeless list actions like the list option they act on. This makes --sub-file=, --audio-file=, --glsl-shader=, --script= etc. complete files, --sub-files-append= etc. complete files when typed directly, and other aliases like --fs= and --audio= complete the values of their target. Fixes #7955. --- etc/mpv.bash-completion | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/etc/mpv.bash-completion b/etc/mpv.bash-completion index 4fcd3b1b6f..398d332eea 100644 --- a/etc/mpv.bash-completion +++ b/etc/mpv.bash-completion @@ -29,6 +29,22 @@ _mpv_get_args() local partial="$2" local type=$(echo "$doc" | awk '{print $2;}') + # Complete aliases like their target (e.g. --sub-file -> --sub-files-append) + local opt="$1" + if [ "$type" = "alias" ]; then + opt=--$(echo "$doc" | awk '{sub(/^--/, "", $4); print $4;}') + doc=$(_mpv_options | grep -E "^\\s*$opt\\s") + type=$(echo "$doc" | awk '{print $2;}') + fi + # List actions are listed without a type; complete them like the list option + if [ -z "$type" ]; then + local list=$(echo "$opt" | sed -E 's/-(add|append|del|pre|remove|set|toggle)$//') + if [ "$list" != "$opt" ]; then + doc=$(_mpv_options | grep -E "^\\s*$list\\s") + type=$(echo "$doc" | awk '{print $2;}') + fi + fi + # We special-case profiles to ensure we read the config if [ "$1" = "--show-profile" ]; then type="ShowProfile"