OS X ships with an outdated version of Bash as its default shell. The preinstalled version dates back to 2007, yes - nearly a decade behind.
If you want to use an updated version of Bash and Bash Completions in your shell, you can install them by using Homebrew, a package manager for OS X.
Installing via Homebrew
Open your terminal and enter this command:
| |
Now we’ll append our desired (Bash 4) shell’s path to a file of whitelisted system shells, and then change the system shell for our user.
| |
If you don’t want to modify your system shell, you can use iTerm’s profile manager to use your brewed version
iTerm.app -> Preferences -> Profiles -> General -> Command -> Click on "Command" and paste "/usr/local/bin/bash --login"
Just paste /usr/local/bin/bash and relaunch your default profile.
Testing New Bash
after you reload your profile, try
| |
If you see something like 4.3.42(1)-release you’re good to go. The OSX binary is likely going to be ~ 3.2.57(1)-release
Better Bash Completions
Now that you’ve installed Bash 4 and your terminal sources it when you open a new profile, you can use bash_completions2 as it’s not compatible with the OSX shipped binary.
| |
After you installed pay attention to the Caveatssection because you’ll need to add the following to your ~/.bash_profile
| |
In my dotfiles , I actually use:
| |
Now we can tab to autocomplete a range of commands, and pretty much any brew binary you have installed, ie:
| |
Bash Brothers Forever
