completions/mpc: conditionally enable file completion for add and insert

When connecting to MPD via a Unix socket, mpc add and insert accept
absolute paths to local files. Offer these in the completion if the
completed token starts with a slash after expansion.
This commit is contained in:
Karel Balej
2025-09-18 09:02:37 +02:00
committed by Johannes Altmanninger
parent 5ece9bec6c
commit 67a9d08778

View File

@@ -85,6 +85,7 @@ complete -c mpc -n "not __fish_seen_subcommand_from $subcommands" -a current -d
# Using '(mpc search filename (commandline -ct))' _might_ be faster for larger libraries
complete -c mpc -n "__fish_seen_subcommand_from add insert" -a "(mpc listall)"
complete -c mpc -n "__fish_seen_subcommand_from add insert" -n 'string match -qr -- ^/ "$(commandline -xt)"' -F
complete -c mpc -n "__fish_seen_subcommand_from playlist load" -a "(mpc lsplaylists)"
complete -c mpc -n "__fish_seen_subcommand_from consume random repeat single" -a "on off"