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.

Webcast
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers

Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.

Learn More

Sponsored by AMD

White Paper
Red Hat White Paper: Using an Open Source Framework to Catch the Bad Guy

Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6

Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.

Learn more about catching the bad guy in this free white paper.

Learn More

Sponsored by DLT Solutions