Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Any way to have ".sh" be optional?



Hi,

2013/9/26 TJ Luoma <luomat@xxxxxxxxx>:
> The Subject line may not be the best description of what I want, but
> it was the best I could come up with.
>
> I tend to name all of my Zsh scripts to end with '.sh' so I can easily
> `fgrep -i Whatever *.sh` when I'm looking for something.
>
> However, I would rather not have to type the ".sh" if not necessary.
> (Yes, I am that lazy.)
>
> So assume I have a script "mkseries.sh" which I do not want to rename
> but which I want to use in zsh just by typing "mkseries" -- is there a
> way to tell zsh "If I use the command 'foo' and there is no 'foo' but
> there is 'foo.sh' then I want to use 'foo.sh'?

Something like

command_not_found_handler() { test -x $1.sh && $1.sh $@[2,-1] }

should do the trick.

Best regards,

-- 
Jérémie



Messages sorted by: Reverse Date, Date, Thread, Author