Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help w/ SED

Status
Not open for further replies.

Speeddy

ISP
Nov 11, 2002
2
US
Ok, I have a shell on a friend's OpenBSD box, and the default prompt (env var PS1) is bash-2.05$ I made the hack in the .bash_profile to get it to show:

"[username@hostname $PWD]$ "

like linux does, but since I am not at home right now, I dont have access to the Linux .bash_profile so I cant just copy the parameter over to his box. I need to know what the sed command would be to get it to remove all but the actual current directory name from $PWD

i.e. if i am in /home/speeddy/wine then i would like it to show me:

"[speeddy@onering wine]$ "
or if i am in /home i would like it to show me
"[speeddy@onering /home]$ "

etc... If anyone knows this or can think of how to do it, please email me

Speeddymon(NoSpAm)@yahoo.com

or reply here and hopefully it goes to my email since i checked the email notification checkbox ;)

-Speeddy
 
I don't believe you need SED to do this and this isn't a hack. It's an advertised feature of bash. Just add the following to your .bash_profile...

[tt] PS1="[\u@\h \w]\$ "[/tt]
 
Hi,

If you really want sed to do the job, try

pwd | sed -e 's!/.*/\(.*\)!\1!'
 
Cool, thanks guys. I didnt even think about the escaped chars being used as a prompt, guess I should have rtfm'd a little harder... ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top