Using zsh autocompletion for alias Announcing the arrival of Valued Associate #679: Cesar...

Can a party unilaterally change candidates in preparation for a General election?

Why are there no cargo aircraft with "flying wing" design?

What do you call a floor made of glass so you can see through the floor?

How do I stop a creek from eroding my steep embankment?

What is the longest distance a player character can jump in one leap?

Why do we bend a book to keep it straight?

For a new assistant professor in CS, how to build/manage a publication pipeline

Why wasn't DOSKEY integrated with COMMAND.COM?

2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?

What causes the direction of lightning flashes?

What is the meaning of the simile “quick as silk”?

An adverb for when you're not exaggerating

Is safe to use va_start macro with this as parameter?

Is it common practice to audition new musicians 1-2-1 before rehearsing with the entire band?

Extracting terms with certain heads in a function

What do you call the main part of a joke?

Does classifying an integer as a discrete log require it be part of a multiplicative group?

Is there a kind of relay only consumes power when switching?

Irreducible of finite Krull dimension implies quasi-compact?

Can you use the Shield Master feat to shove someone before you make an attack by using a Readied action?

Using audio cues to encourage good posture

Why are the trig functions versine, haversine, exsecant, etc, rarely used in modern mathematics?

How can I use the Python library networkx from Mathematica?

Can melee weapons be used to deliver Contact Poisons?



Using zsh autocompletion for alias



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionWhat's the intended use case for COMPLETE_ALIASES in zsh?zsh alias expansionHow do I get my shell functions to make use of existing autocompletion in zsh?How to disable autocompletion for sudo …?ZSH autocompletion gives seemingly random errors after some timeHow do I set Zsh autocompletion rules for second argument (of function) to an existing command's rules?zsh parse error after alias do=…Bash (Git) - Functions, Alias, and SH script filesCan I change how zsh autocomplete works?zsh: remove predicted textHow to use aliases with auto completion in oh-my-zsh?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







3















I have created a few aliases for git in zsh, for example gch = git checkout, grb = git rebase --committer-date-is-author-date and some more complex useful zsh functions for git commands. But how can I allow these aliases to use zsh git autocompletion?










share|improve this question




















  • 1





    What happens when you remove oh-my-zsh and instead just zsh -f and then autoload -U compinit and then compinit and then create the aliases?

    – thrig
    Jan 5 '17 at 18:36


















3















I have created a few aliases for git in zsh, for example gch = git checkout, grb = git rebase --committer-date-is-author-date and some more complex useful zsh functions for git commands. But how can I allow these aliases to use zsh git autocompletion?










share|improve this question




















  • 1





    What happens when you remove oh-my-zsh and instead just zsh -f and then autoload -U compinit and then compinit and then create the aliases?

    – thrig
    Jan 5 '17 at 18:36














3












3








3








I have created a few aliases for git in zsh, for example gch = git checkout, grb = git rebase --committer-date-is-author-date and some more complex useful zsh functions for git commands. But how can I allow these aliases to use zsh git autocompletion?










share|improve this question
















I have created a few aliases for git in zsh, for example gch = git checkout, grb = git rebase --committer-date-is-author-date and some more complex useful zsh functions for git commands. But how can I allow these aliases to use zsh git autocompletion?







zsh autocomplete alias oh-my-zsh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 '18 at 15:45









Michael Mrozek

62.5k29194214




62.5k29194214










asked Jan 5 '17 at 17:49









Patrick ArtounianPatrick Artounian

163




163








  • 1





    What happens when you remove oh-my-zsh and instead just zsh -f and then autoload -U compinit and then compinit and then create the aliases?

    – thrig
    Jan 5 '17 at 18:36














  • 1





    What happens when you remove oh-my-zsh and instead just zsh -f and then autoload -U compinit and then compinit and then create the aliases?

    – thrig
    Jan 5 '17 at 18:36








1




1





What happens when you remove oh-my-zsh and instead just zsh -f and then autoload -U compinit and then compinit and then create the aliases?

– thrig
Jan 5 '17 at 18:36





What happens when you remove oh-my-zsh and instead just zsh -f and then autoload -U compinit and then compinit and then create the aliases?

– thrig
Jan 5 '17 at 18:36










2 Answers
2






active

oldest

votes


















1














If you open the file which contains the autoloaded function defintion for git completion:

On my ubuntu system, its:



/usr/share/zsh/functions/Completion/Unix/_git


at the top of the file you will see the #compdef declaration



#compdef git git-cvsserver git-receive-pack git-upload-archive git-upload-pack git-shell gitk tig


you can try adding your aliases to the #compdef definition, e.g.



#compdef git git-cvsserver git-receive-pack [...] tig gch grb
^^^ ^^^


Then starting a new shell to get that new directive loaded.

Then try invoking completion.



What is /usr/share/zsh/functions/Completion/Unix/_git?



Its the file that contains the autoloaded "function" defining the completion behaviour for the all the commands defined in the #compdef directive, in this case the git family of commands, it lives in fpath and is autoloaded by compinit when the completion system is initialized.



What is #compdef ?



from man zshcompsys




#compdef name ... [ -{p|P} pattern ... [ -N name ... ] ]

The file will be made autoloadable and the function defined in it
will be called when completing names, each of which is either the
name of a command whose arguments are to be completed or one of a
number of special contexts in the form -context- described below.







share|improve this answer


























  • Is there a nicer way to make this happen so it can fit into my dotfiles?

    – Patrick Artounian
    Jan 8 '17 at 21:24











  • yes there are other ways to script this out but did this work for you? I guess there is no point bothering with improving on this solution if it fundamentally didnt work in the first place.

    – the_velour_fog
    Jan 8 '17 at 21:27











  • Just tried it and no dice. I apologize for rushing into things.

    – Patrick Artounian
    Jan 8 '17 at 21:50













  • @patrick oh ok sorry. it works for me with functions, however I dont use aliases anymore so I couldnt test on my system

    – the_velour_fog
    Jan 8 '17 at 21:54





















0














I've done something very similar. Are you using oh-my-zsh? If so, make sure you've enabled the zsh-completions plugin in your .zshrc file. I'd also recommend the zsh-autosuggestions plugin.



