Add script to toggle VS Code theme
Signed-off-by: Ferit Yiğit BALABAN <fybalaban@fybx.dev>
This commit is contained in:
parent
294e9616f5
commit
df9a93704c
24
utility/toggle_vscode_theme.sh
Executable file
24
utility/toggle_vscode_theme.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Ferit Yiğit BALABAN, <fybalaban@fybx>
|
||||
# toggle_vscode_theme.sh, 2023
|
||||
#
|
||||
|
||||
path_settings="$HOME/.config/Code/User/settings.json"
|
||||
preferred_dark=$(grep -o '"workbench.preferredDarkColorTheme": *"[^"]*"' < "$path_settings" | cut -d '"' -f4)
|
||||
preferred_light=$(grep -o '"workbench.preferredLightColorTheme": *"[^"]*"' < "$path_settings" | cut -d '"' -f4)
|
||||
|
||||
if ! command -v code &> /dev/null; then
|
||||
echo "VS Code is not installed. Please install it and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
'light' | l)
|
||||
sed -i "s/\"workbench.colorTheme\": \"[^\"]*\"/\"workbench.colorTheme\": \"$preferred_light\"/" "$path_settings";;
|
||||
'dark' | d)
|
||||
sed -i "s/\"workbench.colorTheme\": \"[^\"]*\"/\"workbench.colorTheme\": \"$preferred_dark\"/" "$path_settings";;
|
||||
*)
|
||||
echo "Invalid argument. Please provide either 'light' or 'dark'."
|
||||
exit 1;;
|
||||
esac
|
Loading…
x
Reference in New Issue
Block a user