From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6235 invoked by alias); 26 Sep 2013 23:18:32 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18007 Received: (qmail 15383 invoked from network); 26 Sep 2013 23:18:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at micahelliott.com does not designate permitted sender hosts) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=gfNxBMYwomip7M4K87pxCM3QQ5l6W6wgeUrW/X8+Uzw=; b=fAWPCZ+oQ7ukk0MtkwWJQEGKH6v+HSaVUXMWhmsQ6jKZPebnkKaHOB+VRkYjjZQ6Yg ZjDgsHdakLGXdhAEfzNfpE6aCz6F1eX6UTepWiwdSzs6ZK5J5F//qakhfEllPrE7JmgZ hRx4JQlU3D7U4KM+ljS7l0C/ksuQHoNoz5uSiWleY1qQta49kWVM3viJXVvWfnOgpGSu 4fFVYZ8gowKWOlgQbMNLD/B64R+tntNNpsEvFfF2fET9+LEJaCnghIrwMW0/1HRuohOj Yl1VR+h/pmUojUmCpj7NCoAAosqKsAYiyOI1Dh644zF1kUlAjtrJ+zMiqBz61vlHk4B9 WgPA== X-Gm-Message-State: ALoCoQl2YAsf5ru5OkitZoI2q0q3u9SWKG6DpDBBy/ItSaucxbCduuXEF9fD3bnDeCVqCQ2mSkxm X-Received: by 10.180.208.45 with SMTP id mb13mr2532697wic.27.1380230872302; Thu, 26 Sep 2013 14:27:52 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Micah Elliott Date: Thu, 26 Sep 2013 14:27:11 -0700 Message-ID: Subject: Re: Any way to have ".sh" be optional? To: TJ Luoma Cc: Zsh-Users List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Thu, Sep 26, 2013 at 1:12 PM, TJ Luoma 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 .=ABtab=BB 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 'f= oo' > 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: command_not_found_handler() { actual=3D$@[1].sh print "Proxying for actual: $actual" for p in $path; do if [[ -x $p/$actual ]]; then $actual $@[2,-1] break fi done } Then use: % 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 tested * 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 hash work? -- twitter:@MicahElliott | email:mde@MicahElliott.com | http://membean.com Remember your words with Membean!