Editting the Command Prompt


For "sh" or "bash" Users:

Usage : export PS1="XXX"

Character Function Example
\d Date Sun Jan 1
\h Hostname myhost
\n Carriage Return -
\s The shell now working tcsh
\t The time shown as 24 hours 18:52:33
\T The time shown as 12 hours -
\@ The time shown as 12 hours 06:52pm
\u Username now login hogehoge
\v The version of bash 2.04
\V The version of bash in detail 2.04.0
\w Current directory from ~/ -
\W Name of the current directory -
\! History number of the command now working -
\# Command number of the command now working -
\$ Showing "#" if the user is root, "$" if others -
\\ "\" -

e.g.
export PS1="[\h:\W:\u]\$"
[myhost:/work:hoge]$



For "csh" or "tcsh" users:

Usage : setenv prompt=XXX

Character Function Example
%n User name hoge
%d Name of the current directory local
%~ Current directory from ~/ ~/usr/local
%cn [n=1,2,...] Display the [n] tail of current directory -
%h History no. of the command now working -
%m Host name myhost
%M Host name in detail myhost.div.hoge.co.jp
%t The time shown as 12 hours 06:52pm
%T The time shown as 24 hours 18:52
%p The time shown as 12 hours in detail 06:52.59pm
%T The time shown as 24 hours in detail 18:52.59
%S Reversal display till "%s" -
%B Bold display till "%b" bold
%U Underline till "%u" underline
%Y Year with 4 digits 2002
%y Year with 2 digits 02
%w Month Jan
%W Month 12
%d The day of the week Mon
%D Date 31


This HP was updated in May 5, 2002 at the latest.

YAHATA YUSAKU
Biomechanics Laboratry, Environmental Studies,
Graduate School of Frontier Science, Univ. of Tokyo

Please get in contact with me : yusaku@sml.k.u-tokyo.ac.jp