The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics 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 03:07 PM
Developer Tricks: VideoLAN VLC Media Player - Redmond Developer News iBot UNIX and Linux RSS News 0 06-17-2007 06:54 PM
tar tricks neked UNIX for Advanced & Expert Users 2 08-14-2006 03:14 PM
prompt why ? ls1429 UNIX for Dummies Questions & Answers 2 12-13-2001 07:44 AM
'make' problems (compliation problems?) xyyz UNIX for Advanced & Expert Users 5 11-05-2001 10:47 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-26-2007
HybridLogic HybridLogic is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 2
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.
  #2 (permalink)  
Old 09-26-2007
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 699
Hi.

See HOWTO: Change your Shell Prompt ... cheers, drl
  #3 (permalink)  
Old 09-26-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
It makes a big differnce whether you are using csh or tcsh.

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

Join Date: Sep 2007
Posts: 35
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.
  #5 (permalink)  
Old 09-26-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
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.
  #6 (permalink)  
Old 09-26-2007
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 699
Hi.

I find this to be very useful in tcsh with regard to the prompt:
Quote:
%c[[0]n], %.[[0]n]
The trailing component of the current working directory, or
n trailing components if a digit n is given. If n begins
with `0', the number of skipped components precede the
trailing component(s) in the format `/<skipped>trailing'.
If the ellipsis shell variable is set, skipped components
are represented by an ellipsis so the whole becomes
`...trailing'. `~' substitution is done as in `%~' above,
but the `~' component is ignored when counting trailing
components.

-- excerpt from man tcsh
cheers, drl
  #7 (permalink)  
Old 09-26-2007
HybridLogic HybridLogic is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 2
Quote:
Originally Posted by reborg View Post
It makes a big differnce whether you are using csh or tcsh.

Please post the output of "echo $0" ( without quotes )
Looks like tcsh. I didn't have a .tcshrc file, but I made one by copying my .cshrc file.

%c[[0]n], %.[[0]n] didn't help much (I just got the current dir followed by all the extra syntax as a static) but the HOWTO: Change your Shell Prompt really helped with that table at the bottom.

%~ seems to be exactly what I wanted. Thanks all.

Last edited by HybridLogic; 09-26-2007 at 08:25 PM..
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0