Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to make commands I've typed (input) into terminal stand out from all the output.

For example:

imac:~ buster$ chmod -R g-w myfolder
imac:~ buster$ cd myfolder
imac:myfolder buster$ ls -l
total 0
drwxr-xr-x 9 root admin 306 Apr 20 2010 bin
drwxr-xr-x 7 root admin 238 Apr 20 2010 include
drwxr-xr-x 73 root admin 2482 May 18 17:16 lib
drwxr-xr-x 6 root admin 204 Apr 20 2010 man
imac:myfolder buster$ echo Go Giants!
Go Giants!

bold jumps to mind but I'd accept a color or even highlighting the whole line...

I'm sure there's a way to do this but it's not obvious to me...

thanks!

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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} "
share|improve this answer
    
Not ~/.bash_profile, but ~/.bashrc (or both, if you don't source .bashrc from .bash_profile). These settings need to be set for each interactive instance of bash, and .bash_profile is read only by login shells. –  Gilles Oct 27 '10 at 18:16
    
Thanks, will edit my answer. I have no bashrc, so I used what was there. –  Daniel Beck Oct 27 '10 at 18:20
    
2  
I figured it out, put an ${OFF} at the front: PS1="${OFF}\u@\h:\w \$${BOLD}" –  Jay Oct 27 '10 at 18:41
1  
@Daniel: There shouldn't be an underscore in ~/.bashrc. –  Dennis Williamson Oct 27 '10 at 19:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.