Is it possible to combine these two PS1 examples?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Is it possible to combine these two PS1 examples?
# 1  
Old 05-09-2012
Is it possible to combine these two PS1 examples?

I need to have the following joined if possible. Any help would be appreciated.

1st PS1 is for current working directory and color in ksh88.
Code:
PS1=$(printf "\033[46;31m%s@\033[1;33m%s:\033[1;34m\$PWD \033[0m \033[1;33m\$date\033[0m \$" $(logname) $(hostname))

2nd PS1 is for the time in ksh88.
Code:
date '+%H %M %S' | read H M S
SECONDS=$((S + 60*(60*H+M)))

Code:
PS1='${DUMMY[((S=(100+$SECONDS%60))+(M=(100+($SECONDS/60)%60))+(H=(100+($SECONDS/3600)%24)))*0]:-} ${H#1}:${M#1}:${S#1} $ '


Last edited by Scrutinizer; 05-10-2012 at 05:41 PM.. Reason: code tags
# 2  
Old 05-09-2012
Try this:

Code:
date '+%H %M %S' | read H M S
SECONDS=$((S + 60*(60*H+M)))
PS1='${DUMMY[((S=(100+$SECONDS%60))+(M=(100+($SECONDS/60)%60))+(H=(100+($SECONDS/3600)%24)))*0]:-}'$(printf "\033[46;31m%s@\033[1;33m%s:\033[1;34m\$PWD \033[0m \033[1;33m\${H#1}:\${M#1}:\${S#1}\033[0m \$" $(logname) $(hostname))

# 3  
Old 05-10-2012
That worked perfectly. Can I ask one more? How can I keep the color of the letters the same, but remove the highlighting which is a light blue color.
# 4  
Old 05-10-2012
You just need to switch the ANSI Color code from "cyan-background; red" to "default-background; red" or "high-intensity; red"

i.e. Replace printf "\033[46;31m in the above with printf "\033[49;31m or printf "\033[1;31m
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need lot of examples

Hi, I need a word doc or pdf which contains lots of Shell Programming samples... This is for my open book examination, thanks in advance.. (2 Replies)
Discussion started by: karthikeayan
2 Replies

2. Programming

Examples, usage, help in C++ program

I have written a C++ program to perform raytracing and would want to write some functions to help the user: examples, usage, help I am wondering how this is done. Would I just put some functions in the main program? (4 Replies)
Discussion started by: kristinu
4 Replies

3. Shell Programming and Scripting

lwp-request examples

Hi; Can i have ne sample examples of of using " lwp-request" in shell script. Is it necessary to have perl installed already in linux box for using this; Thnks; (2 Replies)
Discussion started by: ajaypadvi
2 Replies

4. UNIX for Advanced & Expert Users

Hard Link Examples

Hello, Please move this if I chose the wrong forum category. This question pertains to Unix and Linux I believe. I google the difference between hard and symbolic/soft links and I understand the difference. What I am trying to find is a real example of a hard link being used in a Operating... (11 Replies)
Discussion started by: jaysunn
11 Replies

5. Emergency UNIX and Linux Support

Awk and Sed examples

Hi all, I tried to understand what this awk and sed does but cudnt understand. Can any body explain what awk and sed means with one simple example each and complex examples each with explanation. Thanks in advance. (7 Replies)
Discussion started by: j_panky
7 Replies

6. UNIX for Dummies Questions & Answers

SimpleAWK Examples

Can Anyone please give me some simple AWK Examples to clearly understand the usage and syntax of the command. Thanks (2 Replies)
Discussion started by: unxusr123
2 Replies

7. UNIX for Advanced & Expert Users

Most useful Unix commands and Examples

These commands are placed in the MS Word Doc. with command options and the their respective examples. hope this will help for the beginners. Thanks. Varun Gupta:D (2 Replies)
Discussion started by: varungupta
2 Replies

8. Red Hat

redhat-release examples

I have a script that checks the redhat-release file to determine what security patch needs to be applied. Since there's a Red Hat 5 now, I need a redhat-release file from the various platforms (Desktop, Enteprise Workstation, and Enterprise Server) so I can build a proper search string. Also, it... (5 Replies)
Discussion started by: BOFH
5 Replies

9. Shell Programming and Scripting

need examples?

Can someone give me an example of two shells? (1 Reply)
Discussion started by: wmosley2
1 Replies

10. UNIX for Advanced & Expert Users

looking for .profile examples

I'm looking for some 'well documented' .profile examples (8 Replies)
Discussion started by: JimC
8 Replies
Login or Register to Ask a Question