I'm new to zsh and one thing that I do quite often is execute shell scripts that are in a directory of mine called Scripts. I'm not always inside of the Scripts directory, however... I may be in $HOME and therefore would like to just type Sc<Tab> and have it autocomplete to Scripts/ and then be able to autocomplete which script I want to run from there, of course...

However, zsh doesn't seem to do this by default. It will only autocomplete directory names for me if I have typed ls or cd. If I'm trying to autocomplete a directory first, it just simply won't do it.

Is there a way to change this behavior?

Edit: I figured out that I could do ./Sc<Tab> and it would autocomplete for me. I guess I'm just used to not having to type out ./ before something to get it to autocomplete, so I'd still like to know if this is possible in zsh, but this is an acceptable workaround for now.

2 Answers
2

Not exactly what you asked but I use s to run scripts. So for example if I have a file ~/Scripts/run-stuff.sh I can type s run-stuff.sh and it will run the script. It will also do tab-completion of the script name. The only thing it doesn't do is handle sub-directories in the scripts directory.