Skip to content

Commit

Permalink
shell integration: check for saved PS1 value before using it
Browse files Browse the repository at this point in the history
On bash it's possible to hit ^C before we remembered the PS1 which would
cause the shell to end up with an empty PS1, making it unclear that the
^C actually worked as there is no prompt left.

I'm not sure I understand the need to mess with the variable every time
(could just add the OSC codes if not already present and never remove
them?), but at least make it so we don't end up with an empty prompt
line by checking the saved value isn't empty.
  • Loading branch information
martinetd authored and wez committed Sep 15, 2024
1 parent 1eddc91 commit 24702de
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions assets/shell-integration/wezterm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,12 @@ __wezterm_semantic_precmd() {
}

function __wezterm_semantic_preexec() {
# Restore the original PS1/PS2
PS1="$__wezterm_save_ps1"
PS2="$__wezterm_save_ps2"
# Restore the original PS1/PS2 if set
if [ -n "${__wezterm_save_ps1+1}" ]; then
PS1=$__wezterm_save_ps1"
PS2="$__wezterm_save_ps2"
unset __wezterm_save_ps1
fi
# Indicate that the command output begins here
printf "\033]133;C;\007"
__wezterm_semantic_precmd_executing=1
Expand Down

0 comments on commit 24702de

Please sign in to comment.