Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Multi-word aliases?
- X-seq: zsh-users 19332
- From: Dominik Vogt <vogt@xxxxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Multi-word aliases?
- Date: Tue, 4 Nov 2014 10:08:38 +0100
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: Zsh Users <zsh-users@xxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Reply-to: vogt@xxxxxxxxxxxxxxxxxx
Background:
-----------
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.
Question:
---------
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.
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
IBM Germany
Messages sorted by:
Reverse Date,
Date,
Thread,
Author