1- use crate :: { CLOSE , ESCAPE , START , TMUX } ;
1+ use tracing:: error;
2+ use yazi_shared:: env_exists;
3+
4+ use crate :: { CLOSE , ESCAPE , NVIM , START , TMUX } ;
25
36pub struct Mux ;
47
58impl Mux {
69 pub fn csi ( s : & str ) -> std:: borrow:: Cow < str > {
7- if * TMUX {
10+ if * TMUX == 2 && ! * NVIM {
811 std:: borrow:: Cow :: Owned ( format ! (
912 "{}{}{}" ,
1013 * START ,
@@ -16,6 +19,34 @@ impl Mux {
1619 }
1720 }
1821
22+ pub fn tmux_passthrough ( ) -> u8 {
23+ if !env_exists ( "TMUX_PANE" ) || !env_exists ( "TMUX" ) {
24+ return 0 ;
25+ }
26+
27+ let child = std:: process:: Command :: new ( "tmux" )
28+ . args ( [ "set" , "-p" , "allow-passthrough" , "all" ] )
29+ . stdin ( std:: process:: Stdio :: null ( ) )
30+ . stdout ( std:: process:: Stdio :: null ( ) )
31+ . stderr ( std:: process:: Stdio :: piped ( ) )
32+ . spawn ( ) ;
33+
34+ match child. and_then ( |c| c. wait_with_output ( ) ) {
35+ Ok ( output) if output. status . success ( ) => return 2 ,
36+ Ok ( output) => {
37+ error ! (
38+ "Running `tmux set -p allow-passthrough all` failed: {:?}, {}" ,
39+ output. status,
40+ String :: from_utf8_lossy( & output. stderr)
41+ ) ;
42+ }
43+ Err ( err) => {
44+ error ! ( "Failed to spawn `tmux set -p allow-passthrough all`: {err}" ) ;
45+ }
46+ }
47+ 1
48+ }
49+
1950 pub fn tmux_sixel_flag ( ) -> & ' static str {
2051 let stdout = std:: process:: Command :: new ( "tmux" )
2152 . args ( [ "-LwU0dju1is5" , "-f/dev/null" , "start" , ";" , "display" , "-p" , "#{sixel_support}" ] )
@@ -33,7 +64,7 @@ impl Mux {
3364
3465 pub ( super ) fn term_program ( ) -> ( Option < String > , Option < String > ) {
3566 let ( mut term, mut program) = ( None , None ) ;
36- if ! * TMUX {
67+ if * TMUX == 0 {
3768 return ( term, program) ;
3869 }
3970 let Ok ( output) = std:: process:: Command :: new ( "tmux" ) . arg ( "show-environment" ) . output ( ) else {
0 commit comments