chaning git checkout behaviour in zsh
I'm follwing this link on how to use git checkout auto-completion for only local branches.
I first used it on my bash shell as follows (Used this link as a reference. Also, commented out the original code):
_git_checkout ()
{
__git_has_doubledash && return
case "$cur" in
--conflict=*)
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
;;
--*)
__gitcomp "
--quiet --ours --theirs --track --no-guess --no-track --merge
--conflict= --orphan --patch
"
# __gitcomp "
# --quiet --ours --theirs --track --no-track --merge
# --conflict= --orphan --patch
# "
;;
*)
# check if --track, --no-track, or --no-guess was specified
# if so, disable DWIM mode
local flags="--track --no-track --no-guess" track=1
if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
track=''
fi
# __gitcomp_nl "$(__git_refs '' $track)"
__gitcomp_nl "$(__git_heads '' $track)"
;;
esac
}
and this works, and now I can:
- use
git checkout -- TAB
and see--no-guess
git checkout TAB
shows only local branches
However, moving to zsh, I can't make it happen. I tried copying the _git_checkout()
to a new file (~/.zsh_functions) and to modify it in the same way, and then add a source ~/.zsh_funcitons
in ~/.zshrc
and source it, but it didn't help...
The link I provided suggests editing /usr/local/share/zsh/site-functions/git-completion.bash, which I don't have...
How can I make it work oin zsh also? (more specifaclly, when _git_checkout()
is called and from where. I know I somehow need to mimic the way bash looks at a command (e.g. git checkout <TAB>
) and tries to auto-complete it, but I'm lacking something here)
Thanks!
The reason I'm asking is that zsh is realy nice in that it has an excellent menu I can go over using TAB once the git checkout
presents its output, however, in bash, I can control the output and get only the local branches, so I want the best of two worlds. If the tab-menu thingy of zsh can be imported to bash easily, I would be fine with that too :)
command-line bash git zsh auto-completion
|
show 1 more comment
I'm follwing this link on how to use git checkout auto-completion for only local branches.
I first used it on my bash shell as follows (Used this link as a reference. Also, commented out the original code):
_git_checkout ()
{
__git_has_doubledash && return
case "$cur" in
--conflict=*)
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
;;
--*)
__gitcomp "
--quiet --ours --theirs --track --no-guess --no-track --merge
--conflict= --orphan --patch
"
# __gitcomp "
# --quiet --ours --theirs --track --no-track --merge
# --conflict= --orphan --patch
# "
;;
*)
# check if --track, --no-track, or --no-guess was specified
# if so, disable DWIM mode
local flags="--track --no-track --no-guess" track=1
if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
track=''
fi
# __gitcomp_nl "$(__git_refs '' $track)"
__gitcomp_nl "$(__git_heads '' $track)"
;;
esac
}
and this works, and now I can:
- use
git checkout -- TAB
and see--no-guess
git checkout TAB
shows only local branches
However, moving to zsh, I can't make it happen. I tried copying the _git_checkout()
to a new file (~/.zsh_functions) and to modify it in the same way, and then add a source ~/.zsh_funcitons
in ~/.zshrc
and source it, but it didn't help...
The link I provided suggests editing /usr/local/share/zsh/site-functions/git-completion.bash, which I don't have...
How can I make it work oin zsh also? (more specifaclly, when _git_checkout()
is called and from where. I know I somehow need to mimic the way bash looks at a command (e.g. git checkout <TAB>
) and tries to auto-complete it, but I'm lacking something here)
Thanks!
The reason I'm asking is that zsh is realy nice in that it has an excellent menu I can go over using TAB once the git checkout
presents its output, however, in bash, I can control the output and get only the local branches, so I want the best of two worlds. If the tab-menu thingy of zsh can be imported to bash easily, I would be fine with that too :)
command-line bash git zsh auto-completion
Did you see this comment?
– wjandrea
Feb 18 at 18:01
not sure what comment you are rffering, but this is the link I said I used as reference or my bash auto-complete
– CIsForCookies
Feb 18 at 18:15
Oh, the comments don't load automatically. If you click my link then load the comments, you'll see the one I mean, copied here: Good news, it turns out there is now built-in support for ignoring remotes. You no longer have to modify the script. Put this in your ~/.bashrc:GIT_COMPLETION_CHECKOUT_NO_GUESS=1
– wjandrea
Feb 18 at 18:19
oh, yeah... saw it in another forum a few weeks ago. Didn't work for me
– CIsForCookies
Feb 18 at 18:22
So that comment mentions the .bashrc, but did you try putting it in your .zshrc instead?
– wjandrea
Feb 18 at 18:47
|
show 1 more comment
I'm follwing this link on how to use git checkout auto-completion for only local branches.
I first used it on my bash shell as follows (Used this link as a reference. Also, commented out the original code):
_git_checkout ()
{
__git_has_doubledash && return
case "$cur" in
--conflict=*)
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
;;
--*)
__gitcomp "
--quiet --ours --theirs --track --no-guess --no-track --merge
--conflict= --orphan --patch
"
# __gitcomp "
# --quiet --ours --theirs --track --no-track --merge
# --conflict= --orphan --patch
# "
;;
*)
# check if --track, --no-track, or --no-guess was specified
# if so, disable DWIM mode
local flags="--track --no-track --no-guess" track=1
if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
track=''
fi
# __gitcomp_nl "$(__git_refs '' $track)"
__gitcomp_nl "$(__git_heads '' $track)"
;;
esac
}
and this works, and now I can:
- use
git checkout -- TAB
and see--no-guess
git checkout TAB
shows only local branches
However, moving to zsh, I can't make it happen. I tried copying the _git_checkout()
to a new file (~/.zsh_functions) and to modify it in the same way, and then add a source ~/.zsh_funcitons
in ~/.zshrc
and source it, but it didn't help...
The link I provided suggests editing /usr/local/share/zsh/site-functions/git-completion.bash, which I don't have...
How can I make it work oin zsh also? (more specifaclly, when _git_checkout()
is called and from where. I know I somehow need to mimic the way bash looks at a command (e.g. git checkout <TAB>
) and tries to auto-complete it, but I'm lacking something here)
Thanks!
The reason I'm asking is that zsh is realy nice in that it has an excellent menu I can go over using TAB once the git checkout
presents its output, however, in bash, I can control the output and get only the local branches, so I want the best of two worlds. If the tab-menu thingy of zsh can be imported to bash easily, I would be fine with that too :)
command-line bash git zsh auto-completion
I'm follwing this link on how to use git checkout auto-completion for only local branches.
I first used it on my bash shell as follows (Used this link as a reference. Also, commented out the original code):
_git_checkout ()
{
__git_has_doubledash && return
case "$cur" in
--conflict=*)
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
;;
--*)
__gitcomp "
--quiet --ours --theirs --track --no-guess --no-track --merge
--conflict= --orphan --patch
"
# __gitcomp "
# --quiet --ours --theirs --track --no-track --merge
# --conflict= --orphan --patch
# "
;;
*)
# check if --track, --no-track, or --no-guess was specified
# if so, disable DWIM mode
local flags="--track --no-track --no-guess" track=1
if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
track=''
fi
# __gitcomp_nl "$(__git_refs '' $track)"
__gitcomp_nl "$(__git_heads '' $track)"
;;
esac
}
and this works, and now I can:
- use
git checkout -- TAB
and see--no-guess
git checkout TAB
shows only local branches
However, moving to zsh, I can't make it happen. I tried copying the _git_checkout()
to a new file (~/.zsh_functions) and to modify it in the same way, and then add a source ~/.zsh_funcitons
in ~/.zshrc
and source it, but it didn't help...
The link I provided suggests editing /usr/local/share/zsh/site-functions/git-completion.bash, which I don't have...
How can I make it work oin zsh also? (more specifaclly, when _git_checkout()
is called and from where. I know I somehow need to mimic the way bash looks at a command (e.g. git checkout <TAB>
) and tries to auto-complete it, but I'm lacking something here)
Thanks!
The reason I'm asking is that zsh is realy nice in that it has an excellent menu I can go over using TAB once the git checkout
presents its output, however, in bash, I can control the output and get only the local branches, so I want the best of two worlds. If the tab-menu thingy of zsh can be imported to bash easily, I would be fine with that too :)
command-line bash git zsh auto-completion
command-line bash git zsh auto-completion
edited Feb 18 at 16:25
CIsForCookies
asked Feb 18 at 16:17
CIsForCookiesCIsForCookies
24818
24818
Did you see this comment?
– wjandrea
Feb 18 at 18:01
not sure what comment you are rffering, but this is the link I said I used as reference or my bash auto-complete
– CIsForCookies
Feb 18 at 18:15
Oh, the comments don't load automatically. If you click my link then load the comments, you'll see the one I mean, copied here: Good news, it turns out there is now built-in support for ignoring remotes. You no longer have to modify the script. Put this in your ~/.bashrc:GIT_COMPLETION_CHECKOUT_NO_GUESS=1
– wjandrea
Feb 18 at 18:19
oh, yeah... saw it in another forum a few weeks ago. Didn't work for me
– CIsForCookies
Feb 18 at 18:22
So that comment mentions the .bashrc, but did you try putting it in your .zshrc instead?
– wjandrea
Feb 18 at 18:47
|
show 1 more comment
Did you see this comment?
– wjandrea
Feb 18 at 18:01
not sure what comment you are rffering, but this is the link I said I used as reference or my bash auto-complete
– CIsForCookies
Feb 18 at 18:15
Oh, the comments don't load automatically. If you click my link then load the comments, you'll see the one I mean, copied here: Good news, it turns out there is now built-in support for ignoring remotes. You no longer have to modify the script. Put this in your ~/.bashrc:GIT_COMPLETION_CHECKOUT_NO_GUESS=1
– wjandrea
Feb 18 at 18:19
oh, yeah... saw it in another forum a few weeks ago. Didn't work for me
– CIsForCookies
Feb 18 at 18:22
So that comment mentions the .bashrc, but did you try putting it in your .zshrc instead?
– wjandrea
Feb 18 at 18:47
Did you see this comment?
– wjandrea
Feb 18 at 18:01
Did you see this comment?
– wjandrea
Feb 18 at 18:01
not sure what comment you are rffering, but this is the link I said I used as reference or my bash auto-complete
– CIsForCookies
Feb 18 at 18:15
not sure what comment you are rffering, but this is the link I said I used as reference or my bash auto-complete
– CIsForCookies
Feb 18 at 18:15
Oh, the comments don't load automatically. If you click my link then load the comments, you'll see the one I mean, copied here: Good news, it turns out there is now built-in support for ignoring remotes. You no longer have to modify the script. Put this in your ~/.bashrc:
GIT_COMPLETION_CHECKOUT_NO_GUESS=1
– wjandrea
Feb 18 at 18:19
Oh, the comments don't load automatically. If you click my link then load the comments, you'll see the one I mean, copied here: Good news, it turns out there is now built-in support for ignoring remotes. You no longer have to modify the script. Put this in your ~/.bashrc:
GIT_COMPLETION_CHECKOUT_NO_GUESS=1
– wjandrea
Feb 18 at 18:19
oh, yeah... saw it in another forum a few weeks ago. Didn't work for me
– CIsForCookies
Feb 18 at 18:22
oh, yeah... saw it in another forum a few weeks ago. Didn't work for me
– CIsForCookies
Feb 18 at 18:22
So that comment mentions the .bashrc, but did you try putting it in your .zshrc instead?
– wjandrea
Feb 18 at 18:47
So that comment mentions the .bashrc, but did you try putting it in your .zshrc instead?
– wjandrea
Feb 18 at 18:47
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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%2faskubuntu.com%2fquestions%2f1119271%2fchaning-git-checkout-behaviour-in-zsh%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1119271%2fchaning-git-checkout-behaviour-in-zsh%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
Did you see this comment?
– wjandrea
Feb 18 at 18:01
not sure what comment you are rffering, but this is the link I said I used as reference or my bash auto-complete
– CIsForCookies
Feb 18 at 18:15
Oh, the comments don't load automatically. If you click my link then load the comments, you'll see the one I mean, copied here: Good news, it turns out there is now built-in support for ignoring remotes. You no longer have to modify the script. Put this in your ~/.bashrc:
GIT_COMPLETION_CHECKOUT_NO_GUESS=1
– wjandrea
Feb 18 at 18:19
oh, yeah... saw it in another forum a few weeks ago. Didn't work for me
– CIsForCookies
Feb 18 at 18:22
So that comment mentions the .bashrc, but did you try putting it in your .zshrc instead?
– wjandrea
Feb 18 at 18:47