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

Re: Using Global aliases to make a "macro" shell



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