Why is bash completion being loaded so slow on OS X?











up vote
12
down vote

favorite
8












I don't understand why bash completion is loaded so slow on my MacBook Pro.



I did the following in my ~/.bash_profile:



echo "Loading BashCompletion..."
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
echo "BashCompletion loaded."


the execution time for bash_completion typically is > 2 seconds.



I find that really annoying when I am working on the terminal which requires me to constantly open new tabs.



Is there a way I can cache this or something?



(Note I am using iTerm2 and this is equally slow on the original terminal in Mac as well).










share|improve this question
























  • That should not be happening. Am I correct you use MacPort's bash completion?
    – slhck
    Jul 15 '11 at 20:27










  • What does that file you load look like?
    – Daniel Beck
    Jul 15 '11 at 20:48










  • @slhck: Yes I am indeed using macport's bash completion
    – disappearedng
    Jul 15 '11 at 21:17












  • @Daniel: Everything is fine except for this. I profiled almost every line.
    – disappearedng
    Jul 15 '11 at 21:17








  • 5




    I experience the same slowness and I'm using Homebrew.
    – Brice
    Jan 30 '12 at 11:52















up vote
12
down vote

favorite
8












I don't understand why bash completion is loaded so slow on my MacBook Pro.



I did the following in my ~/.bash_profile:



echo "Loading BashCompletion..."
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
echo "BashCompletion loaded."


the execution time for bash_completion typically is > 2 seconds.



I find that really annoying when I am working on the terminal which requires me to constantly open new tabs.



Is there a way I can cache this or something?



(Note I am using iTerm2 and this is equally slow on the original terminal in Mac as well).










share|improve this question
























  • That should not be happening. Am I correct you use MacPort's bash completion?
    – slhck
    Jul 15 '11 at 20:27










  • What does that file you load look like?
    – Daniel Beck
    Jul 15 '11 at 20:48










  • @slhck: Yes I am indeed using macport's bash completion
    – disappearedng
    Jul 15 '11 at 21:17












  • @Daniel: Everything is fine except for this. I profiled almost every line.
    – disappearedng
    Jul 15 '11 at 21:17








  • 5




    I experience the same slowness and I'm using Homebrew.
    – Brice
    Jan 30 '12 at 11:52













up vote
12
down vote

favorite
8









up vote
12
down vote

favorite
8






8





I don't understand why bash completion is loaded so slow on my MacBook Pro.



I did the following in my ~/.bash_profile:



echo "Loading BashCompletion..."
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
echo "BashCompletion loaded."


the execution time for bash_completion typically is > 2 seconds.



I find that really annoying when I am working on the terminal which requires me to constantly open new tabs.



Is there a way I can cache this or something?



(Note I am using iTerm2 and this is equally slow on the original terminal in Mac as well).










share|improve this question















I don't understand why bash completion is loaded so slow on my MacBook Pro.



I did the following in my ~/.bash_profile:



echo "Loading BashCompletion..."
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
echo "BashCompletion loaded."


the execution time for bash_completion typically is > 2 seconds.



I find that really annoying when I am working on the terminal which requires me to constantly open new tabs.



Is there a way I can cache this or something?



(Note I am using iTerm2 and this is equally slow on the original terminal in Mac as well).







macos bash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 15 '11 at 20:27









slhck

158k47437461




158k47437461










asked Jul 15 '11 at 19:37









disappearedng

3461716




3461716












  • That should not be happening. Am I correct you use MacPort's bash completion?
    – slhck
    Jul 15 '11 at 20:27










  • What does that file you load look like?
    – Daniel Beck
    Jul 15 '11 at 20:48










  • @slhck: Yes I am indeed using macport's bash completion
    – disappearedng
    Jul 15 '11 at 21:17












  • @Daniel: Everything is fine except for this. I profiled almost every line.
    – disappearedng
    Jul 15 '11 at 21:17








  • 5




    I experience the same slowness and I'm using Homebrew.
    – Brice
    Jan 30 '12 at 11:52


















  • That should not be happening. Am I correct you use MacPort's bash completion?
    – slhck
    Jul 15 '11 at 20:27










  • What does that file you load look like?
    – Daniel Beck
    Jul 15 '11 at 20:48










  • @slhck: Yes I am indeed using macport's bash completion
    – disappearedng
    Jul 15 '11 at 21:17












  • @Daniel: Everything is fine except for this. I profiled almost every line.
    – disappearedng
    Jul 15 '11 at 21:17








  • 5




    I experience the same slowness and I'm using Homebrew.
    – Brice
    Jan 30 '12 at 11:52
















That should not be happening. Am I correct you use MacPort's bash completion?
– slhck
Jul 15 '11 at 20:27




That should not be happening. Am I correct you use MacPort's bash completion?
– slhck
Jul 15 '11 at 20:27












What does that file you load look like?
– Daniel Beck
Jul 15 '11 at 20:48




What does that file you load look like?
– Daniel Beck
Jul 15 '11 at 20:48












@slhck: Yes I am indeed using macport's bash completion
– disappearedng
Jul 15 '11 at 21:17






@slhck: Yes I am indeed using macport's bash completion
– disappearedng
Jul 15 '11 at 21:17














@Daniel: Everything is fine except for this. I profiled almost every line.
– disappearedng
Jul 15 '11 at 21:17






@Daniel: Everything is fine except for this. I profiled almost every line.
– disappearedng
Jul 15 '11 at 21:17






5




5




I experience the same slowness and I'm using Homebrew.
– Brice
Jan 30 '12 at 11:52




I experience the same slowness and I'm using Homebrew.
– Brice
Jan 30 '12 at 11:52










5 Answers
5






active

oldest

votes

















up vote
6
down vote













Short version: Removing a single line from /usr/local/etc/bash_completion reduced the time to open a new tab from ten seconds to a quarter of a second. Read on for details.



I'm using bash-completion from homebrew and encountered the same problem. It was taking over ten seconds to load the bash completion scripts each time I opened a terminal.



Most of that time, it seems is taken up by a single line in the have() function: a call to type to determine if a command-line program is installed.



With the default have() function and all of the provided bash completion scripts in place, it would take 10.561s to load the scripts (reported by prefixing time to the . /opt/local/etc/bash_completion line in my .bash_profile file.



After commenting out the PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null && line of my /usr/local/etc/bash_completion script (leaving the have=yes line, opening a new terminal takes only 0.258s. This time could be reduced further by removing unnecessary completion scripts (symlinks) from the /usr/local/etc/bash_completion.d directory.



I don't know why the call to type is taking so long. I'm investigating that next.



One potential downside to this approach is that it will cause bash completion functions to be loaded into memory even though you have no use for them. The have() function checks to see if a command or application is installed. If it's not, the completion script generally decides not to bother loading itself because it will be of no use.



At the moment, I'm happy with the tradeoff but I will continue to explore the type problem as I get time. I'll update my answer if I find a better solution.






share|improve this answer























  • For me, commenting this line reduces 50ms time, from 230ms to 180ms. Of course I never had it so bad in the first place. 👍
    – Edward Anderson
    Dec 28 '17 at 2:44










  • This only shaved off about 60ms, so I've not kept the workaround. I don't have ten second wait times, but about 2s, which is mildly irksome.
    – danemacmillan
    Feb 7 at 0:03




















up vote
0
down vote













I had the same issue. A few simple debugging tricks got me to the root cause.



First, enable DEBUG mode so you can see what's happening:



  export BASH_COMPLETION_DEBUG=true


This enables verbose printing to the console, so you can see the last command. You can now execute the script in the background and you'll see what's happening



   . /opt/local/etc/bash_completion &


Take not of the PID, which you can then trace with ps or pstree:



pstree -p <the PID>:



   | |     -+= 82095 mfellows -bash
| | -+- 82103 mfellows -bash
| | |-+- 82104 mfellows cargo --list
| | | --- 82106 mfellows rustc -vV --cap-lints allow


As you can see, it started some rust related commands, which were taking ages.



Temporarily removing /opt/boxen/homebrew/etc/bash_completion.d/cargo resolved my symptoms.






share|improve this answer




























    up vote
    0
    down vote













    With the idea that godbyk answer gave me, I found that my PATH variable had a few directories that didn't have any binaries or didn't exists, removing them sped it up significantly. In other words, this is the PATH I had in my bashrc:



    PATH="$GOPATH/bin:/some/directory/not/existing:/some/empty/directory:/some/directory/without/binaries:$PATH"


    And then I changed it to:



    PATH="$GOPATH/bin:$PATH"


    This was because have function in that bash completion, looked for each command, and I had too much of useless directories that was going to be visited for each of those binaries, removing them sped it up.






    share|improve this answer






























      up vote
      -1
      down vote













      If you're running MacPorts >= 2.1.2 and Mountain Lion it seems your bash_profile is wrong. Follow the instructions on How to get git-completion.bash to work on Mac OS X?. I assume that could speed up the auto-completion.



      Another solution would be to try installing auto-complete via Fink or Homebrew. If that doesn´t work, you could try another shell altogether. I've found that Fish shell is outstanding when it comes to auto-completion (out of the box). Though version 2 is still in beta I would highly recommend it.






      share|improve this answer






























        up vote
        -1
        down vote













        I'm going to guess that your bash is too old. I'm running stock bash that came with Mountain Lion and here's what I see:



        $ port info bash-completion
        bash-completion @2.0, Revision 1 (sysutils)

        Description: Programmable completion library for bash. This port
        **requires bash >=4.1** and is meant to be used together with
        the bash port.
        Homepage: http://bash-completion.alioth.debian.org/

        Runtime Dependencies: bash
        Conflicts with: bash-completion-devel
        Platforms: darwin
        License: GPL-2+
        Maintainers: raimue@macports.org

        $ bash --version
        GNU bash, version **3.2.48(1)-release (x86_64-apple-darwin12)**
        Copyright (C) 2007 Free Software Foundation, Inc.





        share|improve this answer























        • I don't see to have this port command. :( How do I find out which git tab completion software is running on my mac.
          – Dean Hiller
          Aug 14 '14 at 16:13










        • @DeanHiller This answer is referring to the Macports package manager, which provides the port command. Macports's bash completion app will be newer than the one provided with OS X.
          – Matt S
          Aug 25 '14 at 16:12













        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',
        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%2f311056%2fwhy-is-bash-completion-being-loaded-so-slow-on-os-x%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        6
        down vote













        Short version: Removing a single line from /usr/local/etc/bash_completion reduced the time to open a new tab from ten seconds to a quarter of a second. Read on for details.



        I'm using bash-completion from homebrew and encountered the same problem. It was taking over ten seconds to load the bash completion scripts each time I opened a terminal.



        Most of that time, it seems is taken up by a single line in the have() function: a call to type to determine if a command-line program is installed.



        With the default have() function and all of the provided bash completion scripts in place, it would take 10.561s to load the scripts (reported by prefixing time to the . /opt/local/etc/bash_completion line in my .bash_profile file.



        After commenting out the PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null && line of my /usr/local/etc/bash_completion script (leaving the have=yes line, opening a new terminal takes only 0.258s. This time could be reduced further by removing unnecessary completion scripts (symlinks) from the /usr/local/etc/bash_completion.d directory.



        I don't know why the call to type is taking so long. I'm investigating that next.



        One potential downside to this approach is that it will cause bash completion functions to be loaded into memory even though you have no use for them. The have() function checks to see if a command or application is installed. If it's not, the completion script generally decides not to bother loading itself because it will be of no use.



        At the moment, I'm happy with the tradeoff but I will continue to explore the type problem as I get time. I'll update my answer if I find a better solution.






        share|improve this answer























        • For me, commenting this line reduces 50ms time, from 230ms to 180ms. Of course I never had it so bad in the first place. 👍
          – Edward Anderson
          Dec 28 '17 at 2:44










        • This only shaved off about 60ms, so I've not kept the workaround. I don't have ten second wait times, but about 2s, which is mildly irksome.
          – danemacmillan
          Feb 7 at 0:03

















        up vote
        6
        down vote













        Short version: Removing a single line from /usr/local/etc/bash_completion reduced the time to open a new tab from ten seconds to a quarter of a second. Read on for details.



        I'm using bash-completion from homebrew and encountered the same problem. It was taking over ten seconds to load the bash completion scripts each time I opened a terminal.



        Most of that time, it seems is taken up by a single line in the have() function: a call to type to determine if a command-line program is installed.



        With the default have() function and all of the provided bash completion scripts in place, it would take 10.561s to load the scripts (reported by prefixing time to the . /opt/local/etc/bash_completion line in my .bash_profile file.



        After commenting out the PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null && line of my /usr/local/etc/bash_completion script (leaving the have=yes line, opening a new terminal takes only 0.258s. This time could be reduced further by removing unnecessary completion scripts (symlinks) from the /usr/local/etc/bash_completion.d directory.



        I don't know why the call to type is taking so long. I'm investigating that next.



        One potential downside to this approach is that it will cause bash completion functions to be loaded into memory even though you have no use for them. The have() function checks to see if a command or application is installed. If it's not, the completion script generally decides not to bother loading itself because it will be of no use.



        At the moment, I'm happy with the tradeoff but I will continue to explore the type problem as I get time. I'll update my answer if I find a better solution.






        share|improve this answer























        • For me, commenting this line reduces 50ms time, from 230ms to 180ms. Of course I never had it so bad in the first place. 👍
          – Edward Anderson
          Dec 28 '17 at 2:44










        • This only shaved off about 60ms, so I've not kept the workaround. I don't have ten second wait times, but about 2s, which is mildly irksome.
          – danemacmillan
          Feb 7 at 0:03















        up vote
        6
        down vote










        up vote
        6
        down vote









        Short version: Removing a single line from /usr/local/etc/bash_completion reduced the time to open a new tab from ten seconds to a quarter of a second. Read on for details.



        I'm using bash-completion from homebrew and encountered the same problem. It was taking over ten seconds to load the bash completion scripts each time I opened a terminal.



        Most of that time, it seems is taken up by a single line in the have() function: a call to type to determine if a command-line program is installed.



        With the default have() function and all of the provided bash completion scripts in place, it would take 10.561s to load the scripts (reported by prefixing time to the . /opt/local/etc/bash_completion line in my .bash_profile file.



        After commenting out the PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null && line of my /usr/local/etc/bash_completion script (leaving the have=yes line, opening a new terminal takes only 0.258s. This time could be reduced further by removing unnecessary completion scripts (symlinks) from the /usr/local/etc/bash_completion.d directory.



        I don't know why the call to type is taking so long. I'm investigating that next.



        One potential downside to this approach is that it will cause bash completion functions to be loaded into memory even though you have no use for them. The have() function checks to see if a command or application is installed. If it's not, the completion script generally decides not to bother loading itself because it will be of no use.



        At the moment, I'm happy with the tradeoff but I will continue to explore the type problem as I get time. I'll update my answer if I find a better solution.






        share|improve this answer














        Short version: Removing a single line from /usr/local/etc/bash_completion reduced the time to open a new tab from ten seconds to a quarter of a second. Read on for details.



        I'm using bash-completion from homebrew and encountered the same problem. It was taking over ten seconds to load the bash completion scripts each time I opened a terminal.



        Most of that time, it seems is taken up by a single line in the have() function: a call to type to determine if a command-line program is installed.



        With the default have() function and all of the provided bash completion scripts in place, it would take 10.561s to load the scripts (reported by prefixing time to the . /opt/local/etc/bash_completion line in my .bash_profile file.



        After commenting out the PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null && line of my /usr/local/etc/bash_completion script (leaving the have=yes line, opening a new terminal takes only 0.258s. This time could be reduced further by removing unnecessary completion scripts (symlinks) from the /usr/local/etc/bash_completion.d directory.



        I don't know why the call to type is taking so long. I'm investigating that next.



        One potential downside to this approach is that it will cause bash completion functions to be loaded into memory even though you have no use for them. The have() function checks to see if a command or application is installed. If it's not, the completion script generally decides not to bother loading itself because it will be of no use.



        At the moment, I'm happy with the tradeoff but I will continue to explore the type problem as I get time. I'll update my answer if I find a better solution.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 19 '17 at 0:18

























        answered Nov 14 '15 at 1:50









        godbyk

        19613




        19613












        • For me, commenting this line reduces 50ms time, from 230ms to 180ms. Of course I never had it so bad in the first place. 👍
          – Edward Anderson
          Dec 28 '17 at 2:44










        • This only shaved off about 60ms, so I've not kept the workaround. I don't have ten second wait times, but about 2s, which is mildly irksome.
          – danemacmillan
          Feb 7 at 0:03




















        • For me, commenting this line reduces 50ms time, from 230ms to 180ms. Of course I never had it so bad in the first place. 👍
          – Edward Anderson
          Dec 28 '17 at 2:44










        • This only shaved off about 60ms, so I've not kept the workaround. I don't have ten second wait times, but about 2s, which is mildly irksome.
          – danemacmillan
          Feb 7 at 0:03


















        For me, commenting this line reduces 50ms time, from 230ms to 180ms. Of course I never had it so bad in the first place. 👍
        – Edward Anderson
        Dec 28 '17 at 2:44




        For me, commenting this line reduces 50ms time, from 230ms to 180ms. Of course I never had it so bad in the first place. 👍
        – Edward Anderson
        Dec 28 '17 at 2:44












        This only shaved off about 60ms, so I've not kept the workaround. I don't have ten second wait times, but about 2s, which is mildly irksome.
        – danemacmillan
        Feb 7 at 0:03






        This only shaved off about 60ms, so I've not kept the workaround. I don't have ten second wait times, but about 2s, which is mildly irksome.
        – danemacmillan
        Feb 7 at 0:03














        up vote
        0
        down vote













        I had the same issue. A few simple debugging tricks got me to the root cause.



        First, enable DEBUG mode so you can see what's happening:



          export BASH_COMPLETION_DEBUG=true


        This enables verbose printing to the console, so you can see the last command. You can now execute the script in the background and you'll see what's happening



           . /opt/local/etc/bash_completion &


        Take not of the PID, which you can then trace with ps or pstree:



        pstree -p <the PID>:



           | |     -+= 82095 mfellows -bash
        | | -+- 82103 mfellows -bash
        | | |-+- 82104 mfellows cargo --list
        | | | --- 82106 mfellows rustc -vV --cap-lints allow


        As you can see, it started some rust related commands, which were taking ages.



        Temporarily removing /opt/boxen/homebrew/etc/bash_completion.d/cargo resolved my symptoms.






        share|improve this answer

























          up vote
          0
          down vote













          I had the same issue. A few simple debugging tricks got me to the root cause.



          First, enable DEBUG mode so you can see what's happening:



            export BASH_COMPLETION_DEBUG=true


          This enables verbose printing to the console, so you can see the last command. You can now execute the script in the background and you'll see what's happening



             . /opt/local/etc/bash_completion &


          Take not of the PID, which you can then trace with ps or pstree:



          pstree -p <the PID>:



             | |     -+= 82095 mfellows -bash
          | | -+- 82103 mfellows -bash
          | | |-+- 82104 mfellows cargo --list
          | | | --- 82106 mfellows rustc -vV --cap-lints allow


          As you can see, it started some rust related commands, which were taking ages.



          Temporarily removing /opt/boxen/homebrew/etc/bash_completion.d/cargo resolved my symptoms.






          share|improve this answer























            up vote
            0
            down vote










            up vote
            0
            down vote









            I had the same issue. A few simple debugging tricks got me to the root cause.



            First, enable DEBUG mode so you can see what's happening:



              export BASH_COMPLETION_DEBUG=true


            This enables verbose printing to the console, so you can see the last command. You can now execute the script in the background and you'll see what's happening



               . /opt/local/etc/bash_completion &


            Take not of the PID, which you can then trace with ps or pstree:



            pstree -p <the PID>:



               | |     -+= 82095 mfellows -bash
            | | -+- 82103 mfellows -bash
            | | |-+- 82104 mfellows cargo --list
            | | | --- 82106 mfellows rustc -vV --cap-lints allow


            As you can see, it started some rust related commands, which were taking ages.



            Temporarily removing /opt/boxen/homebrew/etc/bash_completion.d/cargo resolved my symptoms.






            share|improve this answer












            I had the same issue. A few simple debugging tricks got me to the root cause.



            First, enable DEBUG mode so you can see what's happening:



              export BASH_COMPLETION_DEBUG=true


            This enables verbose printing to the console, so you can see the last command. You can now execute the script in the background and you'll see what's happening



               . /opt/local/etc/bash_completion &


            Take not of the PID, which you can then trace with ps or pstree:



            pstree -p <the PID>:



               | |     -+= 82095 mfellows -bash
            | | -+- 82103 mfellows -bash
            | | |-+- 82104 mfellows cargo --list
            | | | --- 82106 mfellows rustc -vV --cap-lints allow


            As you can see, it started some rust related commands, which were taking ages.



            Temporarily removing /opt/boxen/homebrew/etc/bash_completion.d/cargo resolved my symptoms.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 13 at 20:24









            Matthew Fellows

            1112




            1112






















                up vote
                0
                down vote













                With the idea that godbyk answer gave me, I found that my PATH variable had a few directories that didn't have any binaries or didn't exists, removing them sped it up significantly. In other words, this is the PATH I had in my bashrc:



                PATH="$GOPATH/bin:/some/directory/not/existing:/some/empty/directory:/some/directory/without/binaries:$PATH"


                And then I changed it to:



                PATH="$GOPATH/bin:$PATH"


                This was because have function in that bash completion, looked for each command, and I had too much of useless directories that was going to be visited for each of those binaries, removing them sped it up.






                share|improve this answer



























                  up vote
                  0
                  down vote













                  With the idea that godbyk answer gave me, I found that my PATH variable had a few directories that didn't have any binaries or didn't exists, removing them sped it up significantly. In other words, this is the PATH I had in my bashrc:



                  PATH="$GOPATH/bin:/some/directory/not/existing:/some/empty/directory:/some/directory/without/binaries:$PATH"


                  And then I changed it to:



                  PATH="$GOPATH/bin:$PATH"


                  This was because have function in that bash completion, looked for each command, and I had too much of useless directories that was going to be visited for each of those binaries, removing them sped it up.






                  share|improve this answer

























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    With the idea that godbyk answer gave me, I found that my PATH variable had a few directories that didn't have any binaries or didn't exists, removing them sped it up significantly. In other words, this is the PATH I had in my bashrc:



                    PATH="$GOPATH/bin:/some/directory/not/existing:/some/empty/directory:/some/directory/without/binaries:$PATH"


                    And then I changed it to:



                    PATH="$GOPATH/bin:$PATH"


                    This was because have function in that bash completion, looked for each command, and I had too much of useless directories that was going to be visited for each of those binaries, removing them sped it up.






                    share|improve this answer














                    With the idea that godbyk answer gave me, I found that my PATH variable had a few directories that didn't have any binaries or didn't exists, removing them sped it up significantly. In other words, this is the PATH I had in my bashrc:



                    PATH="$GOPATH/bin:/some/directory/not/existing:/some/empty/directory:/some/directory/without/binaries:$PATH"


                    And then I changed it to:



                    PATH="$GOPATH/bin:$PATH"


                    This was because have function in that bash completion, looked for each command, and I had too much of useless directories that was going to be visited for each of those binaries, removing them sped it up.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 22 at 17:12

























                    answered Nov 22 at 14:36









                    Farid Nouri Neshat

                    1014




                    1014






















                        up vote
                        -1
                        down vote













                        If you're running MacPorts >= 2.1.2 and Mountain Lion it seems your bash_profile is wrong. Follow the instructions on How to get git-completion.bash to work on Mac OS X?. I assume that could speed up the auto-completion.



                        Another solution would be to try installing auto-complete via Fink or Homebrew. If that doesn´t work, you could try another shell altogether. I've found that Fish shell is outstanding when it comes to auto-completion (out of the box). Though version 2 is still in beta I would highly recommend it.






                        share|improve this answer



























                          up vote
                          -1
                          down vote













                          If you're running MacPorts >= 2.1.2 and Mountain Lion it seems your bash_profile is wrong. Follow the instructions on How to get git-completion.bash to work on Mac OS X?. I assume that could speed up the auto-completion.



                          Another solution would be to try installing auto-complete via Fink or Homebrew. If that doesn´t work, you could try another shell altogether. I've found that Fish shell is outstanding when it comes to auto-completion (out of the box). Though version 2 is still in beta I would highly recommend it.






                          share|improve this answer

























                            up vote
                            -1
                            down vote










                            up vote
                            -1
                            down vote









                            If you're running MacPorts >= 2.1.2 and Mountain Lion it seems your bash_profile is wrong. Follow the instructions on How to get git-completion.bash to work on Mac OS X?. I assume that could speed up the auto-completion.



                            Another solution would be to try installing auto-complete via Fink or Homebrew. If that doesn´t work, you could try another shell altogether. I've found that Fish shell is outstanding when it comes to auto-completion (out of the box). Though version 2 is still in beta I would highly recommend it.






                            share|improve this answer














                            If you're running MacPorts >= 2.1.2 and Mountain Lion it seems your bash_profile is wrong. Follow the instructions on How to get git-completion.bash to work on Mac OS X?. I assume that could speed up the auto-completion.



                            Another solution would be to try installing auto-complete via Fink or Homebrew. If that doesn´t work, you could try another shell altogether. I've found that Fish shell is outstanding when it comes to auto-completion (out of the box). Though version 2 is still in beta I would highly recommend it.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Mar 20 '17 at 10:17









                            Community

                            1




                            1










                            answered Mar 27 '13 at 12:17









                            awek

                            243




                            243






















                                up vote
                                -1
                                down vote













                                I'm going to guess that your bash is too old. I'm running stock bash that came with Mountain Lion and here's what I see:



                                $ port info bash-completion
                                bash-completion @2.0, Revision 1 (sysutils)

                                Description: Programmable completion library for bash. This port
                                **requires bash >=4.1** and is meant to be used together with
                                the bash port.
                                Homepage: http://bash-completion.alioth.debian.org/

                                Runtime Dependencies: bash
                                Conflicts with: bash-completion-devel
                                Platforms: darwin
                                License: GPL-2+
                                Maintainers: raimue@macports.org

                                $ bash --version
                                GNU bash, version **3.2.48(1)-release (x86_64-apple-darwin12)**
                                Copyright (C) 2007 Free Software Foundation, Inc.





                                share|improve this answer























                                • I don't see to have this port command. :( How do I find out which git tab completion software is running on my mac.
                                  – Dean Hiller
                                  Aug 14 '14 at 16:13










                                • @DeanHiller This answer is referring to the Macports package manager, which provides the port command. Macports's bash completion app will be newer than the one provided with OS X.
                                  – Matt S
                                  Aug 25 '14 at 16:12

















                                up vote
                                -1
                                down vote













                                I'm going to guess that your bash is too old. I'm running stock bash that came with Mountain Lion and here's what I see:



                                $ port info bash-completion
                                bash-completion @2.0, Revision 1 (sysutils)

                                Description: Programmable completion library for bash. This port
                                **requires bash >=4.1** and is meant to be used together with
                                the bash port.
                                Homepage: http://bash-completion.alioth.debian.org/

                                Runtime Dependencies: bash
                                Conflicts with: bash-completion-devel
                                Platforms: darwin
                                License: GPL-2+
                                Maintainers: raimue@macports.org

                                $ bash --version
                                GNU bash, version **3.2.48(1)-release (x86_64-apple-darwin12)**
                                Copyright (C) 2007 Free Software Foundation, Inc.





                                share|improve this answer























                                • I don't see to have this port command. :( How do I find out which git tab completion software is running on my mac.
                                  – Dean Hiller
                                  Aug 14 '14 at 16:13










                                • @DeanHiller This answer is referring to the Macports package manager, which provides the port command. Macports's bash completion app will be newer than the one provided with OS X.
                                  – Matt S
                                  Aug 25 '14 at 16:12















                                up vote
                                -1
                                down vote










                                up vote
                                -1
                                down vote









                                I'm going to guess that your bash is too old. I'm running stock bash that came with Mountain Lion and here's what I see:



                                $ port info bash-completion
                                bash-completion @2.0, Revision 1 (sysutils)

                                Description: Programmable completion library for bash. This port
                                **requires bash >=4.1** and is meant to be used together with
                                the bash port.
                                Homepage: http://bash-completion.alioth.debian.org/

                                Runtime Dependencies: bash
                                Conflicts with: bash-completion-devel
                                Platforms: darwin
                                License: GPL-2+
                                Maintainers: raimue@macports.org

                                $ bash --version
                                GNU bash, version **3.2.48(1)-release (x86_64-apple-darwin12)**
                                Copyright (C) 2007 Free Software Foundation, Inc.





                                share|improve this answer














                                I'm going to guess that your bash is too old. I'm running stock bash that came with Mountain Lion and here's what I see:



                                $ port info bash-completion
                                bash-completion @2.0, Revision 1 (sysutils)

                                Description: Programmable completion library for bash. This port
                                **requires bash >=4.1** and is meant to be used together with
                                the bash port.
                                Homepage: http://bash-completion.alioth.debian.org/

                                Runtime Dependencies: bash
                                Conflicts with: bash-completion-devel
                                Platforms: darwin
                                License: GPL-2+
                                Maintainers: raimue@macports.org

                                $ bash --version
                                GNU bash, version **3.2.48(1)-release (x86_64-apple-darwin12)**
                                Copyright (C) 2007 Free Software Foundation, Inc.






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Apr 4 '13 at 9:37









                                slhck

                                158k47437461




                                158k47437461










                                answered Apr 4 '13 at 4:56









                                numeric illustration

                                28626




                                28626












                                • I don't see to have this port command. :( How do I find out which git tab completion software is running on my mac.
                                  – Dean Hiller
                                  Aug 14 '14 at 16:13










                                • @DeanHiller This answer is referring to the Macports package manager, which provides the port command. Macports's bash completion app will be newer than the one provided with OS X.
                                  – Matt S
                                  Aug 25 '14 at 16:12




















                                • I don't see to have this port command. :( How do I find out which git tab completion software is running on my mac.
                                  – Dean Hiller
                                  Aug 14 '14 at 16:13










                                • @DeanHiller This answer is referring to the Macports package manager, which provides the port command. Macports's bash completion app will be newer than the one provided with OS X.
                                  – Matt S
                                  Aug 25 '14 at 16:12


















                                I don't see to have this port command. :( How do I find out which git tab completion software is running on my mac.
                                – Dean Hiller
                                Aug 14 '14 at 16:13




                                I don't see to have this port command. :( How do I find out which git tab completion software is running on my mac.
                                – Dean Hiller
                                Aug 14 '14 at 16:13












                                @DeanHiller This answer is referring to the Macports package manager, which provides the port command. Macports's bash completion app will be newer than the one provided with OS X.
                                – Matt S
                                Aug 25 '14 at 16:12






                                @DeanHiller This answer is referring to the Macports package manager, which provides the port command. Macports's bash completion app will be newer than the one provided with OS X.
                                – Matt S
                                Aug 25 '14 at 16:12




















                                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.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • 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%2f311056%2fwhy-is-bash-completion-being-loaded-so-slow-on-os-x%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

                                Plaza Victoria

                                Puebla de Zaragoza

                                Musa