Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Multi-word aliases?
On Tue, 04 Nov 2014 10:08:38 +0100
Dominik Vogt <vogt@xxxxxxxxxxxxxxxxxx> wrote:
> 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"
The usually way of handling this is to add a function that
interprets its arguments and can tweak them before passing
them through. The tricky bit here is that git can take
options which you need to be able to take account of, so
the obvious trivial
git() {
case $1 in
(rebase)
set -- rebase --keep-empty "${(@)argv[2,-1]}"
;;
esac
command git "$@"
}
isn't good enough. But it's a start.
I haven't tried myself, but presumably you tried
git config --global alias.rebase "rebase --keep-empty"
and that didn't work?
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author