From ed157439129656c4b34ef95e13a901430ee33fd0 Mon Sep 17 00:00:00 2001 From: Benjamin Lupton Date: Fri, 1 Sep 2023 21:56:22 +0800 Subject: [PATCH] get-terminal-theme: fix vscode ssh sessions --- commands/get-terminal-theme | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/get-terminal-theme b/commands/get-terminal-theme index 82c334f56..7df3c1932 100755 --- a/commands/get-terminal-theme +++ b/commands/get-terminal-theme @@ -41,7 +41,7 @@ function get_terminal_theme() ( # ===================================== # Action - + # on macos, one can do this: # osascript -e 'tell application "Terminal" to get the background color of the current settings of the selected tab of front window' # to get back: @@ -75,7 +75,10 @@ function get_terminal_theme() ( # If the background color is `ba1a2b3c` the read will return `1a74/2b98/3cb6` local _ color='' r g b l # stdin+stderr must be readable+writable for the read to work, but we can't check silently, as failures are noisey, and silencing the failures causes them to close: https://gist.github.com/balupton/6eee015345c663d7d7baf83d8e20ce1f so just note in this comment - IFS=: read -s -t "$(get_read_decimal_timeout 0.01)" -d $'\a' -p $'\e]11;?\a' _ color || : + # as terminal theme is really only important for TTY use cases, use is-tty, this also solves vscode unable to ssh session into a machine + if is-tty; then + IFS=: read -s -t "$(get_read_decimal_timeout 0.01)" -d $'\a' -p $'\e]11;?\a' _ color || : + fi if test -n "$color"; then # Fetch the first two characters of [1a]74/[2b]98/[3c]b6 which is our color, and convert from hexadecimal to decimal # For what the latter two characters are, no one seems to know: https://unix.stackexchange.com/q/754952/50703