set prompt in sh


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers set prompt in sh
# 15  
Old 03-25-2003
Check this out: http://www.unixguide.net/unix/faq/2.4.shtml

Bourne Shell (sh):

If you have a newer version of the Bourne Shell (SVR2 or newer)
you can use a shell function to make your own command, "xcd" say:

xcd() { cd $* ; PS1="`pwd` $ "; }

If you have an older Bourne shell, it's complicated but not
impossible. Here's one way. Add this to your .profile file:

LOGIN_SHELL=$$ export LOGIN_SHELL
CMDFILE=/tmp/cd.$$ export CMDFILE
# 16 is SIGURG, pick a signal that's not likely to be used
PROMPTSIG=16 export PROMPTSIG
trap '. $CMDFILE' $PROMPTSIG

and then put this executable script (without the indentation!),
let's call it "xcd", somewhere in your PATH

: xcd directory - change directory and set prompt
: by signalling the login shell to read a command file
cat >${CMDFILE?"not set"} < cd $1
PS1="\`pwd\`$ "
EOF
kill -${PROMPTSIG?"not set"} ${LOGIN_SHELL?"not set"}

Now change directories with "xcd /some/dir".
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Unable to move from rsc prompt to ok prompt

Hi, on sunfire v890 unable to move from rsc prompt to ok prompt, i have executed the command break. (9 Replies)
Discussion started by: manoj.solaris
9 Replies

2. UNIX for Dummies Questions & Answers

How to Change the % prompt to - prompt in UNIX?

how to Change the % prompt to - prompt in unix :wall: ---------- Post updated at 07:40 AM ---------- Previous update was at 07:38 AM ---------- How To display the last modification time of any file in unix ---------- Post updated at 07:40 AM ---------- Previous update was at 07:40 AM... (2 Replies)
Discussion started by: manjiri sawant
2 Replies

3. HP-UX

Unable to Set Prompt to current working DIR

HPUX does not recognise \h,\w,\u to display the hostname,working directory and username respectively. So how do i set the PS1 variable to display my current working Directory as my prompt? I also tried PS1=$PWD, But it keeps showing the same directory path as prompt which PWD was holding at... (3 Replies)
Discussion started by: Amit Kulkarni
3 Replies

4. UNIX for Dummies Questions & Answers

set prompt = pwd

Assume that you want to set your prompt to display the current working directory followed by a percent symbol and then a space. The command pwd can be used to display this information, so explain why the following command does not have the expected result: set prompt=" `pwd`'%' " Its a... (7 Replies)
Discussion started by: Blockshelf
7 Replies

5. Shell Programming and Scripting

tcsh/csh: set prompt in production to color red

Hi folks This is our prompt at the moment oracle@pinkipinki:/opt/oracle> grep 'set prompt' .cshrc set prompt = "$user@`uname -n`:$cwd> " We wish to have in production the same prompt, but red. Howto do that? I tried a lot a internet manuals, but it doesn't work. (1 Reply)
Discussion started by: slashdotweenie
1 Replies

6. Shell Programming and Scripting

CWD in prompt only showing the directory when set

Hi Gurus, I am working in tcsh and i set the prompt with this. set prompt = "$cwd>" But I see teh prompt only gets reflected with the directory where I set the prompt. After i cd to another directory it still shows the old directory. Please advise (1 Reply)
Discussion started by: kinny
1 Replies

7. Shell Programming and Scripting

set timeout for ssh prompt

Hi all, I want to set a timeout say 10 sec to shh prompt i.e. if no password is enetered for 10 sec prompt should again come to shell. How can this be achieved ?? I am using Linux RHEL 5 and Solaris 10. Pls help. Thanks in adv. VIKAS (3 Replies)
Discussion started by: vikas027
3 Replies

8. UNIX for Dummies Questions & Answers

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... (6 Replies)
Discussion started by: HybridLogic
6 Replies

9. UNIX for Advanced & Expert Users

"Set prompt"

Hi Currently amending my bash profiles, there is a command that makes my session jump into another location. I just wonder if I could pre-define my prompt to begin with "cd " from this location (in order to navigate further into sub-directories). Is there any way of doing that? An important thing... (0 Replies)
Discussion started by: Indalecio
0 Replies

10. UNIX for Dummies Questions & Answers

kill, set prompt

ok, there is a way to nicely kill a suspended job and to terminate another without using the mass -KILL command. also, how can I set my prompt temporarly without using the .bash_profile that uses the PS1. Thanks:) (1 Reply)
Discussion started by: bitwize
1 Replies
Login or Register to Ask a Question
XTELL(1)						      General Commands Manual							  XTELL(1)

NAME
xtell - sends a message to another computer running xtelld SYNOPSIS
xtell [-v] [user[:tty][@host[:port]]] [message] write user [tty] DESCRIPTION
How to use it: suppose you want to send a message to user gubas on computer trener.fsport.uniba.sk Just type: prompt:~% xtell gubas@trener.fsport.uniba.sk Hi To send multiple lines long message to user 7tokarova at computer pascal.fmph.uniba.sk, type prompt:~% xtell 7tokarova@pascal.fmph.uniba.sk Hi How are you today Please answer ^D in this case, finish sending messages with EOF (CTRL D) If you want to send message to user holik on local computer, you can do it either by typing: prompt:~% xtell holik@localhost Hi or simply: prompt:~% xtell holik Hi To send message to certain tty, append the tty to username, separated by colon: prompt:~% xtell stanys:ttyp2@reaktor.ip.fmph.uniba.sk 'Sveikas Tomai' will send message 'Sveikas Tomai' to user stanys on ttyp2 at computer reaktor.ip.fmph.uniba.sk To specify other port than the default 4224, append the port to computer name, separated by colon: prompt:~% xtell bosa@radon.dnp.fmph.uniba.sk:4000 'Ahoj' assumes the xtell daemon runs at computer radon on port 4000, and sends the message 'Ahoj' to user bosa. Option -v turns verbose mode on. Xtell will then display some messgaes about connecting, which is usefull especially when the connection is slow. Example: prompt:~% xtell -v rybar@dmpc.dbp.fmph.uniba.sk xtell invoked without parameters will ask user for username and host to send the message to. If the user has created in his/her/its home directory the file .xtell-log, and the file is writable by nobody, all messages will be written to this file as well as to the screen (handy when the screen is overwritten and you could not see the message). xtell checks the environmental variable XTELLPROMPT. If it exists, it is used as prompt for messages. Last notice: if you do not think zsh is the best shell, (besides doing a mistake) replace prompt:~% in above text with prompt:~$ or what- ever :-) AUTHOR
Radovan Garabik (garabik@melkor.dnp.fmph.uniba.sk) SEE ALSO
xtelld(8), write(1), talk(1), talkd(8), tty(1) BUGS
What happens to .xtell-log when two messages arrive simultaneously? There is no locking implemented. XTELL(1)