Git aliases with arguments and fish shell
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
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?
git fish
add a comment |
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?
git fish
add a comment |
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?
git fish
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?
git fish
git fish
edited Nov 16 '18 at 15:29
CodeWizard
55.7k1270100
55.7k1270100
asked Nov 16 '18 at 15:14
Carl MitchellCarl Mitchell
163
163
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
There isn't any git current-branch
.
If you want the current branch name:
# extract the current branch name
git branch | grep * | cut -d ' ' -f2
# or
git rev-parse --abbrev-ref HEAD
# since you are already on the current branch all you need is pull & merge
# be aware that there can be conflicts
into = "!f() { git pull; git merge $B --no-edit; }; f"
If you want to pass parameter and checkout different branch you already have it in your alias
git checkout $1
Simple way to get current branch name :git rev-parse --abbrev-ref HEAD
– RomainValeri
Nov 16 '18 at 15:33
Agree as well. there are many ways of course
– CodeWizard
Nov 16 '18 at 15:34
Sorry, I wasn't clear. I've got the rest of the aliases from George Gritsouk's .gitconfig (the Human Git Aliases) so "current-branch = rev-parse --abbrev-ref HEAD" is already defined.
– Carl Mitchell
Nov 16 '18 at 16:07
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340575%2fgit-aliases-with-arguments-and-fish-shell%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
add a comment |
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.
add a comment |
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.
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.
edited Nov 17 '18 at 11:19
answered Nov 16 '18 at 15:42
fahofaho
5,8811526
5,8811526
add a comment |
add a comment |
There isn't any git current-branch
.
If you want the current branch name:
# extract the current branch name
git branch | grep * | cut -d ' ' -f2
# or
git rev-parse --abbrev-ref HEAD
# since you are already on the current branch all you need is pull & merge
# be aware that there can be conflicts
into = "!f() { git pull; git merge $B --no-edit; }; f"
If you want to pass parameter and checkout different branch you already have it in your alias
git checkout $1
Simple way to get current branch name :git rev-parse --abbrev-ref HEAD
– RomainValeri
Nov 16 '18 at 15:33
Agree as well. there are many ways of course
– CodeWizard
Nov 16 '18 at 15:34
Sorry, I wasn't clear. I've got the rest of the aliases from George Gritsouk's .gitconfig (the Human Git Aliases) so "current-branch = rev-parse --abbrev-ref HEAD" is already defined.
– Carl Mitchell
Nov 16 '18 at 16:07
add a comment |
There isn't any git current-branch
.
If you want the current branch name:
# extract the current branch name
git branch | grep * | cut -d ' ' -f2
# or
git rev-parse --abbrev-ref HEAD
# since you are already on the current branch all you need is pull & merge
# be aware that there can be conflicts
into = "!f() { git pull; git merge $B --no-edit; }; f"
If you want to pass parameter and checkout different branch you already have it in your alias
git checkout $1
Simple way to get current branch name :git rev-parse --abbrev-ref HEAD
– RomainValeri
Nov 16 '18 at 15:33
Agree as well. there are many ways of course
– CodeWizard
Nov 16 '18 at 15:34
Sorry, I wasn't clear. I've got the rest of the aliases from George Gritsouk's .gitconfig (the Human Git Aliases) so "current-branch = rev-parse --abbrev-ref HEAD" is already defined.
– Carl Mitchell
Nov 16 '18 at 16:07
add a comment |
There isn't any git current-branch
.
If you want the current branch name:
# extract the current branch name
git branch | grep * | cut -d ' ' -f2
# or
git rev-parse --abbrev-ref HEAD
# since you are already on the current branch all you need is pull & merge
# be aware that there can be conflicts
into = "!f() { git pull; git merge $B --no-edit; }; f"
If you want to pass parameter and checkout different branch you already have it in your alias
git checkout $1
There isn't any git current-branch
.
If you want the current branch name:
# extract the current branch name
git branch | grep * | cut -d ' ' -f2
# or
git rev-parse --abbrev-ref HEAD
# since you are already on the current branch all you need is pull & merge
# be aware that there can be conflicts
into = "!f() { git pull; git merge $B --no-edit; }; f"
If you want to pass parameter and checkout different branch you already have it in your alias
git checkout $1
edited Nov 16 '18 at 15:34
answered Nov 16 '18 at 15:31
CodeWizardCodeWizard
55.7k1270100
55.7k1270100
Simple way to get current branch name :git rev-parse --abbrev-ref HEAD
– RomainValeri
Nov 16 '18 at 15:33
Agree as well. there are many ways of course
– CodeWizard
Nov 16 '18 at 15:34
Sorry, I wasn't clear. I've got the rest of the aliases from George Gritsouk's .gitconfig (the Human Git Aliases) so "current-branch = rev-parse --abbrev-ref HEAD" is already defined.
– Carl Mitchell
Nov 16 '18 at 16:07
add a comment |
Simple way to get current branch name :git rev-parse --abbrev-ref HEAD
– RomainValeri
Nov 16 '18 at 15:33
Agree as well. there are many ways of course
– CodeWizard
Nov 16 '18 at 15:34
Sorry, I wasn't clear. I've got the rest of the aliases from George Gritsouk's .gitconfig (the Human Git Aliases) so "current-branch = rev-parse --abbrev-ref HEAD" is already defined.
– Carl Mitchell
Nov 16 '18 at 16:07
Simple way to get current branch name :
git rev-parse --abbrev-ref HEAD
– RomainValeri
Nov 16 '18 at 15:33
Simple way to get current branch name :
git rev-parse --abbrev-ref HEAD
– RomainValeri
Nov 16 '18 at 15:33
Agree as well. there are many ways of course
– CodeWizard
Nov 16 '18 at 15:34
Agree as well. there are many ways of course
– CodeWizard
Nov 16 '18 at 15:34
Sorry, I wasn't clear. I've got the rest of the aliases from George Gritsouk's .gitconfig (the Human Git Aliases) so "current-branch = rev-parse --abbrev-ref HEAD" is already defined.
– Carl Mitchell
Nov 16 '18 at 16:07
Sorry, I wasn't clear. I've got the rest of the aliases from George Gritsouk's .gitconfig (the Human Git Aliases) so "current-branch = rev-parse --abbrev-ref HEAD" is already defined.
– Carl Mitchell
Nov 16 '18 at 16:07
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340575%2fgit-aliases-with-arguments-and-fish-shell%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown