![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing a variable inside a variable to a function | KingVikram | UNIX for Dummies Questions & Answers | 2 | 01-14-2008 08:28 PM |
| Simple to you not simple to me pattern matchin help | aleks001 | Shell Programming and Scripting | 0 | 07-22-2007 11:06 PM |
| Simple C question... Hopefully it's simple | Xeed | High Level Programming | 6 | 12-15-2006 02:29 PM |
| Ok simple question for simple knowledge... | Corrail | UNIX for Dummies Questions & Answers | 1 | 11-28-2005 01:03 PM |
| Very simple question about changing PS1 variable at startup! | abidmalik | UNIX for Dummies Questions & Answers | 2 | 08-26-2002 02:05 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
simple SH variable
Greetz all, I'm using OBSD 2.9 with /bin/sh as my shell. I want to modify the SH prompt to reflect my current working directory. I'm new to shell programming, so pardon if I'm going about things wrong ![]() I thought I'd be able to do it with the following line: Code:
PS1="`pwd`# " but of course, that leaves the prompt as my home directory when I log in and remains so even when I change directories. Can someone point me to the right way to have my SH prompt update the CWD everytime I CD into a new one? |
|
||||
|
sorry for the quirkiness, but I should revise this question. How does one set the prompt to read as follows? <username>@<hostname>:<current_working_directory># for instance, Code:
user@host:/user$ I would also allow the shell to show a hash (#) when root is logged in and a $ when a regular user logs in. I thought I had it figured out before, but I didn't. |
|
||||
|
Hi,
Hope this would help you. Try to set the PS1 in ~/.shrc or you can type it (not automatic). ----------------------- PS1=$'\\u@\\h:\\w\\$ ' ----------------------- should be working, and it will show you (for example): ----------------------- sh-2.05# PS1=$'\\u@\\h:\\w\\$ ' root@negative:~# cd data root@negative:~/data# ----------------------- |
|
||||
|
no go.
when I enter that in (actually in my .profile file in ~), the prompt comes out reading: \u@\h:\w$ not correct, of course. What I have entered in the variable as follows: PS1='\\u@\\h:\\w:$ ' export PS1 and also exacltly as you had shown in your reply. Is it possible it's a different systax for Bourne used under OpenBSD? |
|
||||
|
Im using OpenBSD and i put a "nice" Prompt:
---- PS1='\[\e[1;30m\][\[\e[0;35m\]\t\[\e[1;30m\]]\[\e[1;36m\]\u\[\e[1;30m\]@\[\e[0;36m\]\h\[\e[1;30m\]:\[\e[0;37m\]\w\[\e[1;30m\]\$\[\e[0;37m\] ' ---- just for not getting bored with BLACK & WHITE prompt :) |
|
||||
|
eh.. I have to ask, which shell are you using? I am using /bin/sh and even copying the variable as you set it ( PS1='\[\e[1;30m\][\[\e[0;35m\]\t\[\e[1;30m\]]\[\e[1;36m\]\u\[\e[1;30m\]@\[\e[0;36m\]\h\[\e[1;30m\]:\[\e[0;37m\]\w\[\e[1;30m\]\$\[0;37m\]' )
only makes my command... exactly that. can someone refer a tutorial that goes over this? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|