Michael Minter Programmer & Entrepreneur

Search Multiple Directories With Cd

If you use the command line and frequent a particular directory you can set cd to scan, not just current, but other directories as well.

Modify ~/.bash_profile by appending directories to the CDPATH environment variable.

1
2
# define base directory for cd command
export CDPATH=$CDPATH:$HOME/Repos

Restart your terminal session and now you can cd projectDir. cd will reference any subdirectories in the current directory—as well as $HOME/Repos.

Autotabbing Custom Base Directories

You can install an additonal library; bash-completion to use the [tab] key to autocomplete from the cd command.

1
brew install bash-completion

Add the following to ~/.bash_profile.

1
2
3
4
# add bash-completion
if [ -f `brew --prefix`/etc/bash_completion ]; then
  . `brew --prefix`/etc/bash_completion
fi

To install bash-completion on other systems and more resources: https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion

Case Insensitive Completion

Update ~/.inputrc file to include the following line:

1
set completion-ignore-case on

For hyphens and underscores as well:

1
set completion-map-case on