88import unittest
99from contextlib import contextmanager
1010
11- from kitty .constants import terminfo_dir
11+ from kitty .constants import kitty_base_dir , terminfo_dir
1212from kitty .fast_data_types import CURSOR_BEAM
1313from kitty .shell_integration import setup_zsh_env
1414
@@ -22,24 +22,28 @@ def safe_env_for_running_shell(home_dir, rc='', shell='zsh'):
2222 'TERM' : 'xterm-kitty' ,
2323 'TERMINFO' : terminfo_dir ,
2424 'KITTY_SHELL_INTEGRATION' : 'enabled' ,
25+ 'KITTY_INSTALLATION_DIR' : kitty_base_dir ,
2526 }
27+ for x in ('USER' , 'LANG' ):
28+ if os .environ .get (x ):
29+ ans [x ] = os .environ [x ]
2630 if shell == 'zsh' :
2731 ans ['ZLE_RPROMPT_INDENT' ] = '0'
2832 with open (os .path .join (home_dir , '.zshenv' ), 'w' ) as f :
2933 print ('unset GLOBAL_RCS' , file = f )
3034 with open (os .path .join (home_dir , '.zshrc' ), 'w' ) as f :
31- print (rc , file = f )
35+ print (rc + ' \n ' , file = f )
3236 setup_zsh_env (ans )
3337 return ans
3438
3539
3640class ShellIntegration (BaseTest ):
3741
3842 @contextmanager
39- def run_shell (self , shell = 'zsh' , rc = '' ):
43+ def run_shell (self , shell = 'zsh' , rc = '' , cmd = '{shell} -il' ):
4044 home_dir = os .path .realpath (tempfile .mkdtemp ())
4145 try :
42- pty = self .create_pty (f' { shell } -il' , cwd = home_dir , env = safe_env_for_running_shell (home_dir , rc ))
46+ pty = self .create_pty (cmd . format ( ** locals ()) , cwd = home_dir , env = safe_env_for_running_shell (home_dir , rc ))
4347 i = 10
4448 while i > 0 and not pty .screen_contents ().strip ():
4549 pty .process_input_from_child ()
@@ -66,4 +70,5 @@ def test_zsh_integration(self):
6670 self .ae (pty .callbacks .titlebuf , '~' )
6771 pty .send_cmd_to_child ('mkdir test && ls -a' )
6872 pty .wait_till (lambda : pty .screen_contents ().count (ps1 ) == 2 )
69- self .ae (pty .last_cmd_output (), str (pty .screen .line (1 )))
73+ q = '\n ' .join (str (pty .screen .line (i )) for i in range (1 , pty .screen .cursor .y ))
74+ self .ae (pty .last_cmd_output (), q )
0 commit comments