diff --git a/kitty_tests/shell_integration.py b/kitty_tests/shell_integration.py index 6d7e23942..b3537a987 100644 --- a/kitty_tests/shell_integration.py +++ b/kitty_tests/shell_integration.py @@ -11,8 +11,8 @@ from contextlib import contextmanager from functools import partial from kitty.constants import is_macos, kitty_base_dir, terminfo_dir -from kitty.fast_data_types import CURSOR_BEAM -from kitty.shell_integration import setup_bash_env, setup_zsh_env +from kitty.fast_data_types import CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE +from kitty.shell_integration import setup_bash_env, setup_fish_env, setup_zsh_env from . import BaseTest @@ -41,6 +41,14 @@ def safe_env_for_running_shell(argv, home_dir, rc='', shell='zsh'): with open(os.path.join(home_dir, '.zshrc'), 'w') as f: print(rc + '\n', file=f) setup_zsh_env(ans, argv) + elif shell == 'fish': + conf_dir = os.path.join(home_dir, '.config', 'fish') + os.makedirs(conf_dir, exist_ok=True) + # Avoid generating unneeded completion scripts + os.makedirs(os.path.join(home_dir, '.local', 'share', 'fish', 'generated_completions'), exist_ok=True) + with open(os.path.join(conf_dir, 'config.fish'), 'w') as f: + print(rc + '\n', file=f) + setup_fish_env(ans, argv) elif shell == 'bash': setup_bash_env(ans, argv) ans['KITTY_BASH_INJECT'] += ' posix' @@ -118,6 +126,75 @@ RPS1="{rps1}" pty.write_to_child('\x04') pty.wait_till(lambda: pty.screen.cursor.shape == CURSOR_BEAM) + + @unittest.skipUnless(shutil.which('fish'), 'fish not installed') + def test_fish_integration(self): + fish_prompt, right_prompt = 'left>', ' 1) + pty.write_to_child('\x04') + pty.wait_till(lambda: pty.screen.cursor.shape == CURSOR_BEAM) + pty.send_cmd_to_child('fish_vi_key_bindings') + pty.wait_till(lambda: pty.screen.cursor.shape == CURSOR_BLOCK) + pty.write_to_child('i') + pty.wait_till(lambda: pty.screen.cursor.shape == CURSOR_BEAM) + pty.write_to_child('\x1b') + pty.wait_till(lambda: pty.screen.cursor.shape == CURSOR_BLOCK) + pty.write_to_child('r') + pty.wait_till(lambda: pty.screen.cursor.shape == CURSOR_UNDERLINE) + + pty.write_to_child('\x1biexit\r') + @unittest.skipUnless(not is_macos and shutil.which('bash'), 'macOS bash is too old' if is_macos else 'bash not installed') def test_bash_integration(self): ps1 = 'prompt> '