-
Notifications
You must be signed in to change notification settings - Fork 35
Manual Prompt Annotation
Ethan Pailes edited this page Feb 27, 2025
·
1 revision
By default, shpool will inject a prompt prefix. You can customize this prefix by setting the prompt_prefix config variable, but if you run into a limitation of this mechanism, you can always strike out on your own by disabling shpool's prompt injection and creating your own.
For example, in bash you might want to modify PROMPT_COMMAND by adding the following to your .bashrc
function __prompt_command() {
local EXIT="$?" # This needs to be first
PS1=""
local RCol='\[\e[0m\]'
local Red='\[\e[0;31m\]'
local Gre='\[\e[0;32m\]'
if [ $EXIT != 0 ]; then
PS1+="${Red}"
else
PS1+="${Gre}"
fi
if [ -v SHPOOL_SESSION_NAME ]; then
PS1+="shpool:${SHPOOL_SESSION_NAME}"
fi
PS1+="$ ${RCol}"
}
export PROMPT_COMMAND=__prompt_command
this would inject the standard shpool session name annotation into your prompt, but make it, along with the rest of your prompt, green or red depending on the exit value of the last command. This is not something you can normally acheive with the prompt_prefix option.