Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to custom display prompt in KornShell to show hostname and current directory?

I am using KornShell (ksh) on Solaris and currently my PS1 env var is:

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

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

However, I would 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?

like image 228
daveslab Avatar asked Jul 23 '09 13:07

daveslab


2 Answers

PS1=`id -un`@`hostname -s`:'$PWD'$
like image 154
user8585881 Avatar answered Oct 05 '22 16:10

user8585881


From reading the ksh man page you want

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

Tested on default ksh on SunOS 5.8

like image 28
Rudi Bierach Avatar answered Oct 05 '22 14:10

Rudi Bierach