Hack 33. PROMPT_COMMAND
by Ramesh
Bash shell executes the content of the PROMPT_COMMAND just before displaying the PS1 variable.
- ramesh@dev-db ~> export PROMPT_COMMAND="date +%H:%M:%S"
- 22:08:42
- ramesh@dev-db ~>
- [Note: This displays the PROMPT_COMMAND and PS1 output on different lines]
If you want to display the value of PROMPT_COMMAND in the same line as the PS1, use the echo -n as shown below.
- ramesh@dev-db ~> export PROMPT_COMMAND="echo -n [$(date +%H:%M:%S)]"
- [22:08:51]ramesh@dev-db ~>
- [Note: This displays the PROMPT_COMMAND and PS1 output on the same line]
当前内容版权归 Ramesh Natarajan 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Ramesh Natarajan .