ash@a.cs.okstate.edu (Ashok Rathi) (08/06/88)
Is it possible to make echo " " a part of the unix prompt? My objective is to print a blank line before a prompt to improve clarity of the output from the previous unix command. The example follows: % % ls <output of "ls" command> % <blank line> % <now cursor is here> Will appreciate the response. Thanks! -- Ashok
ilham@athena.mit.edu (Ilhamuddin Ahmed) (08/08/88)
In article <3809@okstate.UUCP> Ashok writes > >Is it possible to make echo " " a part of the unix prompt? My objective >is to print a blank line before a prompt to improve clarity of the output >from the previous unix command. The example follows: > % > % ls > <output of "ls" command> > % <blank line> > % <now cursor is here> > >Will appreciate the response. Thanks! -- Ashok If you are using csh or tcsh then you can simply do this by adding the following in your .cshrc (or .tcshrc) or by manually typing it in [Ugh :-] set prompt = "% \ % " Please note that there is no space after the '\'. This way, you can have multiple-line prompts. - Ilham ============================================================================== \\\!/// From : Ilhamuddin Ahmed [MIT '91] _ _ UUCP : {backbone}!mit-eddie!athena!ilham ( Q Q ) Arpa : ilham@juicy-juice.lcs.mit.edu ---,,,,-------U-------,,,,--- USnail: MIT Laboratory for Computer Science 545 Technology Square, Room 213 HELLO!!! Cambridge, MA 02139. ----------------------------- Phone : (617)-253-3578 ==============================================================================
wnp@dcs.UUCP (Wolf N. Paul) (08/08/88)
In article <3809@okstate.UUCP> ash@a.cs.okstate.edu (Ashok Rathi) writes: > >Is it possible to make echo " " a part of the unix prompt? My objective >is to print a blank line before a prompt to improve clarity of the output >from the previous unix command. The example follows: Your example suggests that you are using the C Shell (csh). Here is a way to set your prompt appropriately, first for the C Shell: set prompt="\ $USER:\!> " This will generate a prompt that begins with a blank line (as you asked for) and then prints the user's login name and the csh history number followed by a "less-than" sign. Note that the newline which is to be part of the prompt needs to be quoted with a backslash in the C Shell. All of this should go into your .login file if you want it only in your login shell, or in .cshrc if you want it in subshells as well. Here is an example for the Bourne Shell, which needs to go into your .profile: PS1=" $USER> " ; export PS1 This will generate a similar prompt to the above; if you do this on System V Release 2 (and maybe earlier) substitute "$LOGNAME" for "$USER". Of course, being Bourne Shell, it has no history number, and note that you do not have to quote the newline. The "export" statement ensures that you will get this same prompt in sub-shells, such as those spawned from within vi. If you have the Korn Shell, use the Bourne example, but make that "$USER:!> " instead -- the Korn Shell has history, and does not want the exclamation point escaped. Of course some people don't want their login name in their prompt, but instead the current directory -- this has been discussed endlessly a few months ago, and I am not going to re-start this discussion. -- Wolf N. Paul * 3387 Sam Rayburn Run * Carrollton TX 75007 * (214) 306-9101 UUCP: killer!dcs!wnp ESL: 62832882 DOMAIN: wnp%dcs@killer.dallas.tx.us TLX: 910-380-0585 EES PLANO UD
rogers@ofc.Columbia.NCR.COM (H. L. Rogers) (08/09/88)
In article <6591@bloom-beacon.MIT.EDU> ilham@athena.mit.edu (Ilhamuddin Ahmed) writes: >In article <3809@okstate.UUCP> Ashok writes >> >>Is it possible to make echo " " a part of the unix prompt? My objective > >set prompt = "% \ >% " For /bin/sh, put following in $HOME/.profile: PS1=" prompt string" Output will look like this: [output of ls command] prompt string -- HL Rogers (hl.rogers@ncrcae.Columbia.NCR.COM)
spenser@ficc.UUCP (spenser aden) (08/09/88)
In article <6591@bloom-beacon.MIT.EDU>, ilham@athena.mit.edu (Ilhamuddin Ahmed) writes: | In article <3809@okstate.UUCP> Ashok writes | > | >My objective | >is to print a blank line before a prompt to improve clarity of the output | >from the previous unix command. The example follows: | > % ls | > <output of "ls" command> | > % <blank line> | > % <now cursor is here> | > | >Will appreciate the response. Thanks! -- Ashok | | If you are using csh or tcsh then you can simply do this by adding the | following in your .cshrc (or .tcshrc) or by manually typing it in | [Ugh :-] | | set prompt = "% \ | % " | | Please note that there is no space after the '\'. This way, you can have | multiple-line prompts. This is interesting, and I would like to do something similar on my XENIX 386 machine, but I've got a problem. I'd like to display the current directory on the firrst line, and the csh history counter on the second line at the prompt. Something like : /usr2/spenser/bin (15) _ In order to do this, I have to alias 'cd'. I've tried this (and a few derivations of) in my .cshrc : alias cd 'cd \!* ; set prompt="[=5h"`pwd`"[=5l \ (\!) " ' # set prompt string (If this is hard to read, I have "<esc>[=5h" and "<esc>[=5l" around the `pwd`) And I have this 'set prompt' command by itself in my .login. The escape sequence simply places the directory name in half intensity. This works fine when I first login and until I try to 'cd' to any directory, but when I try to 'cd' it says 'Unmatched "."' and the 'cd' fails. I suspect that it's not able to carry the alias over to the second line using the \ method spelled out in the previous article, but how does one get an alias definition of this sort to span two lines? Sorry, I've tried to RTFM, but I can't find 'alias' in the reference manual my company has provided me. -- S. Spenser Aden - Ferranti International Controls Corporation - PO Box 5012 Sugar Land, TX. 77487 ------ (713)274-5000 ------ tness1!sugar!ficc!spenser Any opinions expressed above, unless explicitly denoted, are mine alone and do not reflect those of my employer. My wife won't claim them either ...
ron@topaz.rutgers.edu (Ron Natalie) (08/09/88)
If you're using the real shell, then you can do PS1=`promptprog` where promptprog is a program that generates the new prompt. For example PS1=`cat << END_CAT $ $ END_CAT` Will double up dollar sign prompts. -Ron
chris@mimsy.UUCP (Chris Torek) (08/10/88)
In article <1236@ficc.UUCP> spenser@ficc.UUCP (spenser aden) writes: >alias cd 'cd \!* ; set prompt="<stuff>"`pwd`"<stuff> \ >(\!) " ' # set prompt string (The <stuff>s are ESC [ = 5 h and ESC [ = 5 l, but ESC characters disappear over USENET. Good thing too. :-/ ) >... This works fine when I first login and until I try to 'cd' to >any directory, but when I try to 'cd' it says 'Unmatched "."' and the >'cd' fails. I suspect that it's not able to carry the alias over to >the second line using the \ method spelled out in the previous article .... The solution for about half the problems with the C shell is the same: Use more \ characters. You have to write alias cd 'cd \!* ; set ... \\ ... ' so that the alias itself has one \ in it. Some years ago, Fred Blonder and I were experimenting with working- directory prompts. The regular sorts of wd prompts were not hard, but we wanted to get `~' compression, so that one would see, e.g., [~] ==> cd /tmp [/tmp] ==> cd [~] ==> cd foo/bar [~/foo/bar] ==> cd baz [~/foo/bar/baz] ==> Unfortunately, csh insisted on expanding the `~' whenever we ran the output of `dirs' through awk to get the first string. Quoting helped: here is what we came up with (his version): alias set_prompt 'set prompt = '"'"'['"'"'"`dirs|awk '"'"'{print "\$1"}'"'"'`"'"'"'] ==> '"'"'' alias cd '\!:0-$; set_prompt' alias pushd '\!:0-$; set_prompt' alias popd '\!:0-$; set_prompt' set_prompt After some thought, I reduced this (after changing the style) to alias set_prompt 'set prompt="[\\!] `dirs|awk '\''{print "\$1"}'\''` "' alias cd 'cd \!*; set_prompt' alias pushd 'pushd \!*; set_prompt' alias popd 'popd \!*; set_prompt' set_prompt Of course, for faster operation, one can write set prompt=(`dirs`) but again csh insists on expanding `~'.... -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
wnp@dcs.UUCP (Wolf N. Paul) (08/10/88)
In article <1236@ficc.UUCP> spenser@ficc.UUCP (spenser aden) writes: >In order to do this, I have to alias 'cd'. I've tried this (and a few >derivations of) in my .cshrc : > >alias cd 'cd \!* ; set prompt="[=5h"`pwd`"[=5l \ >(\!) " ' # set prompt string > >And I have this 'set prompt' command by itself in my .login. The escape >sequence simply places the directory name in half intensity. This works fine >when I first login and until I try to 'cd' to any directory, but when I try >to 'cd' it says 'Unmatched "."' and the 'cd' fails. I suspect that it's not >able to carry the alias over to the second line using the \ method spelled >out in the previous article, but how does one get an alias definition of this >sort to span two lines? Sorry, I've tried to RTFM, but I can't find 'alias' in >the reference manual my company has provided me. 1. ALIAS is explained (not as well as it could be) in the manual entry for CSH, it does not have an entry of its own. 2. No, csh does not like a newline (even disguised, escaped or quoted) in an alias definition. Try the following: File ~/.setprompt: set prompt="\ =5h`pwd`=5l\ (\!) " Alias line in file ~/.cshrc: (If it is in .login, effective only for login shell; if in .cshrc, effective for sub-shells as well) alias cd 'cd \!* ; source ~/.setprompt' This method effectively REMOVES the newline from the alias definition. -- Wolf N. Paul * 3387 Sam Rayburn Run * Carrollton TX 75007 * (214) 306-9101 UUCP: killer!dcs!wnp ESL: 62832882 DOMAIN: wnp%dcs@killer.dallas.tx.us TLX: 910-380-0585 EES PLANO UD
maart@cs.vu.nl (Maarten Litmaath) (08/11/88)
In article <1236@ficc.UUCP> spenser@ficc.UUCP (spenser aden) writes:
\This is interesting, and I would like to do something similar on my XENIX 386
\machine, but I've got a problem. I'd like to display the current directory
\on the firrst line, and the csh history counter on the second line at the
\prompt. Something like :
\
\/usr2/spenser/bin
\(15) _
\
\In order to do this, I have to alias 'cd'. I've tried this (and a few
\derivations of) in my .cshrc :
\
\alias cd 'cd \!* ; set prompt="[=5h"`pwd`"[=5l \
\(\!) " ' # set prompt string
Try:
alias cd 'cd \!*; set prompt="<esc>[=5h`pwd`<esc>[=5l\\
(\\!) "'
Notice: the newline and the second ! have to be escaped twice, once on setting
the alias and once on executing it.
BTW, it's a nice prompt indeed.
--
If you enjoyed the recent heat wave, |Maarten Litmaath @ Free U Amsterdam:
you'll certainly like the ozone gap...|maart@cs.vu.nl, mcvax!botter!maart
greim@sbsvax.UUCP (Michael Greim) (08/11/88)
In article <1236@ficc.UUCP>, spenser@ficc.UUCP (spenser aden) writes: ... stuff deleted ... > This is interesting, and I would like to do something similar on my XENIX 386 > machine, but I've got a problem. I'd like to display the current directory > on the firrst line, and the csh history counter on the second line at the > prompt. Something like : > > /usr2/spenser/bin > (15) _ > > In order to do this, I have to alias 'cd'. I've tried this (and a few > derivations of) in my .cshrc : > > alias cd 'cd \!* ; set prompt="[=5h"`pwd`"[=5l \ > (\!) " ' # set prompt string > > (If this is hard to read, I have "<esc>[=5h" and "<esc>[=5l" around the `pwd`) > And I have this 'set prompt' command by itself in my .login. The escape > sequence simply places the directory name in half intensity. This works fine > when I first login and until I try to 'cd' to any directory, but when I try > to 'cd' it says 'Unmatched "."' and the 'cd' fails. I suspect that it's not > able to carry the alias over to the second line using the \ method spelled > out in the previous article, but how does one get an alias definition of this > sort to span two lines? Sorry, I've tried to RTFM, but I can't find 'alias' in > the reference manual my company has provided me. My prompt looks like this: (the things between the dotted lines) ------- sbsvax::/RW/usr/greim/NEWS (3) % ------- Note the blank line. In my .login there is: set prompt="\ `/bin/hostname`::$cwd \ (\!) % " In my .cshrc there is : set my_host=`/bin/hostname` alias cd 'cd \!*; set prompt="\\ ${my_host}::$cwd \\ (\\!) % "' alias pushd 'pushd \!*; set prompt="\\ ${my_host}::$cwd \\ (\\!) % "' alias popd 'popd \!*; set prompt="\\ ${my_host}::$cwd \\ (\\!) % "' set prompt="\ ${my_host}::$cwd \ (\!) % " You need to set the prompt in .cshrc in case you are calling script or any other program which resets the value of prompt and then calls csh. Absorb, apply and enjoy, -mg -- +------------------------------------------------------------------------------+ | UUCP: ...!uunet!unido!sbsvax!greim | Michael T. Greim | | or greim@sbsvax.UUCP | Universitaet des Saarlandes | | CSNET: greim%sbsvax.uucp@Germany.CSnet| FB 10 - Informatik (Dept. of CS) | | ARPA: greim%sbsvax.uucp@uunet.UU.NET | Bau 36, Im Stadtwald 15 | | Phone: +49 681 302 2434 | D-6600 Saarbruecken 11, West Germany | +------------------------------------------------------------------------------+ | # include <disclaimers/std.h> | +------------------------------------------------------------------------------+
maart@cs.vu.nl (Maarten Litmaath) (08/12/88)
In article <166@dcs.UUCP> wnp@dcs.UUCP (Wolf N. Paul) writes:
\2. No, csh does not like a newline (even disguised, escaped or quoted) in an
\ alias definition. Try the following:
Not true: you just have to escape it twice.
See my previous posting on this subject.
--
If you enjoyed the recent heat wave, |Maarten Litmaath @ Free U Amsterdam:
you'll certainly like the ozone gap...|maart@cs.vu.nl, mcvax!botter!maart