- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Bold text on PS1 prompt?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2006 07:33 AM
тАО01-20-2006 07:33 AM
Bold text on PS1 prompt?
We have 50 machines but no standard profile. The potential to become confused on where you are is there, and I wouldn't want to reboot the wrong box!!! (not likely but still) I am creating a standard profile and have the following two questions:
1) Is there a switch or sintax that can be added to the PS1 variable, (defined in .profile) so to create bold text within the command line prompt? I have inserted the following line in .profile...
export PS1=`whoami`@`B.``hostname`:'$PWD>
#'
Which creates the following prompt:
root@systemname:/>
# _
...That way the admin always knows what user they are presently using, what system name they are on and what directory they are in. For directory trees and command strings which are long, I have dropped root's "#" prompt to the next line.
I still want to make very SURE an admin knows what system they are on ...so I'd like to display the hostname in bold text. (Man entries can be created using a ".B" switch, but this doesn't work here). Any ideas? examples?
2) I'd also like to trap separate history files for each session. We presently use the same history file each time. separate would be easier to track issues, and keep track of your commands.
Last item, (sorry for lenght!) Is there a best practices white paper on this kind of thing.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2006 07:42 AM
тАО01-20-2006 07:42 AM
Re: Bold text on PS1 prompt?
For the bold part of the question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2006 07:47 AM
тАО01-20-2006 07:47 AM
Re: Bold text on PS1 prompt?
you can try,
export PS1=`tput bold``uname -n`:$LOGNAME:'$PWD">"'`tput sgr0`
Hope this helps.
regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2006 07:54 AM
тАО01-20-2006 07:54 AM
Re: Bold text on PS1 prompt?
HISTFILE=${HOME}/.ssh_history.$(date +%m%d%Y%H%M%S)
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2006 08:10 AM
тАО01-20-2006 08:10 AM
Re: Bold text on PS1 prompt?
On PS1 syntax I'm not quite there yet...
${HOME:-.}/.profile[31]: syntax error: `;' unexpected
I'm expirimenting with my single and double quotes...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2006 09:18 AM
тАО01-20-2006 09:18 AM
Re: Bold text on PS1 prompt?
b=`tput bold` #...then include ${b}just before the variable in question
These are your options...
b=`tput bold` #bold output
u=`tput smul` #underline
e=`tput rev` #reverse video
n=`tput sgr0` #normal output
k=`tput blink` #blink
or just use the tput variables themselves of course. Bold text comes out as reverse so it looks lame ...I did the following...
export PS1=`whoami`@`tput smul``hostname``tput sgr0`:'$PWD>
(you have to use sgr0 to turn off the text enhancement or it goes to the end of line.
Works like a champ! Still working the History point. Thanks guys!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2006 09:51 AM
тАО01-20-2006 09:51 AM
Re: Bold text on PS1 prompt?
For the Shell history, you can try,
export HISTFILE=$HOME/.sh_history.`/usr/bin/tty`.`/usr/bin/date +%m%d%y%H%M%S`
Hope this helps.
regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2006 01:32 PM
тАО01-21-2006 01:32 PM
Re: Bold text on PS1 prompt?
When the 'glass Teletype' became a reality around 1970, the concept of a hard-copy terminal required rework to match the paper effects that were in common usage. With only two colors (black and white/green/orange), something like bold had to emulated, usually with inverse video (dark letters on a light backgrounds). Underlining was also common, but glass tty's could also blink characters. And as the terminals became smarter, enhancements could be combined (bold + underline + blink). HP pioneered the smart terminal category with the 2640A and had the brightest characters (due to half-dot shifting), wide-screens (today = HDTV), and many video enhancements. The 2640A was the first implementation of the HP escape codes which would eventually become the base for the PCL printer language.
Other manufacturers, primarily DEC and Wyse, proceeded to develop their own terminal escape sequences with varied implementation techniques for the visual on the screen. The Curses library continued development to encompass all these features. To see the rich features available today, see the man pages for terminfo, tput, untic.
Almost no one uses terminals anymore. Instead, they are using PCs (which are not terminals) running some sort of terminal emulator. WRQ was one of the first companies to create a terminal emulator that could connect colors to various video enhancements. Later, other emulators would add colors and enhancements.
All this is background to why bold is not 'standard' across different emulators, and with emulator settings, can be different with the same emulator.
Another point of view about directories (especially Java): putting the entire directory path in the prompt can be really annoying. Usually, you need just the current directory and perhaps the parent (I like parent+current). I developed a customizable .profile snippet to handle the 3 most useful parts of a prompt: hostname, username and path. In the attached snippet, you can select one, two or all 3 fields and the enhancement to use for each field.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2006 08:29 PM
тАО01-22-2006 08:29 PM
Re: Bold text on PS1 prompt?
1.
if [[ [[ "$(tty)" = "not a tty" ]] ; then
B=''
R=''
else
B=$(tput bold)
R=$(tput sgr0)
fi
export PS1=${B}${LOGNAME}'$PWD'${R}
this because if you load the profile in not interactive mode (i.e. crontab) you will receive error if you use terminal command
2. To set different history files
HISTFILE=$HOME/.sh_history.$$
to remove it when exit to avoid fill directory
trap "rm $HISTFILE 1>/dev/null 2>&1" exit
HTH,
Art