views:

1310

answers:

2

I'm using Korn Shell on Solaris and currently my PS1 env var is:

PS1="${HOSTNAME}:\${PWD} \$ "

And the prompt displays: hostname:/full/path/to/current/directory $

However, I'd like it to display: hostname:directory $

In other words, how can I display just the hostname and the name of the current directory, i.e. tmp or ~ or public_html etc etc?

A: 

Try this:


PS1="\H:\W"

More information on: How to: Change / Setup bash custom prompt, I know you said ksh, but I am pretty sure it will work.

Freddy
Nope. Doesn't work in ksh.
Sean Bright
Sorry, it doesn't work as you've typed it. I'm fairly certain that what you've typed is BASH syntax. Thanks tho.
daveslab
+2  A: 

From reading the ksh man page you want

PS1="${HOSTNAME}:\${PWD##*/} \$ "

Tested on default ksh on SunOS 5.8

Rudi Bierach
Looks like it's working! Thanks!
daveslab
I was curious if the ##*/ is a common trick and have found this website http://cfaj.freeshell.org/shell/commands/ . it has some other useful shell tricks ;)
Rudi Bierach
Cool, thanks dude.
daveslab