Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using the zsh shell on ArchLinux and I want to know if there's an easy way to make "advanced" aliases.

Normal aliases work just fine. However I can't find a way to create an alias for a substitution like:

git clone git@home:some-repo.git

to

git clone git@192.168.2.2:repositories/some-repo.git

Is there any simple way at all to do this directly in zsh with alias (or something similar)? Of course it should be generic so I don't need and alias for every git action on every repository.

Thanks in advande!

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

In this particular case, you can do it through git rather than through zsh. Add the following to your ~/.gitconfig:

[url "git@192.168.2.2:repositories/"]
    insteadOf = "home:"

Now git clone home:some-repo.git (and other git commands) will use the correct repo.

In the more general case, if you want to do a command substitution that's more advanced than what an alias allows, look at shell functions.

share|improve this answer
    
Great answer, thanks :) –  0x6d48 May 4 '12 at 9:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.