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

Multi-word aliases?


Using git, I want to automatically switch on certain command line
options for certain git subcommands.  For example, "git rebase"
should *always* be silently replaced by "git rebase --keep-empty".
git-config does not help here, because it cannot set the
--keep-empty option.

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"

Of course this can have nasty side effects, but it may be good
enough for my immediate task.


Is there a way to define "multi word" aliases, i.e. to force zsh
to look at the first <n> words for aliasing, not just at the word
in command position?  What I mean is something like this:

  alias "echo foo"="echo foo bar"
  $ echo foo
  foo bar

That would allow to solve this class of problems without help from
the application.


Dominik ^_^  ^_^


Dominik Vogt
IBM Germany

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