2

If I put an executable in ~/bin I can just type the first few letters of the filename and then hit tab to let the shell finish the rest of the name.

While this works with executable programs, it does not seem to work with shell scripts. Is this the desired behavior, or am I doing something wrong?

4 Answers 4

4

Even scripts need the executable bit set.

3

You will probably have your script named similarly (starting) like an existing application or executable in $PATH (or, as Oli mentions, you forgot to make it executable).

Another thing is that it is bad practice to use language extensions in executables in $PATH, see this link

3

I'm using zsh for shell and after putting a script in /usr/local/bin it would not tab-complete. As hinted in another answer, I checked that the executable bit was set.

It turned out that I had to either source ~/.zshrc or restart my terminal (effectively logging me out and back in) to make my scripts tab-completable.

1
  • I have the same setup/problem (zsh, no autocomplete of script names in ~/bin/) but neither restarting the terminal nor sourcing .zshrc makes the autocomplete work for me. Any other ideas?
    – RoG
    Aug 10, 2022 at 7:54
0

Any one has the autocomplete problem with zsh when try to use the newly installed binary command in /usr/local/bin, it may caused by zsh using a autocomplete cache. use command rehash to generate a new autocomplete cache will solve the problem. It also means if you manually remove a command, you may also need to run it to update the cache.

1
  • A source of this function will add additional value to your answer. Feb 1 at 8:05

You must log in to answer this question.

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