Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Using Global aliases to make a "macro" shell
- X-seq: zsh-users 10517
- From: "Mikael Magnusson" <mikachu@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Using Global aliases to make a "macro" shell
- Date: Sat, 15 Jul 2006 18:05:04 +0200
- Cc: zzapper <david@xxxxxxxxxx>
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=pE9YTBJeM2XVqY2jZo4CS2zqLyPHBwwlCaY0Nx95mK+Qv+6cI7qF1NMC/AFxJOIQ9E2Uc+RJZM1uIaQyFadl7U1ZUWUwmkfp4Cri8t4ZUEhsKn4SeYi2FECb8SMm37zcCew5V1iwkKw0aK4aPdiYMM12nXgwHXgBZVSk2yHL/fU=
- In-reply-to: <Xns98017A3A81F80zzappergmailcom@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns98017A3A81F80zzappergmailcom@xxxxxxxxxxx>
On 7/15/06, zzapper <david@xxxxxxxxxx> wrote:
Using Global aliases to make a "macro" shell
It took me a while to suss these
example:
> cp NF ND
Where NF means Newest File in directory and
ND is newsest directory
NF and ND are actually Global Aliases
alias -g ND='$(ls -d *(/om[1]))' # newset directory
alias -g NF='$(ls *(.om[1]))' # newest file
Using these "primitives" ie NF,ND and others has saved me writing lots of
repetive shell scripts.
A related very useful keybind is
bindkey "^N" _most_recent_file
although it completes files and directories alike, despite the name.
Also very useful is
bindkey "^[^N" _most_accessed_file
Just copy _most_recent_file and apply
17c17
< eval "file=($PREFIX*$SUFFIX(om[${NUMERIC:-1}]N))"
---
eval "file=($PREFIX*$SUFFIX(oa[${NUMERIC:-1}]N))"
21c21
< eval "file=($PREFIX*$SUFFIX(om[${NUMERIC:-1}]N))"
---
eval "file=($PREFIX*$SUFFIX(oa[${NUMERIC:-1}]N))"
PS why the ls invocations? this seems to work just as well
alias -g NF='*(.om[1])'
alias -g ND='*(/om[1])'
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author