-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patht
executable file
·56 lines (53 loc) · 2.4 KB
/
t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
if [ ! -d /mnt/c ]; then
# Mac
osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode'
if [ "$(osascript -e 'tell application "System Events" to tell appearance preferences to get dark mode')" == "true" ]; then
osascript -e '
tell application "Terminal"
set defaultSettings to first settings set whose name is "One Dark"
set currentSettings to defaultSettings
repeat with aWindow in windows
repeat with aTab in tabs of aWindow
set current settings of aTab to currentSettings
end repeat
end repeat
end tell' 2>/dev/null
else
osascript -e '
tell application "Terminal"
set defaultSettings to first settings set whose name is "One Light"
set currentSettings to defaultSettings
repeat with aWindow in windows
repeat with aTab in tabs of aWindow
set current settings of aTab to currentSettings
end repeat
end repeat
end tell' 2>/dev/null
fi
else
# Windows in WSL
WINHOME=$(wslpath "$(cmd.exe /C "echo %USERPROFILE%" 2>/dev/null | tr -d '\r' | tail -1)")
settings="$WINHOME/AppData/Local/Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe/LocalState/settings.json"
settingsPreview="$WINHOME/AppData/Local/Packages/Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe/LocalState/settings.json"
if reg.exe query 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize' /v AppsUseLightTheme | grep -q 0x1; then
useLightTheme=0
fromTheme=OneLight
toTheme=OneDark
else
useLightTheme=1
fromTheme=OneDark
toTheme=OneLight
fi
if [ -f "$settings" ]; then
sed "s/\"colorScheme\": \"$fromTheme\"/\"colorScheme\": \"$toTheme\"/g" "$settings" >/tmp/terminal$$.json
cp /tmp/terminal$$.json "$settings"
fi
if [ -f "$settingsPreview" ]; then
sed "s/\"colorScheme\": \"$fromTheme\"/\"colorScheme\": \"$toTheme\"/g" "$settingsPreview" >/tmp/terminal$$.json
cp /tmp/terminal$$.json "$settingsPreview"
fi
rm /tmp/terminal$$.json
reg.exe add 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize' /v SystemUsesLightTheme /t REG_DWORD /f /d $useLightTheme > /dev/null
reg.exe add 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize' /v AppsUseLightTheme /t REG_DWORD /f /d $useLightTheme > /dev/null
fi