1212from functools import lru_cache , partial
1313
1414from kitty .bash import decode_ansi_c_quoted_string
15- from kitty .constants import kitty_base_dir , shell_integration_dir , terminfo_dir
15+ from kitty .constants import kitten_exe , kitty_base_dir , shell_integration_dir , terminfo_dir
1616from kitty .fast_data_types import CURSOR_BEAM , CURSOR_BLOCK , CURSOR_UNDERLINE
17- from kitty .shell_integration import setup_bash_env , setup_fish_env , setup_zsh_env
1817
1918from . import BaseTest
2019
@@ -54,20 +53,17 @@ def safe_env_for_running_shell(argv, home_dir, rc='', shell='zsh'):
5453 argv .insert (1 , '--noglobalrcs' )
5554 with open (os .path .join (home_dir , '.zshrc' ), 'w' ) as f :
5655 print (rc + '\n ZLE_RPROMPT_INDENT=0' , file = f )
57- setup_zsh_env (ans , argv )
5856 elif shell == 'fish' :
5957 conf_dir = os .path .join (home_dir , '.config' , 'fish' )
6058 os .makedirs (conf_dir , exist_ok = True )
6159 # Avoid generating unneeded completion scripts
6260 os .makedirs (os .path .join (home_dir , '.local' , 'share' , 'fish' , 'generated_completions' ), exist_ok = True )
6361 with open (os .path .join (conf_dir , 'config.fish' ), 'w' ) as f :
6462 print (rc + '\n ' , file = f )
65- setup_fish_env (ans , argv )
6663 elif shell == 'bash' :
67- setup_bash_env (ans , argv )
68- ans ['KITTY_BASH_INJECT' ] += ' posix'
69- ans ['KITTY_BASH_POSIX_ENV' ] = os .path .join (home_dir , '.bashrc' )
70- with open (ans ['KITTY_BASH_POSIX_ENV' ], 'w' ) as f :
64+ bashrc = os .path .join (home_dir , '.bashrc' )
65+ ans ['KITTY_RUNNING_BASH_INTEGRATION_TEST' ] = bashrc
66+ with open (bashrc , 'w' ) as f :
7167 # ensure LINES and COLUMNS are kept up to date
7268 print ('shopt -s checkwinsize' , file = f )
7369 if rc :
@@ -84,7 +80,7 @@ def run_shell(self, shell='zsh', rc='', cmd='', setup_env=None):
8480 cmd = shlex .split (cmd .format (** locals ()))
8581 env = (setup_env or safe_env_for_running_shell )(cmd , home_dir , rc = rc , shell = shell )
8682 try :
87- pty = self .create_pty (cmd , cwd = home_dir , env = env )
83+ pty = self .create_pty ([ kitten_exe (), 'run-shell' , '--shell' , shlex . join ( cmd )] , cwd = home_dir , env = env )
8884 i = 10
8985 while i > 0 and not pty .screen_contents ().strip ():
9086 pty .process_input_from_child ()
@@ -327,7 +323,6 @@ def redrawn():
327323
328324 def setup_env (excluded , argv , home_dir , rc = '' , shell = 'bash' ):
329325 ans = basic_shell_env (home_dir )
330- setup_bash_env (ans , argv )
331326 for x in {'profile' , 'bash.bashrc' , '.bash_profile' , '.bash_login' , '.profile' , '.bashrc' , 'rcfile' } - excluded :
332327 with open (os .path .join (home_dir , x ), 'w' ) as f :
333328 if x == '.bashrc' and rc :
0 commit comments