Imagine I have a bash script called myscript
that will only echo
it's first argument, which will be a directory name.
Example of usage:
myscript proj1
Where proj1
is a directory for example located at ~/folder1/folder2/proj1
and your current working directory is ~/
.
My question is, for this script how could I write a completion rule so that myscript [tab][tab]
would list all directories available to echo
, starting at ~/
. This means that in the first example and assuming those are the only directories at ~/
, myscript pro[tab]
would complete the expression to myscript proj1
.
Can anyone help me to achieve this?
Thanks in advance.
Best Answer
Your description seems odd: If you get just
proj1
, how do you know what its parent directory is?Anyway, to give you what you asked for:
[1]: 2 minutes, 66782 directories