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

Re: Multi-word aliases?



On Tue, Nov 4, 2014 at 11:43 AM, Dominik Vogt <vogt@xxxxxxxxxxxxxxxxxx> wrote:
> 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"
>
>> 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.

Is there a strong reason you don't want to write "git rk" or whatever
at the command line? I'm quite lazy with typing so I have a set of
aliases like git rc, git rs for --continue, --skip, and git amend for
git commit --amend.

As for the global command line regex replace, yes, you can do that if
you hook into the accept-line family of widgets but there's a huge
caveat; it will only do literal replacements (obviously), so if you
want to respect any form of quoting you'll have to reimplement the
full zsh parser in shell script which is probably not fun (eg, to
avoid replacing it in git commit -m "git rebase is very useful"). The
wrapper function Peter mentioned is a much saner alternative here :).

-- 
Mikael Magnusson



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