Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZSH auto completion provide full path to files in a specific folder

I'm trying to write an autocomplete function for a custom executable that takes file arguments from a particular folder.

$ ./my_executable <tab> should provide the files in folder /home/me/argument_files.

I got that to work with: compdef '_files -W /home/me/argument_files' my_executable

The problem is that I need to provide the full path to the argument files to my_executable. This only provides $ /home/me/my_executable file1 as opposed to

$ /home/me/my_executable /home/me/argument_files/file1.

How do I do this?

like image 684
Sidd Avatar asked Oct 29 '25 10:10

Sidd


1 Answers

Use the compadd -P option:

compdef '_files -P /home/me/argument_files -W /home/me/argument_files' my_executable
like image 164
Ben Avatar answered Oct 31 '25 07:10

Ben



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!