Skip to content

Commit

Permalink
Detect light mode in Apple Terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
cmer committed May 26, 2021
1 parent dee9dbb commit 55554be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mcfly.bash
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@ if [[ $- =~ .*i.* ]]; then

if [[ "$COLORFGBG" =~ \;15$ ]]; then
export MCFLY_LIGHT=TRUE
elif [[ "$TERM_PROGRAM" == "Apple_Terminal" && $(defaults read -g AppleInterfaceStyle 2> /dev/null) != 'Dark' ]]; then
export MCFLY_LIGHT=TRUE
fi
fi
5 changes: 5 additions & 0 deletions mcfly.fish
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ if status is-interactive
function mcfly_detect_terminal_color -d 'Attempt to determine if running in light mode'
if string match -r '\;15$' $COLORFGBG &> /dev/null
set -gx MCFLY_LIGHT TRUE
else if test "$TERM_PROGRAM" = "Apple_Terminal"
set apple_interface (defaults read -g AppleInterfaceStyle 2> /dev/null)
if [ "$apple_interface" != 'Dark' ]
set -gx MCFLY_LIGHT TRUE
end
end
end

Expand Down
2 changes: 2 additions & 0 deletions mcfly.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,7 @@ if [[ $- =~ .*i.* ]]; then

if [[ "$COLORFGBG" =~ \;15$ ]]; then
export MCFLY_LIGHT=TRUE
elif [[ "$TERM_PROGRAM" == "Apple_Terminal" && $(defaults read -g AppleInterfaceStyle 2> /dev/null) != 'Dark' ]]; then
export MCFLY_LIGHT=TRUE
fi
fi

0 comments on commit 55554be

Please sign in to comment.