bash-git-prompt icon indicating copy to clipboard operation
bash-git-prompt copied to clipboard

Capture more information about last command line status

Open jdevera opened this issue 5 years ago • 0 comments

My own scripts were capturing the status of last command before I started using this prompt. Now I see that setLastCommandState always gets first in PROMPT_COMMAND. I could just use GIT_PROMPT_LAST_COMMAND_STATE but that, unfortunately, captures insufficient information.

Since setLastCommandState sits always first, would it make sense to you that it captured also the values in PIPESTATUS?

This is what I had first in my PROMPT_COMMAND function:

function prompt_command()
{
     # As the first command, capture all status info from the previous command IN
     # ONE GO. Then later break it down. If done in two separate assignments, the
     # status of the first assignment, and not that of the previos shell command,
     # will be used instead.
     local status_capture=( $? "${PIPESTATUS[@]}" )
     LAST_RC="${status_capture[0]}"
     LAST_PIPESTATUS=( "${status_capture[@]:1}" )
}

Even when the prompt code would not use it itself, it would make it stop interfering with other integrations that can just take the variables set by setLastCommandState.

What do you think?

jdevera avatar Apr 25 '20 13:04 jdevera