The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need couple of ksh tricks please JamesByars Shell Programming and Scripting 4 02-23-2008 11:07 AM
Developer Tricks: VideoLAN VLC Media Player - Redmond Developer News iBot UNIX and Linux RSS News 0 06-17-2007 03:54 PM
tar tricks neked UNIX for Advanced & Expert Users 2 08-14-2006 12:14 PM
prompt why ? ls1429 UNIX for Dummies Questions & Answers 2 12-13-2001 03:44 AM
'make' problems (compliation problems?) xyyz UNIX for Advanced & Expert Users 5 11-05-2001 06:47 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-26-2007
Registered User
 

Join Date: Sep 2007
Posts: 2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Set prompt, problems and tricks

I'm using a csh shell (or, that'd be my guess from the .cshrc file I see) and I'm looking to change my prompt.

There are about 10 other threads, I know, but this question is a little more specific. I want to know, is there a way to list the current directory from a certain level or directory down? That is, I'm using a university's Unix server and I don't need to see
/home/ugrads/myName on every line, but I'd like to see everything from myName/ down (so I know where in my own directories I am).

Is it possible to cut the directory like this? Also, using a command like set prompt = "$PWD Through the Hedge \!% :" seems to set the prompt line to the current directory only. Makes sense, setting it equal to the current value of the PWD variable.

How do I get it to change whenever I change directories?


Links to pre-existing helpful threads appreciated. Thanks.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-26-2007
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 433
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Hi.

See HOWTO: Change your Shell Prompt ... cheers, drl
Reply With Quote
  #3 (permalink)  
Old 09-26-2007
reborg's Avatar
Administrator
 
Join Date: Mar 2005
Location: Ireland
Posts: 3,340
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
It makes a big differnce whether you are using csh or tcsh.

Please post the output of "echo $0" ( without quotes )
Reply With Quote
  #4 (permalink)  
Old 09-26-2007
tomas's Avatar
Registered User
 

Join Date: Sep 2007
Posts: 35
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
This is an ugly way to do it.

VAR0=`echo $HOME | cut -f3 -d'/'`
VAR1=`echo $HOME | wc -c`
VAR2=`pwd | cut -c${VAR1}-`
echo ${VAR0}${VAR2}

But it will give you the desired output.

I wouldn't use this example because if you go below your $HOME path it doesn't show anything.
Reply With Quote
  #5 (permalink)  
Old 09-26-2007
reborg's Avatar
Administrator
 
Join Date: Mar 2005
Location: Ireland
Posts: 3,340
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
And in csh what will happen if this is used for a prompt is that the pormpt will have a fixed value and not be updated when the directory is changed.

See my post in the FAQ for what needs to be done to get the prompt to update dynamically, on the other hand in tcsh %~ would be an option to explore.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 09:15 PM.


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

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102