The Human Git aliases includes some functions which take arguments, for example
into = "!f() { B=$(git current-branch); git checkout $1; git pull; git merge $B --no-edit; }; f"
I'm having trouble getting similar things to work in fish.
I can create a fish alias, say called git-into, which works, but I'd rather have a git alias so I don't have to remember which commands use the dash and which use the space.
Using ! fish -c STUFF" or "! bash -c STUFF doesn't pass in the arguments properly.
How would I make it so that
git into repository
will do the equivalent of the above script?
Adding a leading "!" to an alias indeed means that git runs it in a shell, but that shell isn't fish here. It's the shell that was given at build time as SHELL_PATH, most likely (and defaulting to) "/bin/sh". And since git uses the same shell to run other things (e.g. the pager), it should definitely be a POSIX-compatible one, which rules out fish.
Your user's chosen login shell doesn't matter.
So you can simply use the original code and it should work.
Alternatively, you could put this into a script called git-into (no ending, proper shebang-line and executable bit) in $PATH, and git will find it when you call git into.
If you really want to use fish -c here, you'll have to deal with two slightly incompatible layers of quoting, which isn't something I'd recommend.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With