Hack 34. Display username, hostname and basename of directory in the prompt
by Ramesh
The PS1 in this example displays following three information in the prompt:
- \u – Username
- \h – Hostname
- \W – Base name of the current working directory
- -bash-3.2$ export PS1="\u@\h \W> "
- ramesh@dev-db ~> cd /etc/mail
- ramesh@dev-db mail>
In this example, the Linux prompt changed from the boring “-bash-3.2$” to a meaningful “ramesh@dev-db mail>”, in which it represents the following:
- ramesh is the users who is currently logged into the Linux system.
- dev-db is the host name of the Linux machine.
- mail is the current working directory. i.e (/etc/mail)
当前内容版权归 Ramesh Natarajan 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Ramesh Natarajan .