免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2591 | 回复: 15
打印 上一主题 下一主题

如何在用户登录的时候显示? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-05-20 15:30 |只看该作者 |倒序浏览
如何在用户登录的时候显示当前登录的主机名:登录名和所在的目录?就是说和linux一样显示成:[root@bbs root]# 的形式,好像是在/etc/profile 文件中该但是我对shell不熟不知道该具体怎么做这个东西
帮帮我!

论坛徽章:
0
2 [报告]
发表于 2003-05-20 22:04 |只看该作者

如何在用户登录的时候显示?

...

export PS1='[\u@\h:\w]\$ '

只对 bash 有效。

论坛徽章:
0
3 [报告]
发表于 2003-05-20 23:47 |只看该作者

如何在用户登录的时候显示?

SCO UNIX ksh 可以这样作:
  1. export PS1='hostname $PWD # '
复制代码

论坛徽章:
0
4 [报告]
发表于 2003-05-21 21:20 |只看该作者

如何在用户登录的时候显示?

不知可不可以实时显示提示符前的路径呢?
请问该如何设置?

论坛徽章:
0
5 [报告]
发表于 2003-05-21 21:35 |只看该作者

如何在用户登录的时候显示?

原帖由 "ncwyj" 发表:
不知可不可以实时显示提示符前的路径呢?
请问该如何设置?


你是什么 shell?

论坛徽章:
0
6 [报告]
发表于 2003-05-21 21:41 |只看该作者

如何在用户登录的时候显示?

随便
不过一般用BSH

论坛徽章:
0
7 [报告]
发表于 2003-05-21 21:51 |只看该作者

如何在用户登录的时候显示?

\PWD显示完整路径
export PS1='\u@\h \PWD\$ '

\w不显示完整路径
export PS1='\u@\h \w\$ '

以上for Bash

论坛徽章:
0
8 [报告]
发表于 2003-05-21 21:53 |只看该作者

如何在用户登录的时候显示?

linux:
export PS1='$USER/${PWD}'

论坛徽章:
0
9 [报告]
发表于 2003-05-21 21:59 |只看该作者

如何在用户登录的时候显示?

原帖由 "ncwyj" 发表:
随便
不过一般用BSH


是指 bourne shell 吗?

论坛徽章:
0
10 [报告]
发表于 2003-05-21 22:03 |只看该作者

如何在用户登录的时候显示?

原帖由 "aquino" 发表:
\PWD显示完整路径
export PS1='\u@\h \PWD\$ '

\w不显示完整路径
export PS1='\u@\h \w\$ '

以上for Bash




aquino 你是用的什么OS?有 \PWD 吗?\w 是完整路径,\W 是不完整路径

还有很多选项,可以从 man bash 中查到 ( bash2.05a )



  1. ...
  2. PROMPTING
  3.        When executing interactively, bash  displays  the  primary
  4.        prompt  PS1  when  it  is ready to read a command, and the
  5.        secondary prompt PS2 when it needs more input to  complete
  6.        a  command.   Bash  allows these prompt strings to be cus-
  7.        tomized by inserting a number of backslash-escaped special
  8.        characters that are decoded as follows:
  9.               \a     an ASCII bell character (07)
  10.               \d     the  date  in  "Weekday  Month  Date" format
  11.                      (e.g., "Tue May 26")
  12.               \e     an ASCII escape character (033)
  13.               \h     the hostname up to the first `.'
  14.               \H     the hostname
  15.               \j     the number of jobs currently managed by  the
  16.                      shell
  17.               \l     the  basename of the shell's terminal device
  18.                      name
  19.               \n     newline
  20.               \r     carriage return
  21.               \s     the name of the shell, the  basename  of  $0
  22.                      (the portion following the final slash)
  23.               \t     the current time in 24-hour HH:MM:SS format
  24.               \T     the current time in 12-hour HH:MM:SS format
  25.               \@     the current time in 12-hour am/pm format
  26.               \A     the current time in 24-hour HH:MM format
  27.               \u     the username of the current user
  28.               \v     the version of bash (e.g., 2.00)
  29.               \V     the  release  of  bash, version + patchelvel
  30.                      (e.g., 2.00.0)
  31.               \w     the current working directory
  32.               \W     the basename of the current  working  direc-
  33.                      tory
  34.               \!     the history number of this command
  35.               \#     the command number of this command
  36.               \$     if  the effective UID is 0, a #, otherwise a
  37.                      $
  38.               \nnn   the character  corresponding  to  the  octal
  39.                      number nnn
  40.               \\     a backslash
  41.               \[     begin a sequence of non-printing characters,
  42.                      which could be used to embed a terminal con-
  43.                      trol sequence into the prompt
  44.               \]     end a sequence of non-printing characters

  45.        The command number and the history number are usually ....
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP