( env: CliEnv = getCliEnv(), )
| 15 | * Detect which image protocol the terminal supports |
| 16 | */ |
| 17 | export function detectTerminalImageSupport( |
| 18 | env: CliEnv = getCliEnv(), |
| 19 | ): TerminalImageProtocol { |
| 20 | if (cachedProtocol !== null) { |
| 21 | return cachedProtocol |
| 22 | } |
| 23 | |
| 24 | // Check for iTerm2 |
| 25 | if (env.TERM_PROGRAM === 'iTerm.app') { |
| 26 | cachedProtocol = 'iterm2' |
| 27 | return cachedProtocol |
| 28 | } |
| 29 | |
| 30 | // Check for Kitty |
| 31 | if ( |
| 32 | env.TERM === 'xterm-kitty' || |
| 33 | env.KITTY_WINDOW_ID !== undefined |
| 34 | ) { |
| 35 | cachedProtocol = 'kitty' |
| 36 | return cachedProtocol |
| 37 | } |
| 38 | |
| 39 | // Check for Sixel support (less common) |
| 40 | if ( |
| 41 | env.TERM?.includes('sixel') || |
| 42 | env.SIXEL_SUPPORT === 'true' |
| 43 | ) { |
| 44 | cachedProtocol = 'sixel' |
| 45 | return cachedProtocol |
| 46 | } |
| 47 | |
| 48 | cachedProtocol = 'none' |
| 49 | return cachedProtocol |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Check if terminal supports inline images |
no test coverage detected