Once you've done that, you'll need to add the following to your .zshrc file (if it's not already there)



fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinit





share|improve this answer


























  • Yes, I am oh-my-zsh and I also already have that in the zshrc.

    – Patrick Artounian
    Jan 8 '17 at 21:21














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f335145%2fusing-zsh-autocompletion-for-alias%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









1














If you open the file which contains the autoloaded function defintion for git completion:

On my ubuntu system, its:



/usr/share/zsh/functions/Completion/Unix/_git


at the top of the file you will see the #compdef declaration



#compdef git git-cvsserver git-receive-pack git-upload-archive git-upload-pack git-shell gitk tig


you can try adding your aliases to the #compdef definition, e.g.



#compdef git git-cvsserver git-receive-pack [...] tig gch grb
^^^ ^^^


Then starting a new shell to get that new directive loaded.

Then try invoking completion.



What is /usr/share/zsh/functions/Completion/Unix/_git?



Its the file that contains the autoloaded "function" defining the completion behaviour for the all the commands defined in the #compdef directive, in this case the git family of commands, it lives in fpath and is autoloaded by compinit when the completion system is initialized.



What is #compdef ?



from man zshcompsys




#compdef name ... [ -{p|P} pattern ... [ -N name ... ] ]

The file will be made autoloadable and the function defined in it
will be called when completing names, each of which is either the
name of a command whose arguments are to be completed or one of a
number of special contexts in the form -context- described below.







share|improve this answer


























  • Is there a nicer way to make this happen so it can fit into my dotfiles?

    – Patrick Artounian
    Jan 8 '17 at 21:24











  • yes there are other ways to script this out but did this work for you? I guess there is no point bothering with improving on this solution if it fundamentally didnt work in the first place.

    – the_velour_fog
    Jan 8 '17 at 21:27











  • Just tried it and no dice. I apologize for rushing into things.

    – Patrick Artounian
    Jan 8 '17 at 21:50













  • @patrick oh ok sorry. it works for me with functions, however I dont use aliases anymore so I couldnt test on my system

    – the_velour_fog
    Jan 8 '17 at 21:54


















1














If you open the file which contains the autoloaded function defintion for git completion:

On my ubuntu system, its:



/usr/share/zsh/functions/Completion/Unix/_git


at the top of the file you will see the #compdef declaration



#compdef git git-cvsserver git-receive-pack git-upload-archive git-upload-pack git-shell gitk tig


you can try adding your aliases to the #compdef definition, e.g.



#compdef git git-cvsserver git-receive-pack [...] tig gch grb
^^^ ^^^


Then starting a new shell to get that new directive loaded.

Then try invoking completion.



What is /usr/share/zsh/functions/Completion/Unix/_git?



Its the file that contains the autoloaded "function" defining the completion behaviour for the all the commands defined in the #compdef directive, in this case the git family of commands, it lives in fpath and is autoloaded by compinit when the completion system is initialized.



What is #compdef ?



from man zshcompsys




#compdef name ... [ -{p|P} pattern ... [ -N name ... ] ]

The file will be made autoloadable and the function defined in it
will be called when completing names, each of which is either the
name of a command whose arguments are to be completed or one of a
number of special contexts in the form -context- described below.







share|improve this answer


























  • Is there a nicer way to make this happen so it can fit into my dotfiles?

    – Patrick Artounian
    Jan 8 '17 at 21:24











  • yes there are other ways to script this out but did this work for you? I guess there is no point bothering with improving on this solution if it fundamentally didnt work in the first place.

    – the_velour_fog
    Jan 8 '17 at 21:27











  • Just tried it and no dice. I apologize for rushing into things.

    – Patrick Artounian
    Jan 8 '17 at 21:50













  • @patrick oh ok sorry. it works for me with functions, however I dont use aliases anymore so I couldnt test on my system

    – the_velour_fog
    Jan 8 '17 at 21:54
















1












1








1







If you open the file which contains the autoloaded function defintion for git completion:

On my ubuntu system, its:



/usr/share/zsh/functions/Completion/Unix/_git


at the top of the file you will see the #compdef declaration



#compdef git git-cvsserver git-receive-pack git-upload-archive git-upload-pack git-shell gitk tig


you can try adding your aliases to the #compdef definition, e.g.



#compdef git git-cvsserver git-receive-pack [...] tig gch grb
^^^ ^^^


Then starting a new shell to get that new directive loaded.

Then try invoking completion.



What is /usr/share/zsh/functions/Completion/Unix/_git?



Its the file that contains the autoloaded "function" defining the completion behaviour for the all the commands defined in the #compdef directive, in this case the git family of commands, it lives in fpath and is autoloaded by compinit when the completion system is initialized.



What is #compdef ?



from man zshcompsys




#compdef name ... [ -{p|P} pattern ... [ -N name ... ] ]

The file will be made autoloadable and the function defined in it
will be called when completing names, each of which is either the
name of a command whose arguments are to be completed or one of a
number of special contexts in the form -context- described below.







share|improve this answer















If you open the file which contains the autoloaded function defintion for git completion:

On my ubuntu system, its:



/usr/share/zsh/functions/Completion/Unix/_git


at the top of the file you will see the #compdef declaration



#compdef git git-cvsserver git-receive-pack git-upload-archive git-upload-pack git-shell gitk tig


you can try adding your aliases to the #compdef definition, e.g.



#compdef git git-cvsserver git-receive-pack [...] tig gch grb
^^^ ^^^


Then starting a new shell to get that new directive loaded.

Then try invoking completion.



What is /usr/share/zsh/functions/Completion/Unix/_git?



Its the file that contains the autoloaded "function" defining the completion behaviour for the all the commands defined in the #compdef directive, in this case the git family of commands, it lives in fpath and is autoloaded by compinit when the completion system is initialized.



What is #compdef ?



from man zshcompsys




#compdef name ... [ -{p|P} pattern ... [ -N name ... ] ]

The file will be made autoloadable and the function defined in it
will be called when completing names, each of which is either the
name of a command whose arguments are to be completed or one of a
number of special contexts in the form -context- described below.








share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 5 '17 at 21:19

























answered Jan 5 '17 at 21:13









the_velour_fogthe_velour_fog

5,47753467




5,47753467













  • Is there a nicer way to make this happen so it can fit into my dotfiles?

    – Patrick Artounian
    Jan 8 '17 at 21:24











  • yes there are other ways to script this out but did this work for you? I guess there is no point bothering with improving on this solution if it fundamentally didnt work in the first place.

    – the_velour_fog
    Jan 8 '17 at 21:27











  • Just tried it and no dice. I apologize for rushing into things.

    – Patrick Artounian
    Jan 8 '17 at 21:50













  • @patrick oh ok sorry. it works for me with functions, however I dont use aliases anymore so I couldnt test on my system

    – the_velour_fog
    Jan 8 '17 at 21:54





















  • Is there a nicer way to make this happen so it can fit into my dotfiles?

    – Patrick Artounian
    Jan 8 '17 at 21:24











  • yes there are other ways to script this out but did this work for you? I guess there is no point bothering with improving on this solution if it fundamentally didnt work in the first place.

    – the_velour_fog
    Jan 8 '17 at 21:27











  • Just tried it and no dice. I apologize for rushing into things.

    – Patrick Artounian
    Jan 8 '17 at 21:50













  • @patrick oh ok sorry. it works for me with functions, however I dont use aliases anymore so I couldnt test on my system

    – the_velour_fog
    Jan 8 '17 at 21:54



















Is there a nicer way to make this happen so it can fit into my dotfiles?

– Patrick Artounian
Jan 8 '17 at 21:24





Is there a nicer way to make this happen so it can fit into my dotfiles?

– Patrick Artounian
Jan 8 '17 at 21:24













yes there are other ways to script this out but did this work for you? I guess there is no point bothering with improving on this solution if it fundamentally didnt work in the first place.

– the_velour_fog
Jan 8 '17 at 21:27





yes there are other ways to script this out but did this work for you? I guess there is no point bothering with improving on this solution if it fundamentally didnt work in the first place.

– the_velour_fog
Jan 8 '17 at 21:27













Just tried it and no dice. I apologize for rushing into things.

– Patrick Artounian
Jan 8 '17 at 21:50







Just tried it and no dice. I apologize for rushing into things.

– Patrick Artounian
Jan 8 '17 at 21:50















@patrick oh ok sorry. it works for me with functions, however I dont use aliases anymore so I couldnt test on my system

– the_velour_fog
Jan 8 '17 at 21:54







@patrick oh ok sorry. it works for me with functions, however I dont use aliases anymore so I couldnt test on my system

– the_velour_fog
Jan 8 '17 at 21:54















0














I've done something very similar. Are you using oh-my-zsh? If so, make sure you've enabled the zsh-completions plugin in your .zshrc file. I'd also recommend the zsh-autosuggestions plugin.



Once you've done that, you'll need to add the following to your .zshrc file (if it's not already there)



fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinit





share|improve this answer


























  • Yes, I am oh-my-zsh and I also already have that in the zshrc.

    – Patrick Artounian
    Jan 8 '17 at 21:21


















0














I've done something very similar. Are you using oh-my-zsh? If so, make sure you've enabled the zsh-completions plugin in your .zshrc file. I'd also recommend the zsh-autosuggestions plugin.



Once you've done that, you'll need to add the following to your .zshrc file (if it's not already there)



fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinit





share|improve this answer


























  • Yes, I am oh-my-zsh and I also already have that in the zshrc.

    – Patrick Artounian
    Jan 8 '17 at 21:21
















0












0








0







I've done something very similar. Are you using oh-my-zsh? If so, make sure you've enabled the zsh-completions plugin in your .zshrc file. I'd also recommend the zsh-autosuggestions plugin.



Once you've done that, you'll need to add the following to your .zshrc file (if it's not already there)



fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinit





share|improve this answer















I've done something very similar. Are you using oh-my-zsh? If so, make sure you've enabled the zsh-completions plugin in your .zshrc file. I'd also recommend the zsh-autosuggestions plugin.



Once you've done that, you'll need to add the following to your .zshrc file (if it's not already there)



fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinit






share|improve this answer














share|improve this answer



share|improve this answer








edited 7 hours ago









Rui F Ribeiro

42.1k1484142




42.1k1484142










answered Jan 5 '17 at 19:20









Brian TullyBrian Tully

11




11













  • Yes, I am oh-my-zsh and I also already have that in the zshrc.

    – Patrick Artounian
    Jan 8 '17 at 21:21





















  • Yes, I am oh-my-zsh and I also already have that in the zshrc.

    – Patrick Artounian
    Jan 8 '17 at 21:21



















Yes, I am oh-my-zsh and I also already have that in the zshrc.

– Patrick Artounian
Jan 8 '17 at 21:21







Yes, I am oh-my-zsh and I also already have that in the zshrc.

– Patrick Artounian
Jan 8 '17 at 21:21




















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f335145%2fusing-zsh-autocompletion-for-alias%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...