Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH v2 1/2] complete absolute paths for mpc add



When connecting via Unix socket, mpc can queue files from outside the
music directory as well when given the absolute path.
---

Notes:
    v2:
    - Fix indentation.
    - Do not exit non-zero if either completion succeeds.
    - RFC v1: https://www.zsh.org/mla/workers/2024/msg00694.html

 Completion/Unix/Command/_mpc | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc
index c3f93878ca28..d1036ccfab37 100644
--- a/Completion/Unix/Command/_mpc
+++ b/Completion/Unix/Command/_mpc
@@ -178,6 +178,16 @@ _mpc_helper_files() {
   fi
 }
 
+(( $+functions[_mpc_helper_all_files] )) ||
+_mpc_helper_all_files() {
+  local ret=1
+  if [[ $words[CURRENT] == [/~]* ]]; then
+    _files
+    ret=$?
+  fi
+  _mpc_helper_files || return $ret
+}
+
 (( $+functions[_mpc_helper_directories] )) ||
 _mpc_helper_directories() {
   if [[ -n $MPD_MUSIC_DIR ]]; then
@@ -204,7 +214,7 @@ _mpc_helper_outputs() {
 }
 
 _mpc_add() {
-  _mpc_helper_files
+  _mpc_helper_all_files
 }
 
 _mpc_albumart() {
-- 
2.47.0





Messages sorted by: Reverse Date, Date, Thread, Author