zsh-users
 help / color / mirror / code / Atom feed
From: "Mikael Magnusson" <mikachu@gmail.com>
To: zsh-users@sunsite.dk
Cc: zzapper <david@tvis.co.uk>
Subject: Re: Using Global aliases to make a "macro" shell
Date: Sat, 15 Jul 2006 18:05:04 +0200	[thread overview]
Message-ID: <237967ef0607150905v400bac6cl9dc9add48786074a@mail.gmail.com> (raw)
In-Reply-To: <Xns98017A3A81F80zzappergmailcom@80.91.229.5>

On 7/15/06, zzapper <david@tvis.co.uk> 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


  reply	other threads:[~2006-07-15 16:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-15 11:00 zzapper
2006-07-15 16:05 ` Mikael Magnusson [this message]
2006-07-15 16:22   ` zzapper
2006-07-15 19:46     ` Mikael Magnusson
2006-07-15 22:22       ` zzapper
2006-07-17  9:24   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=237967ef0607150905v400bac6cl9dc9add48786074a@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=david@tvis.co.uk \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).