Make OS X Terminal commands I type BOLD
Edit your ~/.bash_profile
or ~/.bashrc
(see Gilles' comment below) and add the following lines:
BOLD="\[\033[1m\]"
OFF="\[\033[m\]"
PS1="${OFF}\u@\h:\w \$${BOLD}"
PS2="> ${BOLD}"
trap 'echo -ne "${OFF}" > $(tty)' DEBUG
Move the ${BOLD}
around to make part of the prompt also bold. If the prompt itself should not be colored, you need the ${OFF}
prefix in PS1
, otherwise empty lines (pressing enter without having something written) will make the following prompt bold (credits to @Jay, thanks again!)
This adds a debug trap to turn bold format off, so it's quite a hack. Credits (works without group tty on OS X though).
This is a bit of a hack, so use it at your own risk.
Only setting your PS1
/PS2
prompts to bold would be easier and just as visible:
BOLD="\[\033[1m\]"
OFF="\[\033[m\]"
PS1="${BOLD}\u@\h:\w \$${OFF}"
PS2="${BOLD}>${OFF} "
I had a little trouble with the solutions here while using El Capitan (esp. in iTerm2 but in plain old Terminal as well). I got two sorts of errors:
- The ability to delete my bash prompt entirely by just pressing space then backspace
-
Unwanted characters finding their way into my bash output, e.g. the input
pwd
would result in\[\]/Users/home/Directory
or in
\e[0m/Users/home/Directory
I propose the following solution, which is really just more of the same.
BOLD="\033[1m"
OFF="\033[m"
PS1="${OFF}\u@\h :${BOLD}"
PS2="> ${BOLD}"
trap 'echo -ne "${OFF}" > $(tty)' DEBUG