From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6570 invoked by alias); 29 Mar 2012 21:14:25 -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: 16934 Received: (qmail 15951 invoked from network); 29 Mar 2012 21:14:24 -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=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.160.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=yiI/92EsLn0eWhWqyHrRQ8aICo5R3tQFKbhGSrYU3Cg=; b=mEaDiUkCdTUXrSLYOGbnp6M9HurDmum7xWpSGXL/Bidfs1v7vnut+vzh5FrhrrXMjf Cn7b7arGjxr4ZSxS8GiCi2yHwl21gbk1NCmScI/xNQN20kIPIiaAZV2kU1IxRrVVhs2I pYvgGyC49ltfwYu9fGltni9xj5491K8CHiukvi2+48bGhpmBDWg/Kl8MCrxhAhfuC6vf tp/zuJwvJc7Uyh/DKZ2IDOWoLc8XRpT+BbrxmPrlOEoMHEnnfjX94K47wGpyL5ptxtrt q7bjElxmdjEWg2W4hSuBiofl+IPrk2Ie04dAw5bEQADoi3byr1ay9ORD4oa/8IO1Kk/O FN3w== MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 29 Mar 2012 23:07:11 +0200 Message-ID: Subject: Re: Automatically run ls on blank line for faster navigation From: Mikael Magnusson To: Mitchell Burdette Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 On 29 March 2012 22:55, Mitchell Burdette wrote: > I rigged up a function that makes navigation super fast in zsh. If you > hit enter on a blank line, it runs ls automatically. > > Just add the following to your .zshrc: > auto-ls () { > if [[ $#BUFFER -eq 0 ]]; then > echo "" > ls > zle redisplay > else > zle accept-line > fi > } > zle -N auto-ls > bindkey '^M' auto-ls > > To get the ^M correct in vim, hit . You could really > make this run whatever you want, on any key you want, but I like this > shortcut in particular (It goes great with autocd!). A (slightly) more generic way to do it would be auto-ls () { if [[ $#BUFFER -eq 0 ]]; then echo "" ls zle redisplay else zle .$WIDGET fi } zle -N accept-line auto-ls zle -N other-widget auto-ls This uses the same function to wrap any widget, ie you might want it on accept-and-hold and accept-line-and-down-history as well, or something. Maybe not. Note that the . in .$WIDGET is important, or it will call the wrapper recursively, .foo always calls the builtin widget ignoring any custom widgets by the same name. (And $WIDGET is obviously the name of the widget that caused the function to be called). -- Mikael Magnusson