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 30th March 2009
bsdnewbie999 bsdnewbie999 is offline
Package Pilot
 
Join Date: May 2008
Posts: 145
Default changing custom prompt ksh for root.

How to edit custom ksh prompt for root? I have already done for normal user but cann't figure out for root..

i added the following line to .profile

export PS1='$PWD>'
Reply With Quote
  #2   (View Single Post)  
Old 30th March 2009
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by bsdnewbie999 View Post
How to edit custom ksh prompt for root?
  • ~/.profile is for each user.
  • /root/.profile is for the superuser.
A better strategy is to configure & use sudo(8).

I'm not finding where it was stated, but I recall that it was Nick Holland (who maintains a large portion of the official FAQ...) who said that needing to customize the root prompt shows an unnecessary dependence upon the root account. This can potentially lead to catastrophic mistakes (Everyone makes mistakes; just don't do them while logged in as root...) which would be circumvented by using sudo(8).

sudo(8) can be your friend. Begin by studying its manpage.

Last edited by ocicat; 30th March 2009 at 05:24 AM.
Reply With Quote
  #3   (View Single Post)  
Old 30th March 2009
Loki Loki is offline
Port Guard
 
Join Date: Nov 2008
Location: Sydney
Posts: 11
Wink And I change ALL prompts

I use the following:

export PS1='\e[0;31m[\h:\w]\n\$ \e[m'
in root's .profile and
export PS1='\e[0;36m[\h:\w]\n\$ \e[m'
for everybody else.

Then if I really need to do lots of rootly stuff I do:
sudo su -
and end up with a red warning that I have not left root (yeah, I know the prompt is # but a red prompt sticks out like dogs balls.

Whatever floats your boat, I guess.
Reply With Quote
  #4   (View Single Post)  
Old 30th March 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

terminal and shell supporting, good idea Loki.

(I usually use user@host-$ and #, where $ is colour coded to the shell; so I know just a simple '#' means the big charlie)
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #5   (View Single Post)  
Old 31st March 2009
bsdnewbie999 bsdnewbie999 is offline
Package Pilot
 
Join Date: May 2008
Posts: 145
Default

How do i enable this line for user? i added this line to .profile but it only works for root why not normal users? In normal user prompts it shows \e[0;36m[\h:\w]\n\$ \e[m instead of the colour one.
export PS1='\e[0;36m[\h:\w]\n\$ \e[m'
Reply With Quote
  #6   (View Single Post)  
Old 31st March 2009
Loki Loki is offline
Port Guard
 
Join Date: Nov 2008
Location: Sydney
Posts: 11
Wink

Quote:
Originally Posted by bsdnewbie999 View Post
How do i enable this line for user? i added this line to .profile but it only works for root why not normal users? In normal user prompts it shows \e[0;36m[\h:\w]\n\$ \e[m instead of the colour one.
export PS1='\e[0;36m[\h:\w]\n\$ \e[m'
What does:
echo $TERM
give you as a non-root user?

If it isn't VT220 or similar it cannot interpret the DEC colour commands.
Reply With Quote
  #7   (View Single Post)  
Old 31st March 2009
bsdnewbie999 bsdnewbie999 is offline
Package Pilot
 
Join Date: May 2008
Posts: 145
Default

echo $TERM give me xterm

the code actually works for root account but not normal user..
Reply With Quote
  #8   (View Single Post)  
Old 1st April 2009
Loki Loki is offline
Port Guard
 
Join Date: Nov 2008
Location: Sydney
Posts: 11
Default

Quote:
Originally Posted by bsdnewbie999 View Post
echo $TERM give me xterm

the code actually works for root account but not normal user..
There is some glitch somewhere in $user's .profile, most likely.
What I gave you works here even with xterm.

Easy mistakes we all have made sometime:
' at one end " at other (I forget if that growls at you in PS1 setting)
leaving out a quote or having a space in there where it should not be
some other tyop

Otherwise you have me beat. I've been using it for years without problems.
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
Nicer Prompt with ksh on 5.0 nihonto NetBSD Installation and Upgrading 8 12th October 2009 08:49 PM
Exec command in zsh prompt? bsddaemon General software and network 2 18th October 2008 09:37 PM
About Custom Kernels qmemo NetBSD General 2 28th September 2008 03:45 PM
Utility to make FreeBSD custom ISO mtx FreeBSD General 5 9th June 2008 11:13 PM
what to do at mountroot prompt? Sunsawe FreeBSD General 13 5th June 2008 08:06 AM


All times are GMT. The time now is 08:39 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