diff --git a/.github/workflows/ci.py b/.github/workflows/ci.py index b7ebed1e8..fc671f3fe 100644 --- a/.github/workflows/ci.py +++ b/.github/workflows/ci.py @@ -37,7 +37,7 @@ def install_deps(): run('sudo apt-get install -y libgl1-mesa-dev libxi-dev libxrandr-dev libxinerama-dev ca-certificates' ' libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev libx11-xcb-dev zsh' ' libpng-dev liblcms2-dev libfontconfig-dev libxkbcommon-x11-dev libcanberra-dev librsync-dev uuid-dev' - ' zsh bash dash fish') + ' zsh bash dash') # for some reason these directories are world writable which causes zsh # compinit to break run('sudo chmod -R og-w /usr/share/zsh') diff --git a/kitty_tests/shell_integration.py b/kitty_tests/shell_integration.py index 6d7e23942..05a9f434d 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,74 @@ 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> '