Create Fish alias for 'git add remote...' Create Fish alias for 'git add remote...' heroku heroku

Create Fish alias for 'git add remote...'


When you use alias, Fish just appends your ARGV to the end of the command. Try aliasing something to echo to see:

alias herokuadd "echo git@heroku.com:$argv.git"herokuadd foo# git@heroku.com:.git foo

If you write a function instead, you can inline $argv[1]:

function herokuadd  echo git@heroku.com:$argv[1].gitendherokuadd foo# git@heroku.com:foo.git


git config --global alias.herokuadd '!herokuadd() { git remote add heroku git@heroku.com:$1.git; }; herokuadd'

should be what you are after.


Git aliases can get parameters from the command line

Here is a sample im using:

[alias]    ra = "!f() { git remote add $1 https://bitbucket.org/$2.git; }; f"

You can always add more command separated with the ; or with && to execute several command if you wish to add remote and pull on the same time.

Another option is to use script with the git alias.
Here is an example on how to execute script:

[alias]    l = "!bash -c 'source ~/.githelpers && pretty_git_log'"

In your case since you are using fish you can set the ur hardcoded (to be the same on all your machines) and simply use git alias without any parameters.

[alias]    set_remote = "git remote add <name> <url>"