It is currently Sat, 05 Dec 2020 12:17:16 GMT



 
Author Message
 flexible prompt in shells via shell-script
Hello knowing people :-)))

I'm a newuser under UNIX and I must to install and configure a
unix "derivative" (LynxOS).

At the moment I have the problem to realize a flexible prompt
in a shell-script. The prompt should indicate a complete actua-
lized path name whenever directories are changed, like

/usr/users/653129:>cd ..
/usr/users:>

I've set up the prompt variable PS1 with pwd, but I have no
idea to do this continuous in background :-(

Is there anybody who has written anytimes a shell-script for
this and can tell me via mail?

Thanks a lot :-)))))))

Andreas Gulden
653...@rz.fht-esslingen.de



 Tue, 28 Jul 1998 03:00:00 GMT   
 flexible prompt in shells via shell-script
In article <4fgepa$...@news.BelWue.DE>,

What shell is it?  You can't do it on Bourne shell, in some others you
can write an alias for "cd", others have a built in means of putting the
directory in the prompt.
man $SHELL



 Wed, 29 Jul 1998 03:00:00 GMT   
 flexible prompt in shells via shell-script
In article <4fgepa$...@news.BelWue.DE>, 653...@rhds17.rz.fht-esslingen.de

Here's the quick answer:

1). Set your shell to the Korn Shell (ksh). It is a superset of the Bourne
Shell, so any Borne Shell script will work in Korn Shell. Plus Korn Shell
has a real nice command editing facility.

2). Set PS1 equal to "\$PWD> ". This will do exactly what you want.

If you want something fancier, you can create a command alias and a
function to replace the cd command with your own version. Here's mine (in
my .kshrc file):

#
#   ####Redefine cd function to allow prompt to show $PWD
#

function _cd
{
        \cd $1
        dir=${PWD#$HOME}
        [ "$dir" != "$PWD" ] && dir="~${dir}"
        [ "$dir" = "~" ] && dir="~$(id -un)"
        export PS1="$(id -un):$dir> "
alias cd=_cd

cd .

The first line does the "cd" to the directory. The second line removes my
$HOME from the directory path. The third adds "~/" to the front of the
prompt if the directory is a subdirectory of my $HOME directory. The
fourth line makes the directory name "~davidw" if I am in my $HOME
directory. My prompt looks like this:

davidw:~david>          #I am in my Home directory
davidw:~/bin>           #I am in $HOME/bin
davidw:/usr/bin>        #I am in /usr/bin

The zsh (which comes with Lynex) allows you to do all sorts of wacky
things with your prompt without defining functions.

--
David Weintraub                    _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
System Configuration Management   _/                                      _/
Dow Jones/Telerate - NSG         _/    I AM THE GREAT AND POWERFUL OZ*   _/
dav...@cnj.digex.net            _/                                      _/
d...@telerate.com               _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
                           *Pay no attention to the man behind the curtains



 Thu, 30 Jul 1998 03:00:00 GMT   
 flexible prompt in shells via shell-script
: Hello knowing people :-)))
: I'm a newuser under UNIX and I must to install and configure a
: unix "derivative" (LynxOS).
: At the moment I have the problem to realize a flexible prompt
: in a shell-script. The prompt should indicate a complete actua-
: lized path name whenever directories are changed, like
: /usr/users/653129:>cd ..
: /usr/users:>
: I've set up the prompt variable PS1 with pwd, but I have no
: idea to do this continuous in background :-(
: Is there anybody who has written anytimes a shell-script for
: this and can tell me via mail?
: Thanks a lot :-)))))))
: Andreas Gulden
: 653...@rz.fht-esslingen.de

I have indeed written _many_ shell scripts in _many_ shells do do exactly
the same thing, but the one thing you fail to mention is: what shell are
you using? This makes a great deal of difference in the respect it deter-
mines the method of which is used to do the above.

Reply by followup or email and I'll see what I can do.
-Brian
--
   ,---.     ,---.     ,---.     ,---.     ,---.     ,---.     ,---.  
  /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \  
.'  / \  `.'  / bsh20...@challenger.atc.fhda.edu `.'  / \  `.'  / \  `.
__,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.__



 Fri, 31 Jul 1998 03:00:00 GMT   
 flexible prompt in shells via shell-script
bsh20...@challenger.fhda.edu (Brian S Hiles ) writes:
]: Hello knowing people :-))) I'm a newuser under UNIX and I must to install
]: and configure a unix "derivative" (LynxOS). At the moment I have the
]: problem to realize a flexible prompt in a shell-script. The prompt should
]: indicate a complete actua- lized path name whenever directories are
]: /usr/users/653129:>cd ..
]: /usr/users:>
]: I've set up the prompt variable PS1 with pwd, but I have no idea to do
]: this continuous in background :-( Is there anybody who has written
]: anytimes a shell-script for this and can tell me via mail? Thanks a lot
]: :-))))))) Andreas Gulden 653...@rz.fht-esslingen.de

]I have indeed written _many_ shell scripts in _many_ shells do do exactly
]the same thing, but the one thing you fail to mention is: what shell are
]you using? This makes a great deal of difference in the respect it deter-
]mines the method of which is used to do the above.

]Reply by followup or email and I'll see what I can do.

Actually, I'd like to see it too.  I got the .kshrc you posted a few months
ago, which I really liked.  More, please. . . ;)
--
      Kevin MacNeil            \      Memorial University of Newfoundland
kmacn...@morgan.ucs.mun.ca      /            English & Philosophy



 Mon, 03 Aug 1998 03:00:00 GMT   
 
   [ 6 post ] 

Similar Threads

1. Shell Variables: Shell prompt OK, script, NO.

2. Convert Bash shell script to Korn shell script

3. shell script within shell script (general question)

4. Shell Script Help (C-Shell Script)

5. Shell script invoking other shell scripts

6. shell scripting and time out prompting

7. prompt not returning after shell script

8. rsh works on the ksh prompt but not in a shell script

9. Why does the following shell script executes differently than the command prompt

10. Changing login prompt (NOT motd or shell prompt)


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software