1

I had finessed in bash a function that changes to any directory below the current working directory by having that directory name as a parameter to the function. If there are multiple results by that name, a menu appears to allow the user to choose the intended destination. The bash code is:

function cdb() {
  select dir in $(find -type d -name "$1" -not -path '*/\.*' -prune);
  do
    cd "${dir}" && break;
  done 
}

An example it of at play would be:

android@cybaryme:~/octos$ cdb av
1) ./frameworks/av
2) ./system/bt/bta/av
#? 1
android@cybaryme:~/octos/frameworks/av$

I use fish most of the time though, and would like to have this function there as well. But for the life of me I cannot find the select command, or its equivalent. Possibly thought that "complete" would do the job, but I got confused over what it is for.

Can anyone shed light on what is available? Or maybe an example of a Perl script that can shim the missing gaps?

1 Answer 1

1

Fish does not have a select command. Nor can I find any indication that anyone has requested it be added. You can find an example of how to do the equivalent in a couple of the functions that ship with fish as well as my mcd function which will probably be added to the core package. Note that my implementation allows selecting by number or letter which is a pretty useful convenience. Feel free to open an enhancement request.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .