Reputation: 626
I have a custom command that I have created. I need it to get suggestions while using it in shell. These suggestions are basically sub-directories Ys in a particular directory X. (X will be available in some global variable).
eg. op [tab] then i should get suggestions for all directories in the directory X.
Also, If i have to provide suggestions for commands. How do i do that ?
Upvotes: 0
Views: 63
Reputation: 141523
The features is called "autocomplete" (or similar) and there are many resources available on the internet on how to implement it in bash, for example this etc.
From what I get from your post, assuming your subdirectories doesn't have any spaces tabs or newlines, I think you can just:
complete -W "$(find "X" -type d -maxdepth 1 -mindepth1)" op
Upvotes: 1