Skip to content

Commit

Permalink
setup/bash: Add support for SAVVY_CONTEXT = run|record
Browse files Browse the repository at this point in the history
  • Loading branch information
joshi4 committed May 5, 2024
1 parent 4becba7 commit 52e5a1f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/setup/bash-preexec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ savvy_cmd_pre_exec() {
local cmd="${expanded_command}"
local prompt=$(get_user_prompt)
step_id=""
if [[ "${SAVVY_CONTEXT}" == "1" ]] ; then
if [[ "${SAVVY_CONTEXT}" == "record" ]] ; then
step_id=$(SAVVY_SOCKET_PATH=${SAVVY_INPUT_FILE} savvy send --prompt="${prompt}" "$cmd")
fi
}

savvy_cmd_pre_cmd() {
local exit_code=$?

if [[ "${SAVVY_CONTEXT}" == "1" && "$PS1" != *'recording'* ]]; then
if [[ "${SAVVY_CONTEXT}" == "record" && "$PS1" != *'recording'* ]]; then
PS1+=$'\[\e[31m\]recording\[\e[0m\] \U1f60e '
fi

# if return code is not 0, send the return code to the server
if [[ "${SAVVY_CONTEXT}" == "1" && "${exit_code}" != "0" ]] ; then
if [[ "${SAVVY_CONTEXT}" == "record" && "${exit_code}" != "0" ]] ; then
SAVVY_SOCKET_PATH=${SAVVY_INPUT_FILE} savvy send --step-id="${step_id}" --exit-code="${exit_code}"
fi
}
Expand Down

0 comments on commit 52e5a1f

Please sign in to comment.