cshell环境中提示符设置
终端的提示符可以按如下设置:
set prompt = '[%n@%m %c]$ '
set prompt='[%m:%/]>>>'
%n:用户名
%m:主机名
%c:最后的目录.
使用 pwd无效, 因为cshrc文件在shell启动的时候是只读的,不是在每一次文件改变时都读取。
csh和tcsh使用cshrc文件,bash使用bashrc文件。
以下是tcshell常用的提示符设置选项:
| option | description |
|---|---|
| %/ | The current working directory. |
| %~ | The current working directory, but with one's home directory represented by `~' and other users' home directories represented by `~user' as per Filename substitution.`~user' substitution happens only if the shell has already used `~user' in a pathname in the current session. |
| %c[[0]n], %.[[0]n] | The trailing component of the current working directory, or n trailing components if a digit n is given. If n begins with `0', the number of skipped components precede the trailing component(s) in the format `/ |
| %C | Like %c, but without `~' substitution. |
| %h, %!, ! | The current history event number. |
| %M | The full hostname. |
| %m | The hostname up to the first `.'. |
| %S (%s) | Start (stop) standout mode. |
| %B (%b) | Start (stop) boldfacing mode. |
| %U (%u) | Start (stop) underline mode. |
| %t, %@ | The time of day in 12-hour AM/PM format. |
| %T | Like `%t', but in 24-hour format (but see the ampm shell variable). |
| %p | The `precise' time of day in 12-hour AM/PM format, with seconds. |
| %P | Like `%p', but in 24-hour format (but see the ampm shell variable). |
| \c | c is parsed as in bindkey. |
| ^c | c is parsed as in bindkey. |
| %% | A single `%'. |
| %n | The user name. |
| %N | The effective user name. |
| %j | The number of jobs. |
| %d | The weekday in `Day' format. |
| %D | The day in `dd' format. |
| %w | The month in `Mon' format. |
| %W | The month in `mm' format. |
| %y | The year in `yy' format. |
| %Y | The year in `yyyy' format. |
| %l | The shell's tty. |
| %L | Clears from the end of the prompt to end of the display or the end of the line. |
| %$ | Expands the shell or environment variable name immediately after the `$'. |
| %# | `>' (or the first character of the promptchars shell variable) for normal users, `#' (or the second character of promptchars) for the superuser. |
| % | Includes string as a literal escape sequence. It should be used only to change terminal attributes and should not move the cursor location. This cannot be the last sequence in prompt. |
| %? | The return code of the command executed just before the prompt. |
| %R | In prompt2, the status of the parser. In prompt3, the corrected string. In history, the history string. |
`%B', `%S', `%U' and `%{string%}' are available in only eight-bit-clean shells; see the version shell variable.
The bold, standout and underline sequences are often used to distinguish a superuser shell. For example,
> set prompt = "%m [%h] %B[%@]%b [%/] you rang? "
tut [37] [2:54pm] [/usr/accts/sys] you rang? _
If `%t', `%@', `%T', `%p', or `%P' is used, and noding is not set, then print DING!' on the change of hour (i.e, :00' min‐
utes) instead of the actual time.
Set by default to `%# ' in interactive shells.
浙公网安备 33010602011771号