The bash completion project provides a lot of interesting functionalities to the bash shell, one of the most used completion tips is when the user hits the tab key to complete the name of a file. Another interesting tip is applied to the cd command, when you type a cd (change directory) and after you hit the tab key you should see only the directories instead of all the files. this can be done using the complete command.


For programmers like me,  it is very useful the completion of the make command, if I type the tab key after make I want to see all the rules I can call. The bash-completion gives this functionality to me.

To use the bash-completion you have to use the MacPorts


Open a terminal window and issue the following commands:

$ sudo port install bash-completion


Warning: port definitions are more than two weeks old, consider using selfupdate

--->  Computing dependencies for bash-completion

--->  Dependencies to be installed: bash

--->  Fetching archive for bash

--->  Attempting to fetch bash-4.2.37_0.darwin_12.x86_64.tbz2 from

--->  Attempting to fetch bash-4.2.37_0.darwin_12.x86_64.tbz2 from

--->  Attempting to fetch bash-4.2.37_0.darwin_12.x86_64.tbz2 from

--->  Fetching distfiles for bash

--->  Attempting to fetch bash42-001 from

--->  Attempting to fetch bash42-002 from

--->  Attempting to fetch bash42-003 from

--->  Attempting to fetch bash42-004 from

--->  Attempting to fetch bash42-005 from

--->  Attempting to fetch bash42-006 from

--->  Attempting to fetch bash42-007 from

--->  Attempting to fetch bash42-008 from

--->  Attempting to fetch bash42-009 from

--->  Attempting to fetch bash42-010 from

--->  Attempting to fetch bash42-011 from

--->  Attempting to fetch bash42-012 from

--->  Attempting to fetch bash42-013 from

--->  Attempting to fetch bash42-014 from

--->  Attempting to fetch bash42-015 from

--->  Attempting to fetch bash42-016 from

--->  Attempting to fetch bash42-017 from

--->  Attempting to fetch bash42-018 from

--->  Attempting to fetch bash42-019 from

--->  Attempting to fetch bash42-020 from

--->  Attempting to fetch bash42-021 from

--->  Attempting to fetch bash42-022 from

--->  Attempting to fetch bash42-023 from

--->  Attempting to fetch bash42-024 from

--->  Attempting to fetch bash42-025 from

--->  Attempting to fetch bash42-026 from

--->  Attempting to fetch bash42-027 from

--->  Attempting to fetch bash42-028 from

--->  Attempting to fetch bash42-029 from

--->  Attempting to fetch bash42-030 from

--->  Attempting to fetch bash42-031 from

--->  Attempting to fetch bash42-032 from

--->  Attempting to fetch bash42-033 from

--->  Attempting to fetch bash42-034 from

--->  Attempting to fetch bash42-035 from

--->  Attempting to fetch bash42-036 from

--->  Attempting to fetch bash42-037 from

--->  Attempting to fetch bash-4.2.tar.gz from

--->  Verifying checksum(s) for bash

--->  Extracting bash

--->  Applying patches to bash

--->  Configuring bash

--->  Building bash

--->  Staging bash into destroot

--->  Installing bash @4.2.37_0

--->  Activating bash @4.2.37_0

--->  Cleaning bash

--->  Fetching archive for bash-completion

--->  Attempting to fetch bash-completion-2.0_1.darwin_12.noarch.tbz2 from

--->  Attempting to fetch bash-completion-2.0_1.darwin_12.noarch.tbz2.rmd160 from

--->  Installing bash-completion @2.0_1

--->  Activating bash-completion @2.0_1


To use bash_completion, add the following lines at the end of your .bash_profile:

  if [ -f /opt/local/etc/profile.d/ ]; then

      . /opt/local/etc/profile.d/


The port bash-completion >=2.0 requires bash >=4.1; please make sure

you are using /opt/local/bin/bash by changing the preferences of your

terminal accordingly. If your version of bash is too old, the script

above will not modify your shell environment and no extended completion

will be available.

--->  Cleaning bash-completion

--->  Updating database of binaries: 100.0%

--->  Scanning binaries for linking errors: 100.0%

--->  No broken files found.


To use bash_completion, add the following lines at the end of your .bash_profile:

$ cd

$ echo " if [ -f /opt/local/etc/profile.d/ ]; then" >> .bash_profile

$ echo ". /opt/local/etc/profile.d/" >> .bash_profile

$ echo  "fi" >> .bash_profile


Last, you need to change the command uses to launch the shell in the preferences.

  1. Goto Menu->Preferences>Startup, and then "Shells open with:"
  2. Select "Command" and enter /opt/local/bin/bash -l to switch to bash provided by MacPorts.
  3. Menu > Preferences > Settings > Shell (per shell type), "Prompt before closing:"
  4. Click "+" and add "bash" to the list of processes.
  5. Quit the terminal app and start it again.