Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have noticed that unless I add an .sh extension to my shell scripts, Zsh does not suggest them for autocompletion for execution despite having them in my PATH. I have the same problem if I cd into the directory and start typing the filename.

When I say for execution I mean typing the file directly on the prompt, i.e.:

$ my_shell_script

Are there any options in Zsh that control which file extensions are considered for this type of autocompletion?

share|improve this question
up vote 4 down vote accepted

Have your shell scripts start with the appropriate shebang (#!) and with the execution permission bits on. zsh will then recognize them as proper executable files.

(With some configurations, you might have to refresh zsh paths cache. Restarting it with exec zsh is one way to do it.)

share|improve this answer
rehash is a Zsh builtin which does exactly that. – Mischa Arefiev Feb 16 '12 at 9:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.