Stop zsh incorporating /etc/hosts in autocompleteZSH autocomplete second argumentStrange zsh autocomplete...

Should we avoid writing fiction about historical events without extensive research?

What does it mean when I add a new variable to my linear model and the R^2 stays the same?

Can a space-faring robot still function over a billion years?

Too soon for a plot twist?

What is the oldest European royal house?

New invention compresses matter to produce energy? or other items? (Short Story)

Why do phishing e-mails use faked e-mail addresses instead of the real one?

Why would the IRS ask for birth certificates or even audit a small tax return?

Can a Mimic (container form) actually hold loot?

3.5% Interest Student Loan or use all of my savings on Tuition?

Dukha vs legitimate need

Rationale to prefer local variables over instance variables?

Sundering Titan and basic normal lands and snow lands

An Undercover Army

What can I do if someone tampers with my SSH public key?

Naming Characters after Friends/Family

The (Easy) Road to Code

Problems with rounding giving too many digits

What is Tony Stark injecting into himself in Iron Man 3?

Deal the cards to the players

Is every open circuit a capacitor?

Is there such a thing in math the inverse of a sequence?

Python 3.6+ function to ask for a multiple-choice answer

Remove object from array based on array of some property of that object



Stop zsh incorporating /etc/hosts in autocomplete


ZSH autocomplete second argumentStrange zsh autocomplete behaviourBash autocomplete like zshXCode Command-T-style autocomplete for zshzsh completion after installing/removing packageszsh autocomplete menu press enter onceHow stop zsh backspacing over trailing underscore in autocomplete filename?zsh: autocomplete relative pathsZsh / git: Tab autocomplete not working if “HEAD^” is next to last word on input rowzsh autocomplete results from function













2















