LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1122|回复: 2

怎样让命令提示符能把路径显示完整啊??

[复制链接]
发表于 2006-11-26 22:08:12 | 显示全部楼层 |阅读模式
我的CentOS上只显示最后一个子目录的名字,我想显示完整,怎么办?

[root@centos zlib-1.2.3] 我的就是这样的……

我想改成这个样子 root:/usr/local/src/lamp/zlib-1.2.3
发表于 2006-11-26 22:36:27 | 显示全部楼层
修改你的 bash 变量 PS1:
你看看现在它是什么值?
$ set | grep PS

然后根据这个说明来改:(这个说明你可以通过 $ man bash 然后 查找 PROMPTING 字串
找到)
  1. PROMPTING
  2.        When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the  secondary  prompt  PS2
  3.        when it needs more input to complete a command.  Bash allows these prompt strings to be customized by inserting a number of backslash-
  4.        escaped special characters that are decoded as follows:
  5.               \a     an ASCII bell character (07)
  6.               \d     the date in "Weekday Month Date" format (e.g., "Tue May 26")
  7.               \D{format}
  8.                      the format is passed to strftime(3) and the result is inserted into the prompt string; an  empty  format  results  in  a
  9.                      locale-specific time representation.  The braces are required
  10.               \e     an ASCII escape character (033)
  11.               \h     the hostname up to the first ‘.’
  12.               \H     the hostname
  13.               \j     the number of jobs currently managed by the shell
  14.               \l     the basename of the shell’s terminal device name
  15.               \n     newline
  16.               \r     carriage return
  17.               \s     the name of the shell, the basename of $0 (the portion following the final slash)
  18.               \t     the current time in 24-hour HH:MM:SS format
  19.               \T     the current time in 12-hour HH:MM:SS format
  20.               \@     the current time in 12-hour am/pm format
  21.               \A     the current time in 24-hour HH:MM format
  22.               \u     the username of the current user
  23.               \v     the version of bash (e.g., 2.00)
  24.               \V     the release of bash, version + patch level (e.g., 2.00.0)
  25.               \w     the current working directory, with $HOME abbreviated with a tilde
  26.               \W     the basename of the current working directory, with $HOME abbreviated with a tilde
  27.               \!     the history number of this command
  28.               \#     the command number of this command
  29.               \$     if the effective UID is 0, a #, otherwise a $
  30.               \nnn   the character corresponding to the octal number nnn
  31.               \\     a backslash
  32.               \[     begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
  33.               \]     end a sequence of non-printing characters
  34.        The  command number and the history number are usually different: the history number of a command is its position in the history list,
  35.        which may include commands restored from the history file (see HISTORY below), while  the  command  number  is  the  position  in  the
  36.        sequence  of commands executed during the current shell session.  After the string is decoded, it is expanded via parameter expansion,
  37.        command substitution, arithmetic expansion, and quote removal, subject to the value of the promptvars shell option (see  the  descrip-
  38.        tion of the shopt command under SHELL BUILTIN COMMANDS below).
复制代码

你要的效果可以这样改:
$ PS1='[\u:`pwd`]\$ '

要长久有效的话就把它添加到: .bashrc 文件中。
添加的行:
export PS1='[\u:`pwd`]\$ '
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-11-27 00:56:00 | 显示全部楼层
成功了,十分感谢
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表