My previous Terminal Tweaks post had an incorrect prompt (PS1) setting, that caused lines to wrap on themselves! This is now corrected, with more details on the color options...

The corrected .bash_profile is:

export CLICOLOR=1
export PS1="\[\e[36m\]\w\[\e[0m\]$ "
alias ll='ls -GFhl' dir='ls -GFhl'
alias start=open
printf "\033]0;`date "+%a %d %b %Y %I:%M %p"`\007"
alias title='printf "\033]0;%s\007"'

Line 2 used to read "\e[0;36m\w$ \e[m" which is correct for other UNIX distributions but not OSX. In OSX the format is:

\[\e[36m\] PROMPT \[\e[0m\]

The first \[\e[36m\] turns on the color (cyan in this case), and the closing \[\e[0m\] turns it off. \e is just shorthand for the ASCII escape \033. You can also use the opening format \[\e[36;40m\] to set the background (cyan on white in this case).

Color Foreground Background
Black 30 40
Red 31 41
Green 32 42
Yellow 33 43
Blue 34 44
Purple 35 45
Cyan 36 46
White 37 47

Check the bash man page, under the PROMPTING header for options for the PROMPT itself. Here's an excerpt (mine is just \w):

\d the date in "Weekday Month Date" format (e.g., "Tue May 26")
\h the hostname up to the first '.'
\H the hostname
\j the number of jobs currently managed by the shell
\l the basename of the shell's terminal device name
\s the name of the shell, the basename of $0 (the portion following the final slash)
\t the current time in 24-hour HH:MM:SS format
\T the current time in 12-hour HH:MM:SS format
\@ the current time in 12-hour am/pm format
\A the current time in 24-hour HH:MM format
\u the username of the current user
\v the version of bash (e.g., 2.00)
\V the release of bash, version + patch level (e.g., 2.00.0)
\w the current working directory, with $HOME abbreviated with a tilde
\W the basename of the current working directory, with $HOME abbreviated with a tilde
! the history number of this command
# the command number of this command

Related Posts

Newer Post Older Post