DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 20th February 2012
s2scott's Avatar
s2scott s2scott is offline
Package Pilot
 
Join Date: May 2008
Location: Toronto, Ontario Canada
Posts: 198
Default PS1 command line prompt AFTER su

As established in the /etc/profile, I have the following 'PS1' custom prompt:

Code:
PSGreen() {
print "\[\033[00;32m\]"
}
PSRestore() {
print "\[\033[01;00m\]"
}
export PS1='$(PSGreen)\u@\h/\w\$(PSRestore) \$ '
It works great for user login and root login; however, it does NOT appear to run (or to be of any affect) if at the command line post 'su'

Does anyone know which 'profile' or '.profile' is invoked when 'su' is run and where I should place this script fragment? (I have tried /root/.profile and several others.)

With thanks,
/S
__________________
Never argue with an idiot. They will bring you down to their level and beat you with experience.
Reply With Quote
  #2   (View Single Post)  
Old 20th February 2012
daemonfowl daemonfowl is offline
bsdstudent
 
Join Date: Jan 2012
Location: DaemonLand
Posts: 834
Default

Hi ! I put it right away in my ~/.profile .. it works for user & root except that with root it's full light green without gls colors but this because root .profile doesn't contai that .. maybe I didn't understand your point here ..

Thanks for this nice gift !! .. a peaceful light green which reminds of the Netbsd.macppc fg color ..
Reply With Quote
  #3   (View Single Post)  
Old 21st February 2012
s2scott's Avatar
s2scott s2scott is offline
Package Pilot
 
Join Date: May 2008
Location: Toronto, Ontario Canada
Posts: 198
Default

okay...

Code:
scott@myhost/~ # su<cr>
Password:
$
the su(1) shell fails to receive the custom PS1 environment variable in the spawned su(1) shell.

Whereas,
Code:
scott@myhost/~ # su - <cr>
Password:
root@myhost/~ $
correctly exports my custom PS1 ('\u@\h/\w\$ ' in green) and other environment variables to the spawned su(1) shell.

I don't know if this (typing the "-") is the best/right answer. Any expertise in the matter welcomed! I'd still like to know what shell script is controlling the entry to su(1).

Cheers,
/S
__________________
Never argue with an idiot. They will bring you down to their level and beat you with experience.
Reply With Quote
  #4   (View Single Post)  
Old 21st February 2012
s2scott's Avatar
s2scott s2scott is offline
Package Pilot
 
Join Date: May 2008
Location: Toronto, Ontario Canada
Posts: 198
Default

Quote:
Originally Posted by daemonfowl View Post
Thanks for this nice gift !! .. a peaceful light green which reminds of the Netbsd.macppc fg color ..
The other color, foreground, background and blink escape code sequences are found variously on google, but here's one link to digest.

http://wiki.bash-hackers.org/scripting/terminalcodes

You may also use tput(1). For example,
Code:
export PS1="\[$(tput setaf 3)\]\u@\h:\w \$ \[$(tput sgr0)\]"
is functionally the same as my script fragment.

tput(1) may be a little easier to use if you're combining FG & BG and other visual attribute.

Knock yourself out!

/S
__________________
Never argue with an idiot. They will bring you down to their level and beat you with experience.
Reply With Quote
  #5   (View Single Post)  
Old 21st February 2012
daemonfowl daemonfowl is offline
bsdstudent
 
Join Date: Jan 2012
Location: DaemonLand
Posts: 834
Default

Thank you very much for the link and for the interesting website as well .. I'm browsing those bash treasures .. a second shelldorado .. ;-)
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to begin with GUI as a frontend for command line? Daffy General software and network 9 12th August 2011 03:41 AM
command-line-fu (digg like site with UNIX commands) vermaden Guides 3 13th March 2009 03:56 PM
avidemux2 command line roddierod FreeBSD General 1 10th November 2008 08:27 PM
Exec command in zsh prompt? bsddaemon General software and network 2 18th October 2008 09:37 PM
OSS , playing a sound via command line.. scotsman FreeBSD General 7 29th August 2008 08:01 PM


All times are GMT. The time now is 08:33 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick