7.13 Pre-Prompt Commands in bashbash can run a UNIX command, or multiple commands, before it prints every prompt. This command does not have to set the prompt; it just happens to be run before each prompt is printed. The command could do some system checking, reset shell variables, or almost anything that you could type at a shell prompt. Store the command(s) in the PROMPT_COMMAND shell variable. If the commands run slowly, though, they'll delay your prompt. Here's a silly example that I used to have in my bash setup file ( 2.2 ) :
The first part is a series of shell commands that are
stored in the
PROMPT_COMMAND
variable;
they're surrounded by a pair of single quotes (
Here's what my screen looked like with this ridiculous setup.
Notice that the prompt keeps changing as the
PROMPT_COMMAND
resets
jerry@ruby :-{) (It was even more useless than psychoanalyze-pinhead ( 32.13 ) , but it was fun while it lasted.) Seriously now, I'll say again: PROMPT_COMMAND does not have to be used to set a prompt. You can use it to run any commands. If the commands in PROMPT_COMMAND write to standard output or standard error, you'll see that text before the prompt. - |
|