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

Re: Multi-word aliases?

On Tue, Nov 04, 2014 at 09:56:50AM +0000, Peter Stephenson wrote:
> > Now, the shell already has an aliasing mechanism.  For "normal"
> > commands it would be just somethins like "alias ls='ls -F'" For
> > now I've settled with a suboptimal approach using alises:
> > 
> >   # force treating the second argument like a command
> >   alias git="git "
> >   # aliasing rule for the first argument of git commands
> >   alias rebase="rebase --keep-empty"
> The usually way of handling this is to add a function that
> interprets its arguments and can tweak them before passing
> them through.

Yes, I considered this too.  But to get it right it's a lot of
work, which seems to be silly for such a "small" problem.  And
then, if I don't do it right, using the alias approach above is
much simpler and not much worse.  :-/

Just to better understand the situation, is there any technical
reason to limit the scope of aliases to the first word of the
command line?  After all, zsh already has to look everywhere for
global aliases.

Btw., there's no simple way to do regexp search and replace on
command lines like

  s/^(git\w.*\wrebase\w)(.*)/\1 --keep-empty\2/

or is there? (\w is an ad-hoc expression for a token boundary)

> I haven't tried myself, but presumably you tried
>    git config --global alias.rebase "rebase --keep-empty"

According to the man page, you can only define new aliases, not
overwrite subcommands.

  $ man git-config
  To avoid confusion and troubles with script usage, aliases that
  hide existing git commands are ignored.


Dominik ^_^  ^_^


Dominik Vogt
IBM Germany

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