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

Re: !!:$



On Tue, 16 Nov 2004, keef wrote:

> something to the effect of:
> alias ch="chmod 755 !!:$"

This is what the "fc" command is for, by the way.

  fcch() {
    emulate -L zsh
    # We're passed a file name, so:
    # - read it
    # - split it into shell words
    # - and grab the last one
    local w=${${(z)"$(<$1)"}[-1]}
    # Write back the edited command
    print "chmod 755 ${(qq)w}" >| $1
  }
  alias ch='fc -e fcch'


With that, you can even do e.g.

  ch -3

to chmod the last argument from the third command back instead of the 
immediately preceding command.



Messages sorted by: Reverse Date, Date, Thread, Author