- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Change color in PS1
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
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
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
тАО05-06-2002 04:56 PM
тАО05-06-2002 04:56 PM
Example
user@host:$PWD >
Where user can be one color,
host can be another...etc...
using dtterm?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2002 08:28 PM
тАО05-06-2002 08:28 PM
Re: Change color in PS1
PS1="`whoami`@`hostname`:"'${PWD}'""
Depending on where you define this (.profile or .kshrc), you would vi that file and insert the escape sequence. Say you want blue for "whoami" and yellow for "hostname", the color esc code would be ..
esc&v4S for blue
esc&v3S for yellow
In vi bring your cursor in the position ready for an insert (the first ` before whoami and the third ` before hostname), enter ctrl-V then ESC which will give you ^[ and then enter &v4S and &v3S. The line should look like ..
PS1="^[&v4S`whoami`@^[&v3S`hostname`:"'${PWD}'""
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2002 08:50 PM
тАО05-06-2002 08:50 PM
SolutionThe ANSI color codes are numbers 0-7 for black, red, green, yellow, blue, magenta, cyan, and white respectively.
Example:
Blue on white for user name, yellow on magenta for hostname:
HOSTNAME=$(hostname)
BOW="$(tput setaf 4)$(tput setab 7)"
YOM="$(tput setaf 3)$(tput setab 5)"
NONE="$(tput sgr0)"
PS1=${BOW}${LOGNAME}${NONE}@${YOM}${HOSTNAME}${NONE}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2002 09:54 AM
тАО05-07-2002 09:54 AM
Re: Change color in PS1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2002 12:30 PM
тАО05-07-2002 12:30 PM
Re: Change color in PS1
Here's a common set of enhancements:
export HB=$(/usr/bin/tput dim) # dim text
export HV=$(/usr/bin/tput smso) # 1/2 bright inverse
export IV=$(/usr/bin/tput bold) # inverse
export UL=$(/usr/bin/tput smul) # underline
export BL=$(/usr/bin/tput blink) # blink
export EE=$(/usr/bin/tput sgr0) # end all enhancements
And an example PS1:
export PS1='$HB$LOGNAME $IV${PWD##${PWD%/*/*}/}$EE $ '
This produces half-bright username and inverse-video current-plus-parent directory.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2002 01:13 PM
тАО05-07-2002 01:13 PM