Skip to content

Commit

Permalink
get-terminal-theme: fix vscode ssh sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Sep 1, 2023
1 parent dc38d57 commit ed15743
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions commands/get-terminal-theme
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed15743

Please sign in to comment.