Fix rendering issues with bash shell integration (#301)

* shell-integration/bash: we need to wrap escape sequences in brackets

* nix: install bashInteractive on Linux
This commit is contained in:
Mitchell Hashimoto
2023-08-17 22:42:26 -07:00
committed by GitHub
parent 9d61212451
commit 0bdd73797e
2 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,6 @@
{ mkShell, lib, stdenv { mkShell, lib, stdenv
, bashInteractive
, debugedit , debugedit
, flatpak-builder , flatpak-builder
, gdb , gdb
@ -85,6 +86,10 @@ in mkShell rec {
wabt wabt
wasmtime wasmtime
] ++ lib.optionals stdenv.isLinux [ ] ++ lib.optionals stdenv.isLinux [
# My nix shell environment installs the non-interactive version
# by default so we have to include this.
bashInteractive
# Flatpak builds # Flatpak builds
debugedit debugedit
flatpak-builder flatpak-builder

View File

@ -32,23 +32,24 @@ function __ghostty_get_current_command() {
function __ghostty_precmd() { function __ghostty_precmd() {
local ret="$?" local ret="$?"
if test "$_ghostty_executing" != "0"; then if test "$_ghostty_executing" != "0"; then
_GHOSTTY_SAVE_PS0="$PS0"
_GHOSTTY_SAVE_PS1="$PS1" _GHOSTTY_SAVE_PS1="$PS1"
_GHOSTTY_SAVE_PS2="$PS2" _GHOSTTY_SAVE_PS2="$PS2"
# Marks # Marks
PS1=$PS1'\e]133;B\a' PS1=$PS1'\[\e]133;B\a\]'
PS2=$PS2'\e]133;B\a' PS2=$PS2'\[\e]133;B\a\]'
# Cursor # Cursor
PS1=$PS1'\e[5 q' PS1=$PS1'\[\e[5 q\]'
PS0=$PS0'\e[0 q' PS0=$PS0'\[\e[0 q\]'
# Command # Command
PS0=$PS0'$(__ghostty_get_current_command)' PS0=$PS0'$(__ghostty_get_current_command)'
PS1=$PS1'\e]2;$PWD\a' PS1=$PS1'\[\e]2;$PWD\a\]'
fi fi
if test "$_ghostty_executing" != ""; then if test "$_ghostty_executing" != "0"; then
builtin printf "\033]133;D;%s;aid=%s\007" "$ret" "$BASHPID" builtin printf "\033]133;D;%s;aid=%s\007" "$ret" "$BASHPID"
fi fi
@ -65,6 +66,7 @@ function __ghostty_precmd() {
} }
function __ghostty_preexec() { function __ghostty_preexec() {
PS0="$_GHOSTTY_SAVE_PS0"
PS1="$_GHOSTTY_SAVE_PS1" PS1="$_GHOSTTY_SAVE_PS1"
PS2="$_GHOSTTY_SAVE_PS2" PS2="$_GHOSTTY_SAVE_PS2"
builtin printf "\033]133;C;\007" builtin printf "\033]133;C;\007"