Extending the Bash Prompt

 in
Terminal and xterm prompts can be created incorporating standard escape sequences to give user name, current working directory, time and more.
______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

you can use the tput utility

norpan's picture

you can use the tput utility to avoid typing escape sequences and have it work on any terminal. Just use for instance $(tput setaf 1) instead of \e[31m.

xterm/xfterm4

Anonymous's picture

how about the title prompt in tthe bar up top? what is the code for that? I have:

function combo {
PS1="\[\033[01;34;01m\]\333\262\261\260\[\033[01;37;44m\]\u@\h\[\033[00;34;40m\]\260\261\262\333\[\033[00;34;40m\]\333\262\261\260\[\033[01;37;40m\] \d \$(date +%I:%M:%S%P)\n\[\033[01;33;40m\]$PWD>\[\033[00m\] "
PS2="\[\033[01;34;01m\]\333\262\261\260\[\033[00;34;40m\]\260\261\262\333\[\033[00;34;40m\]\260\261\262\333\[\033[00;34;40m\]\333\262\261\260\[\033[01;01;34m\]>\[\033[00m\] "
}
combo

and it just says "xterm" at the top title of the xterm--not the screen prompt, that is correct. Am I making sense? I have code for it, but i get my old hostname there, but the correct hostname at the screen prompt. I hope this makes sense...

USA bash prompt

s7even's picture

patriot or pirate....latter or former.

here's the fruit of some wasted productivity.
USA the _______.

pieces

PS1="\033[44m*****\033[41m \033[0m\n\033[44m*****\033[47m \033[0m\n\033[44m*****\033[41m \033[0m\n\033[47m \033[0m\n\033[41m \033[0m \$ "

ps,,, BSD rules =P

BSD ruled

humbletech99's picture

BSD did rule, but now is the time of GNU/Linux where newer, younger, stronger challengers are here, bring on Gentoo...

Also, death to 1000 distros, let's concentrate on 3 good ones...
(take note Mr Shuttleworth - you should be working for Debian, not seeking personal glory riding their coattails...)

Oh, and thanks for the article, LINUX Journal.