Bash terminal: change color of directories #

and the current working directory path. Because blue on black is hard to read.

Change the color of directories in bash:

  1. If you don't already have an /etc/DIR_COLORS file, create one: $ sudo dircolors -p > /etc/DIR_COLORS
    (See Configuring LS_COLORS for information on multi-user options)
  2. Open /etc/DIR_COLORS in a text editor and change DIR 01;34 to DIR 01;33 to change the default blue to yellow. More color codes.
  3. In ~/.bashrc, change eval "`dircolors -b`" to eval "$(dircolors /etc/DIR_COLORS)"
  4. Reload .bashrc to see the result: $ source ~/.bashrc

Change the bash prompt's current working directory path color:

  1. In ~/.bashrc, comment out every line between:
    # set a fancy prompt (non-color, unless we know we "want" color)
    and:
    # Comment in the above and uncomment this below for a color prompt
  2. Uncomment the next line and change 01;34m to 01;33m. It should look something like this:
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ '
  3. Reload .bashrc to see the result: $ source ~/.bashrc

Sources:

/nix | Sep 28, 2014


Subscribe or visit the archives.