I added loads of entries to my /etc/hosts file to aid in adblocking and tracking on the internet (a list I got from github https://github.com/StevenBlack/hosts).



However, zsh now incorporates all the entries in the hosts file when searching for autocompletes. This means I can be moving a simple file with a long name and I type mv w<TAB> and I get hundreds of autocomplete entries with the filename I want buried in there somewhere.



Is there a way to restrict the sources zsh uses for autocompletion?



Edit: here are what I think are the relevant parts of my zshrc:



zstyle ':completion:*' completer _complete _ignored _approximate
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' matcher-list ''
zstyle ':completion:*' menu select=1
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
autoload -Uz compinit
autoload -U zutil
autoload -U complist
compinit









share|improve this question

























  • Let me guess... you are using d'oh-my-zsh or something similar?

    – mpy
    Jul 11 '16 at 17:08











  • @mpy Nope, no zsh plugins. I can post my .zshrc if it would help.

    – thosphor
    Jul 12 '16 at 15:23











  • Yes, post your .zshrc if it's not too big. If it's more than 50 lines please try to narrow the behavior down to a specific part of it before.

    – mpy
    Jul 12 '16 at 17:08











  • @mpy Edited the question to include the relevant bits.

    – thosphor
    Jul 12 '16 at 17:27






  • 1





    Check out nion.modprobe.de/blog/archives/… for a starting point.

    – mpy
    Jul 13 '16 at 18:06
















2















I added loads of entries to my /etc/hosts file to aid in adblocking and tracking on the internet (a list I got from github https://github.com/StevenBlack/hosts).



However, zsh now incorporates all the entries in the hosts file when searching for autocompletes. This means I can be moving a simple file with a long name and I type mv w<TAB> and I get hundreds of autocomplete entries with the filename I want buried in there somewhere.



Is there a way to restrict the sources zsh uses for autocompletion?



Edit: here are what I think are the relevant parts of my zshrc:



zstyle ':completion:*' completer _complete _ignored _approximate
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' matcher-list ''
zstyle ':completion:*' menu select=1
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
autoload -Uz compinit
autoload -U zutil
autoload -U complist
compinit









share|improve this question

























  • Let me guess... you are using d'oh-my-zsh or something similar?

    – mpy
    Jul 11 '16 at 17:08











  • @mpy Nope, no zsh plugins. I can post my .zshrc if it would help.

    – thosphor
    Jul 12 '16 at 15:23











  • Yes, post your .zshrc if it's not too big. If it's more than 50 lines please try to narrow the behavior down to a specific part of it before.

    – mpy
    Jul 12 '16 at 17:08











  • @mpy Edited the question to include the relevant bits.

    – thosphor
    Jul 12 '16 at 17:27






  • 1





    Check out nion.modprobe.de/blog/archives/… for a starting point.

    – mpy
    Jul 13 '16 at 18:06














2












2








2


1






I added loads of entries to my /etc/hosts file to aid in adblocking and tracking on the internet (a list I got from github https://github.com/StevenBlack/hosts).



However, zsh now incorporates all the entries in the hosts file when searching for autocompletes. This means I can be moving a simple file with a long name and I type mv w<TAB> and I get hundreds of autocomplete entries with the filename I want buried in there somewhere.



Is there a way to restrict the sources zsh uses for autocompletion?



Edit: here are what I think are the relevant parts of my zshrc:



zstyle ':completion:*' completer _complete _ignored _approximate
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' matcher-list ''
zstyle ':completion:*' menu select=1
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
autoload -Uz compinit
autoload -U zutil
autoload -U complist
compinit









share|improve this question
















I added loads of entries to my /etc/hosts file to aid in adblocking and tracking on the internet (a list I got from github https://github.com/StevenBlack/hosts).



However, zsh now incorporates all the entries in the hosts file when searching for autocompletes. This means I can be moving a simple file with a long name and I type mv w<TAB> and I get hundreds of autocomplete entries with the filename I want buried in there somewhere.



Is there a way to restrict the sources zsh uses for autocompletion?



Edit: here are what I think are the relevant parts of my zshrc:



zstyle ':completion:*' completer _complete _ignored _approximate
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' matcher-list ''
zstyle ':completion:*' menu select=1
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
autoload -Uz compinit
autoload -U zutil
autoload -U complist
compinit






zsh autocomplete hosts-file






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 7 '16 at 7:08









DavidPostill

106k26228263




106k26228263










asked Jul 9 '16 at 13:54









thosphorthosphor

1113




1113













  • Let me guess... you are using d'oh-my-zsh or something similar?

    – mpy
    Jul 11 '16 at 17:08











  • @mpy Nope, no zsh plugins. I can post my .zshrc if it would help.

    – thosphor
    Jul 12 '16 at 15:23











  • Yes, post your .zshrc if it's not too big. If it's more than 50 lines please try to narrow the behavior down to a specific part of it before.

    – mpy
    Jul 12 '16 at 17:08











  • @mpy Edited the question to include the relevant bits.

    – thosphor
    Jul 12 '16 at 17:27






  • 1





    Check out nion.modprobe.de/blog/archives/… for a starting point.

    – mpy
    Jul 13 '16 at 18:06



















  • Let me guess... you are using d'oh-my-zsh or something similar?

    – mpy
    Jul 11 '16 at 17:08











  • @mpy Nope, no zsh plugins. I can post my .zshrc if it would help.

    – thosphor
    Jul 12 '16 at 15:23











  • Yes, post your .zshrc if it's not too big. If it's more than 50 lines please try to narrow the behavior down to a specific part of it before.

    – mpy
    Jul 12 '16 at 17:08











  • @mpy Edited the question to include the relevant bits.

    – thosphor
    Jul 12 '16 at 17:27






  • 1





    Check out nion.modprobe.de/blog/archives/… for a starting point.

    – mpy
    Jul 13 '16 at 18:06

















Let me guess... you are using d'oh-my-zsh or something similar?

– mpy
Jul 11 '16 at 17:08





Let me guess... you are using d'oh-my-zsh or something similar?

– mpy
Jul 11 '16 at 17:08













@mpy Nope, no zsh plugins. I can post my .zshrc if it would help.

– thosphor
Jul 12 '16 at 15:23





@mpy Nope, no zsh plugins. I can post my .zshrc if it would help.

– thosphor
Jul 12 '16 at 15:23













Yes, post your .zshrc if it's not too big. If it's more than 50 lines please try to narrow the behavior down to a specific part of it before.

– mpy
Jul 12 '16 at 17:08





Yes, post your .zshrc if it's not too big. If it's more than 50 lines please try to narrow the behavior down to a specific part of it before.

– mpy
Jul 12 '16 at 17:08













@mpy Edited the question to include the relevant bits.

– thosphor
Jul 12 '16 at 17:27





@mpy Edited the question to include the relevant bits.

– thosphor
Jul 12 '16 at 17:27




1




1





Check out nion.modprobe.de/blog/archives/… for a starting point.

– mpy
Jul 13 '16 at 18:06





Check out nion.modprobe.de/blog/archives/… for a starting point.

– mpy
Jul 13 '16 at 18:06










1 Answer
1






active

oldest

votes


















1














By default, zsh populates its hosts completion list from the command getent hosts if it's available, or from certain files, including /ect/hosts.



If we want to skip this part, we need to provide our own completion logic. You can do so by adding the following to your ~/.zshrc:



zstyle -e ':completion:*:hosts' hosts 'reply=(
${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//,/ }
${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#***}:#*?*}}
)'


Inspiration: Voku's solution in their dotfiles, by leaving out the /ect/hosts part.






share|improve this answer








New contributor




autra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1098829%2fstop-zsh-incorporating-etc-hosts-in-autocomplete%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    By default, zsh populates its hosts completion list from the command getent hosts if it's available, or from certain files, including /ect/hosts.



    If we want to skip this part, we need to provide our own completion logic. You can do so by adding the following to your ~/.zshrc:



    zstyle -e ':completion:*:hosts' hosts 'reply=(
    ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//,/ }
    ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#***}:#*?*}}
    )'


    Inspiration: Voku's solution in their dotfiles, by leaving out the /ect/hosts part.






    share|improve this answer








    New contributor




    autra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      1














      By default, zsh populates its hosts completion list from the command getent hosts if it's available, or from certain files, including /ect/hosts.



      If we want to skip this part, we need to provide our own completion logic. You can do so by adding the following to your ~/.zshrc:



      zstyle -e ':completion:*:hosts' hosts 'reply=(
      ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//,/ }
      ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#***}:#*?*}}
      )'


      Inspiration: Voku's solution in their dotfiles, by leaving out the /ect/hosts part.






      share|improve this answer








      New contributor




      autra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        1












        1








        1







        By default, zsh populates its hosts completion list from the command getent hosts if it's available, or from certain files, including /ect/hosts.



        If we want to skip this part, we need to provide our own completion logic. You can do so by adding the following to your ~/.zshrc:



        zstyle -e ':completion:*:hosts' hosts 'reply=(
        ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//,/ }
        ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#***}:#*?*}}
        )'


        Inspiration: Voku's solution in their dotfiles, by leaving out the /ect/hosts part.






        share|improve this answer








        New contributor




        autra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        By default, zsh populates its hosts completion list from the command getent hosts if it's available, or from certain files, including /ect/hosts.



        If we want to skip this part, we need to provide our own completion logic. You can do so by adding the following to your ~/.zshrc:



        zstyle -e ':completion:*:hosts' hosts 'reply=(
        ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//,/ }
        ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#***}:#*?*}}
        )'


        Inspiration: Voku's solution in their dotfiles, by leaving out the /ect/hosts part.







        share|improve this answer








        New contributor




        autra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        autra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 21 hours ago









        autraautra

        1113




        1113




        New contributor




        autra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        autra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        autra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • 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%2fsuperuser.com%2fquestions%2f1098829%2fstop-zsh-incorporating-etc-hosts-in-autocomplete%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

            Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

            Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...