The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to use find commnad to show only path of the result umen UNIX for Dummies Questions & Answers 1 02-05-2008 12:22 AM
Secondary groups show in groups but don't show in id (Not working) zen03 HP-UX 4 12-31-2007 08:15 AM
Show path name p.vvugt UNIX for Dummies Questions & Answers 2 12-19-2007 02:11 AM
vi - replacing a relative path with absolute path in a file Yinzer955i UNIX for Dummies Questions & Answers 2 09-07-2006 08:47 AM
How would I make a find command NOT show the path of a file? LordJezo Shell Programming and Scripting 1 10-01-2004 03:01 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-15-2005
Registered User
 

Join Date: Aug 2001
Location: Cape Town,South Africa
Posts: 41
PS1 to show relitive path

Hi I am trying to format my prompt in a KSH to show the relative path
currently it is PS1='$PWD >' /home/users/dir/dir/dir >
I want to display it as /home/users/.../.../dir >
Reply With Quote
Forum Sponsor
  #2  
Old 07-17-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
You can have fun with your PS1 prompt by creating a function which changes PS1 each time you change directory, e.g...
Code:
function ncd {
   cd "$*"
   PS1=$(echo $PWD|sed 's!\([^/]\)[^/]\{4,\}/!\1../!g')' :> '
}
alias cd=ncd
Reply With Quote
  #3  
Old 07-20-2005
Registered User
 

Join Date: Aug 2001
Location: Cape Town,South Africa
Posts: 41
Thanks that helped a lot
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0