PS1 to show relitive path


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PS1 to show relitive path
# 1  
Old 07-15-2005
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 > Smilie
# 2  
Old 07-17-2005
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

# 3  
Old 07-20-2005
Thanks that helped a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Show faulty shows PS1 faulty

I plugged both power cables in both power supply. When I unplugged each power cable one by one, the SPARC T4-1 machine keep running. However, show faulty command shows below message. (I have also attached the picture of both power supply) -> show faulty Target ... (1 Reply)
Discussion started by: z_haseeb
1 Replies

2. UNIX for Advanced & Expert Users

Command to see the logical volume path, device mapper path and its corresponding dm device path

Currently I am using this laborious command lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}' Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies

3. UNIX for Dummies Questions & Answers

PS1 directory path not refreshing...

Hi, I am using Unix, I have added below in the .profile to change my prompt value. PS1=`logname`@`hostname`:$PWD# The problem is, after changing the directory, path is not being refreshed. Is there anything wrong? Thanks, Milind (2 Replies)
Discussion started by: mgpatil31
2 Replies

4. Shell Programming and Scripting

How do I get an ls -l to not show the full directory path?

Hey I'm new to the forums here, and I'm seeking help for this script that I'm writing. When I do ls -l of a directory it shows the full pathname for files in it. For example, if the directory is /internet/post/forum/ and the file is topic, it currently shows internet/post/forum/topic. What's the... (3 Replies)
Discussion started by: unity04
3 Replies

5. Programming

DOM query selected path and show as xml

First, I am sorry if this question not this room scope, I have a XML file : file: book.xml <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> ... (3 Replies)
Discussion started by: penyu
3 Replies

6. Solaris

Non-Root mode ... luxadm to show path(s) for Disks

Hi Gurus out there... I am pondering over a situation where I have non-root access (user account), where I am trying to determine paths (including multipaths) on a host. "luxadm display" seems very appropriate, but requires root access. Is there anyway I can get the FC path information? ... (1 Reply)
Discussion started by: verisund
1 Replies

7. UNIX for Dummies Questions & Answers

how to use find commnad to show only path of the result

Hello all say i like to find files i do : find . -name "*.txt" but if i like to find ( and print out ) only the path's where the files are ( the *.txt files ) what can i add to the find command ? (1 Reply)
Discussion started by: umen
1 Replies

8. UNIX for Dummies Questions & Answers

Show path name

Hello I'm new to this forum. So please spare me! I'm using SCO UnixWare 7.1.4 and created a few accounts. So far so good. When I login I see: $. But here I want to see (for example), /home 25$ So I want to see the pathname where I am without each time typing pwd (2 Replies)
Discussion started by: p.vvugt
2 Replies

9. Shell Programming and Scripting

To change PS1 for every one second

I want to change the PS1 prompt with current time. I want the PS1 to update for every one second. I write a Script. PS1='\T' but it updates after i press enter key.I want to update without pressing enter key. can any one help me? (0 Replies)
Discussion started by: lakshmananindia
0 Replies

10. Shell Programming and Scripting

How would I make a find command NOT show the path of a file?

When I do find . -name "*.txt" -size +0 -exec ls {} \; I get something like ./lpi_stdout.txt ./lpi_stderr.txt What would I need to do or pipe it into to strip off those first two characters so I just get lpi_stdout.txt lpi_stderr.txt ? Thanks for the help! (1 Reply)
Discussion started by: LordJezo
1 Replies
Login or Register to Ask a Question