Hack 36. Display output of any command in the prompt
by Ramesh
You can display output of any Linux command in the prompt. The following example displays three items separated by | (pipe) in the command prompt:
- !: The history number of the command
- \h: hostname
- $kernel_version: The output of the uname -r command from $kernel_version variable
- \$?: Status of the last command
- ramesh@dev-db ~> kernel_version=$(uname -r)
- ramesh@dev-db ~> export PS1="\!|\h|$kernel_version|\$?> "
- 473|dev-db|2.6.25-14.fc9.i686|0>
当前内容版权归 Ramesh Natarajan 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Ramesh Natarajan .