$PROMPT_COMMAND  –  Commands to Execute Before Printing The Prompt

$PROMPT_COMMAND is either an array or a regular variable. Each value is executed as a command before the primary prompt $PS1 is executed.

This is only useful for interactive terminals.

Examples

Show number of files in $HOME in the prompt:
1
2
3
PROMPT_COMMAND='_fileCount=$(ls ~ | wc -l)' 
PS1="$_fileCount files]$ "
# next prompt will display the number of files
BashSupport Pro 是一个 支持 $PROMPT_COMMAND 的 Bash 集成开发工具 – 马上试用
© 2020–2024 Joachim Ansorg
声明
隐私政策
许可条款