diff --git a/kitty_tests/shell_integration.py b/kitty_tests/shell_integration.py index ed4ad92ac..b5946ad41 100644 --- a/kitty_tests/shell_integration.py +++ b/kitty_tests/shell_integration.py @@ -306,7 +306,7 @@ PS1="{ps1}" self.ae(pty.screen_contents(), f'{ps1}printf "%s^G%s" "a" "b"\nab{ps1}') self.assertTrue(pty.screen.last_reported_cwd.decode().endswith(self.home_dir)) pty.send_cmd_to_child('echo $HISTFILE') - pty.wait_till(lambda: '.bash_history' in pty.screen_contents()) + pty.wait_till(lambda: '.bash_history' in pty.screen_contents().replace('\n', '')) q = os.path.join(self.home_dir, 'testing-cwd-notification-🐱') os.mkdir(q) pty.send_cmd_to_child(f'cd {q}') diff --git a/tools/cmd/run_shell/main.go b/tools/cmd/run_shell/main.go index e70e0cdb3..ad0a40e0f 100644 --- a/tools/cmd/run_shell/main.go +++ b/tools/cmd/run_shell/main.go @@ -9,6 +9,7 @@ import ( "strings" "kitty/tools/cli" + "kitty/tools/tty" "kitty/tools/tui" "kitty/tools/tui/shell_integration" ) @@ -68,6 +69,9 @@ func main(args []string, opts *Options) (rc int, err error) { return } +var debugprintln = tty.DebugPrintln +var _ = debugprintln + func EntryPoint(root *cli.Command) *cli.Command { sc := root.AddSubCommand(&cli.Command{ Name: "run-shell", diff --git a/tools/tui/run.go b/tools/tui/run.go index a45c42c7e..61315bc01 100644 --- a/tools/tui/run.go +++ b/tools/tui/run.go @@ -163,7 +163,7 @@ func RunShell(shell_cmd []string, shell_integration_env_var_val, cwd string) (er shell_env = env } exe := shell_cmd[0] - if runtime.GOOS == "darwin" { + if runtime.GOOS == "darwin" && os.Getenv("KITTY_RUNNING_BASH_INTEGRATION_TEST") != "" { // ensure shell runs in login mode. On macOS lots of people use ~/.bash_profile instead of ~/.bashrc // which means they expect the shell to run in login mode always. Le Sigh. shell_cmd[0] = "-" + filepath.Base(shell_cmd[0]) @@ -184,6 +184,9 @@ func RunShell(shell_cmd []string, shell_integration_env_var_val, cwd string) (er return unix.Exec(utils.FindExe(exe), shell_cmd, env) } +var debugprintln = tty.DebugPrintln +var _ = debugprintln + func RunCommandRestoringTerminalToSaneStateAfter(cmd []string) { exe := utils.FindExe(cmd[0]) c := exec.Command(exe, cmd[1:]...) diff --git a/tools/tui/shell_integration/api.go b/tools/tui/shell_integration/api.go index 6acabb5d3..9a28bfc52 100644 --- a/tools/tui/shell_integration/api.go +++ b/tools/tui/shell_integration/api.go @@ -328,8 +328,7 @@ func bash_setup_func(shell_integration_dir string, argv []string, env map[string argv = slices.Insert(argv, 1, `--posix`) if bashrc := os.Getenv(`KITTY_RUNNING_BASH_INTEGRATION_TEST`); bashrc != `` { - // prevent bash from source /etc/profile which is not under our control - os.Unsetenv(`KITTY_RUNNING_BASH_INTEGRATION_TEST`) + // prevent bash from sourcing /etc/profile which is not under our control env[`KITTY_BASH_INJECT`] += ` posix` env[`KITTY_BASH_POSIX_ENV`] = bashrc }