Last active
August 8, 2023 03:13
-
-
Save naranyala/500f124b2da0899a39c8f1dc4a5eda2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################# | |
# KITTY THEMES SETUP (github.com/naranyala) # | |
############################################# | |
dir="~/.config/kitty/kitty-themes" | |
width=$(tput cols) | |
separator=$(printf '%*s' "$width" | tr ' ' '-') | |
# Check if the directory exists | |
if [ -d "$dir" ]; then | |
echo "The '$dir' directory already exists. Skipping clone action." | |
else | |
# git clone https://github.com/dexpota/kitty-themes.git "$dir" | |
git clone --depth 1 https://github.com/dexpota/kitty-themes.git "$dir" | |
echo "Themes SUCCESS cloned." | |
fi | |
echo $separator; | |
echo "All themes display can be found in 'github.com/dexpota/kitty-themes'" | |
echo $separator; | |
###################### | |
# DISPLAY ALL THEMES # | |
###################### | |
echo "Available themes:" | |
theme_list=("$dir/themes"/*) | |
# Extract the filenames without the directory path and file extension | |
theme_list_modified=() | |
for theme in "${theme_list[@]}"; do | |
filename=$(basename "$theme") | |
theme_list_modified+=("${filename%.*}") | |
done | |
## PERSONAL RECOMENDATION (based on order) | |
# PencilDark | |
# Flatland | |
# Obsidian | |
# OceanicMaterial | |
# Neutron | |
# Highway | |
# MaterialDark | |
# OneDark | |
# snazzy | |
# Galaxy | |
# Tomorrow_Night | |
# Prompt the user to select a theme | |
PS3="Select a theme based on number: " | |
select theme in "${theme_list_modified[@]}"; do | |
if [[ -n $theme ]]; then | |
echo "$separator" | |
echo "Theme selected: $theme" | |
echo "$separator" | |
break | |
else | |
echo "Invalid option. Please try again." | |
fi | |
done | |
########################## | |
# Apply selected theme # | |
########################## | |
# Source and destination file paths | |
source_file="kitty-themes/themes/$theme.conf" | |
final_file="theme.conf" | |
# Check if the final file already exists | |
if [ -f "$final_file" ]; then | |
echo "The '$final_file' file already exists." | |
read -p "Do you want to override this file? (y/n): " choice | |
case $choice in | |
y|Y) | |
cp "$source_file" "$final_file" | |
echo $separator | |
echo "Theme $theme success applied, restart kitty terminal ..." | |
;; | |
n|N) | |
echo "Operation canceled. Exiting..." | |
exit 0 | |
;; | |
*) | |
echo "Invalid choice. Exiting..." | |
exit 1 | |
;; | |
esac | |
else | |
cp "$source_file" "$final_file" | |
echo $separator | |
echo "Theme $theme success applied, restart kitty terminal ..." | |
fi | |
######################### | |
# KITTY RESTART OPTION # | |
######################### | |
service_name="kitty" | |
pid=$(pidof "$service_name") | |
if [ -z "$pid" ]; then | |
echo "Service '$service_name' is not running." | |
else | |
echo "Service '$service_name' found with PID: $pid." | |
# Restart the service by sending SIGHUP signal | |
kill -SIGHUP "$pid" | |
start_command="kitty -d='~/'" | |
eval "nohup $start_command" | |
echo "Service restarted." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment