Results 1 to 1 of 1

Thread: bash-completion working 100%... I think!

  1. #1
    Join Date
    Jan 2011
    Beans
    5

    Lightbulb bash-completion working 100%... I think!

    Well After half the night installing latest version of git from ppa. i noticed that git completion wasnít working. So I started my troubleshooting methods; Google. I saw post from various forums with solutions that sourced /etc/bash_completion.d/git in ~/bashrc. I tried it and it worked. In the process of all this i looked through the directory of /etc/bash_completion.d/ and there are around 150 or so files for various programs, some of which Iím sure arenít installed on my box. so out of curiosity i chose a random file from that dir and enter the command in terminal followed by [TAB] [TAB] to see if auto completion would work. to my surprise it didnít work. So i chose another which was the command dpkg; [TAB] [TAB] auto completion worked! Some worked, most didnít. I then thought of how tedious it would be to source every single file inside my ~/.bashrc. so I began looking through my ~/.bashrc... At the bottom is:

    ~/.bashrc BEFORE

    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
    fi

    So after looking at this for along time I looked through /etc/bash_completion which is a bunch of stuff I really didnít follow. but after all those lines, why isnít /etc/bash_completion sourcing all files in /etc/bash_completion.d/? So since Iím a little familiar with bash scripts(very little) I began looking at ~/.bashrc again, and I changed it to look like this:

    ~/.bashrc AFTER

    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -d /etc/bash_completion.d/ ] && ! shopt -oq posix; then
    . /etc/bash_completion
    fi

    saved the edited ~/.bashrc, closed then reopened terminal. I first tried git [TAB] [TAB] and completion worked! I tried dpkg, it worked! I tried rsync it worked! I tried a few more and they ďallĒ work now. The ď-fĒ switch = if <file> exists. The ď-dĒ = if <directory> exists. and ď changed /etc/bash_completion.d/ because that directory exists.

    Iím not sure if its a bug in /etc/bash_completion or not. Iím using ubuntu 10.04(64-bit) on a Dell Latitude D620. If anyone else has problems with auto completion of any command listed in /etc/bash_completion.d/ give this a try all you have to do is copy/paste. Let me know if this helped you.

    -leemaster81
    Last edited by leemaster81; August 6th, 2012 at 12:17 AM. Reason: changed title

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •