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

[RFC PATCH 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.
---
mpc also supports explicitly prefixing the path with file:// which is
not covered here, however according to my testing this only works for
absolute paths too so there doesn't seem to be any benefit.

This implementation doesn't work with environment variables, such as
mpc add $HOME/somethi<tab>, I will appreciate tips on whether there is a
simple way to make this more robust to include situations such as this
instead of just checking for these two specific starting characters.

Thank you and kind regards,
K. B.

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

diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc
index c3f93878ca28..93100de09ca8 100644
--- a/Completion/Unix/Command/_mpc
+++ b/Completion/Unix/Command/_mpc
@@ -178,6 +178,14 @@ _mpc_helper_files() {
   fi
 }
 
+(( $+functions[_mpc_helper_all_files] )) ||
+_mpc_helper_all_files() {
+  if [[ $words[CURRENT] == [/~]* ]]; then
+	  _files
+  fi
+  _mpc_helper_files
+}
+
 (( $+functions[_mpc_helper_directories] )) ||
 _mpc_helper_directories() {
   if [[ -n $MPD_MUSIC_DIR ]]; then
@@ -204,7 +212,7 @@ _mpc_helper_outputs() {
 }
 
 _mpc_add() {
-  _mpc_helper_files
+  _mpc_helper_all_files
 }
 
 _mpc_albumart() {
-- 
2.46.0





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