Zsh Mailing List Archive
Messages sorted by:
Re: Any way to have ".sh" be optional?
- X-seq: zsh-users 18007
- From: Micah Elliott <mde@xxxxxxxxxxxxxxxx>
- To: TJ Luoma <luomat@xxxxxxxxx>
- Subject: Re: Any way to have ".sh" be optional?
- Date: Thu, 26 Sep 2013 14:27:11 -0700
- Cc: Zsh-Users List <zsh-users@xxxxxxx>
- In-reply-to: <CADjGqHsrd8K=rW6dyDxwddYMu-iG6tmNMMj0HtJZ6SVQksWmCw@mail.gmail.com>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADjGqHsrd8K=rW6dyDxwddYMu-iG6tmNMMj0HtJZ6SVQksWmCw@mail.gmail.com>
On Thu, Sep 26, 2013 at 1:12 PM, TJ Luoma <luomat@xxxxxxxxx> wrote:
> 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.
Cool, I tend to use .zsh, but mostly so I know they're not system scripts.
> However, I would rather not have to type the ".sh" if not necessary. (Yes, I
> am that lazy.)
Leaving out the .«tab» saves a little bit of typing. But you might have
already fully tab-completed a couple chars in.
> 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'?
You could tie into the command_not_found_hook (briefly mentioned in
zshmisc(1)). Something like this:
print "Proxying for actual: $actual"
for p in $path; do
if [[ -x $p/$actual ]]; then
% foo aa bb
Proxying for actual: foo.sh
A couple caveats:
* I don't actually do this, but maybe I'll try; the func is not really
* zsh syntax highlighting
(https://github.com/zsh-users/zsh-syntax-highlighting) won't match foo
* running in cwd as ./foo isn't handled
* not sure if looping over path is best approach; would something with
twitter:@MicahElliott | email:mde@xxxxxxxxxxxxxxxx | http://membean.com
Remember your words with Membean!
Messages sorted by: