♻️ refactor(spawn-window): better organize script

Split the icons and colors dictionaries into separate files to keep things managable
This commit is contained in:
2024-08-09 06:12:01 -04:00
parent 8d1332388c
commit 271e0a2816
3 changed files with 255 additions and 179 deletions
+84
View File
@@ -0,0 +1,84 @@
# colors.sh
# Define color codes
declare -A colors
colors=(
[rosewater]="#f4dbd6"
[flamingo]="#f0c6c6"
[pink]="#f5bde6"
[mauve]="#c6a0f6"
[red]="#ed8796"
[maroon]="#ee99a0"
[peach]="#f5a97f"
[yellow]="#eed49f"
[green]="#a6da95"
[teal]="#8bd5ca"
[sky]="#91d7e3"
[sapphire]="#7dc4e4"
[blue]="#8aadf4"
[lavender]="#b7bdf8"
[text]="#cad3f5"
[subtext1]="#b8c0e0"
[subtext0]="#a5adcb"
[overlay2]="#939ab7"
[overlay1]="#8087a2"
[overlay0]="#6e738d"
[surface2]="#5b6078"
[surface1]="#494d64"
[surface0]="#363a4f"
[base]="#24273a"
[mantle]="#1e2030"
[crust]="#181926"
[black]="#181926"
[white]="#cad3f5"
[gray]="#6e738d"
[grey]="#6e738d"
[silver]="#a5adcb"
[orange]="#f5a97f"
[brown]="#24273a"
[purple]="#b7bdf8"
[cyan]="#91d7e3"
[magenta]="#f5bde6"
[gold]="#eed49f"
[dark - rosewater]="#e0a4a0"
[dark - flamingo]="#d29a9a"
[dark - pink]="#d890b6"
[dark - mauve]="#9a6ed5"
[dark - red]="#c56a7a"
[dark - maroon]="#c27d7e"
[dark - peach]="#d78c4d"
[dark - yellow]="#d0b879"
[dark - green]="#85c07a"
[dark - teal]="#6a9e9a"
[dark - sky]="#6ba2b0"
[dark - sapphire]="#5b9ac0"
[dark - blue]="#6a7cc7"
[dark - lavender]="#8e8bcf"
[dark - text]="#9aacc6"
[dark - subtext1]="#8c9cb6"
[dark - subtext0]="#7a8a9f"
[dark - overlay2]="#6d7a8a"
[dark - overlay1]="#5c6d7e"
[dark - overlay0]="#4a5569"
[dark - surface2]="#464b5e"
[dark - surface1]="#313548"
[dark - surface0]="#252831"
[dark - base]="#1a1d26"
[dark - mantle]="#151a22"
[dark - crust]="#11161e"
[dark - black]="#11161e"
[dark - white]="#9aacc6"
[dark - gray]="#4a5569"
[dark - grey]="#4a5569"
[dark - silver]="#7a8a9f"
[dark - orange]="#d78c4d"
[dark - brown]="#1a1d26"
[dark - purple]="#8e8bcf"
[dark - cyan]="#6ba2b0"
[dark - magenta]="#d890b6"
[dark - gold]="#d0b879"
)
# Export the dictionary if needed
export colors
+157
View File
@@ -0,0 +1,157 @@
# Icon dictionary for NerdFont glyphs
declare -A icons=(
["code"]="󱃖 " # Code icon
["git"]="󰊢 " # Git icon
["docs"]=" " # Docs icon
["web"]="󰖟 " # Web icon
["music"]=" " # Music icon
["bug"]=" " # Bug icon
["info"]=" " # Info icon
["question"]=" " # Question icon
["warning"]=" " # Warning icon
["error"]=" " # Error icon
["folder"]=" " # Folder icon
["file"]=" " # File icon
["lock"]=" " # Lock icon
["unlock"]=" " # Unlock icon
["key"]=" " # Key icon
["search"]=" " # Search icon
["clock"]=" " # Clock icon
["calendar"]=" " # Calendar icon
["download"]=" " # Download icon
["vim"]=" " # Vim icon
["nvim"]=" " # Neovim icon
["neovim"]=" " # Neovim icon
["python"]=" " # Python icon
["shell"]=" " # Shell icon
["rust"]=" " # Rust icon
["go"]=" " # Go icon
["java"]=" " # Java icon
["lua"]=" " # Lua icon
["cat"]="󰄛 " # Cat icon
["dog"]="󰩄 " # Dog icon
["fish"]="󰈺 " # Fish icon
["cow"]="󰆚 " # Cow icon
["bird"]="󱗆 " # Bird icon
["config"]=" " # Config icon
["home"]=" " # Home icon
["game"]=" " # Game icon
["image"]=" " # Image icon
["video"]=" " # Video icon
["pdf"]=" " # PDF icon
["music2"]=" " # Music2 icon
["archive"]=" " # Archive icon
["heart"]=" " # Heart icon
["md"]="󰍔 " # MarkDown icon
["apple"]=" " # Apple icon
["mac"]=" " # Apple icon
["google"]=" " # Google icon
["microsoft"]=" " # Microsoft icon
["ms"]=" " # Microsoft icon
["windows"]=" " # Windows icon
["slack"]=" " # Slack icon
["linux"]=" " # Linux icon
["ubuntu"]="󰕈 " # Linux icon
["archlinux"]=" " # ArchLinux icon
["arch"]=" " # ArchLinux icon
["debian"]=" " # Debian icon
["fedora"]=" " # Fedora icon
["freebsd"]=" " # FreeBSD icon
["gentoo"]=" " # Gentoo icon
["manjaro"]=" " # Manjaro icon
["nixos"]=" " # NixOS icon
["opensuse"]=" " # OpenSUSE icon
["suse"]=" " # OpenSUSE icon
["redhat"]="󱄛 " # RedHat icon
["centos"]="󱄛 " # RedHat icon
["endeavoros"]=" " # EndeavorOS icon
["endeavor"]=" " # EndeavorOS icon
["eos"]=" " # EndeavorOS icon
["github"]=" " # GitHub icon
["gh"]=" " # GitHub icon
["youtube"]=" " # YouTube icon
["yt"]=" " # YouTube icon
["poop"]="󰇷 " # Poop icon
["sun"]="󰖙 " # Sun icon
["moon"]=" " # Moon icon
["rain"]=" " # Rain icon
["cloud"]=" " # Cloud icon
["alien"]="󰢚 " # Alien icon
["lightbulb"]=" " # Lightbulb icon
["lightning"]=" " # Lightning icon
["night"]=" " # Night icon
["day"]=" " # Day icon
["chat"]="󰭹 " # Chat icon
["mail"]=" " # Mail icon
["terminal"]=" " # Terminal icon
["sleep"]=" " # Sleep icon
["bed"]=" " # Sleep icon
["note"]=" " # Note icon
["notes"]=" " # Note icon
["fire"]=" " # Fire icon
["trash"]=" " # Trash icon
["garbage"]=" " # Trash icon
["trashcan"]=" " # Trash icon
["recycle"]=" " # Trash icon
["water"]="󰖌 " # Water icon
["beer"]=" " # Beer icon
["coffee"]=" " # Coffee icon
["cake"]="󰃩 " # Cake icon
["package"]=" " # Package icon
["inbox"]=" " # Inbox icon
["outbox"]=" " # Outbox icon
["scissors"]=" " # Scissors icon
["stats"]=" " # Stats icon
["database"]=" " # Database icon
["link"]=" " # Link icon
["flag"]=" " # Flag icon
["pizza"]=" " # Pizza icon
["burger"]="󰚅 " # Burger icon
["success"]=" " # Success icon
["fail"]=" " # Fail icon
["warn"]=" " # Warn icon
["alert"]=" " # Warn icon
["car"]=" " # Car icon
["bicycle"]="󰂣 " # Bicycle icon
["bike"]="󰂣 " # Bicycle icon
["airplane"]=" " # Airplane icon
["plane"]=" " # Airplane icon
["boat"]="󰻈 " # Boat icon
["sailboat"]="󰻈 " # Boat icon
["ship"]=" " # Ship icon
["shipit"]=" " # Ship icon
["train"]=" " # Train icon
["subway"]=" " # Subway icon
["bus"]=" " # Bus icon
["motorbike"]=" " # Motorcycle icon
["motorcycle"]=" " # Motorcycle icon
["truck"]=" " # Truck icon
["rocket"]="󱓞 " # Rocket icon
["helicopter"]="󰫂 " # Helicopter icon
["anchor"]=" " # Anchor icon
["planet"]=" " # Planet icon
["map"]=" " # Map icon
["brain"]="󰧑 " # Brain icon
["heartbeat"]=" " # heartbeat icon
["paw"]=" " # Paw icon
["eye"]=" " # Eye icon
["eye-opened"]=" " # Eye icon
["eye-open"]=" " # Eye icon
["eye-off"]=" " # Eye-off icon
["eye-slash"]=" " # Eye-off icon
["eye-closed"]=" " # Eye-off icon
["eye-close"]=" " # Eye-off icon
["feather"]="󰛓 " # Feather icon
["pencil"]=" " # Pencil icon
["pen"]="󰏪 " # Pen icon
["paint"]=" " # Paint icon
["smoke"]="󱞙 " # Smoke icon
["fireplace"]="󰸮 " # Fireplace icon
["yes"]=" " # Yes icon
["no"]=" " # No icon
["on"]=" " # On icon
["off"]=" " # Off icon
)
# Export the dictionary if needed
export icons
+12 -177
View File
@@ -1,5 +1,14 @@
#!/bin/bash #!/bin/bash
# Determine the directory of the current script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Source the icons dictionary
source "$SCRIPT_DIR/icons-dict.sh"
# Source the colors dictionary
source "$SCRIPT_DIR/colors-dict.sh"
# Default values # Default values
type="tab" type="tab"
title="" title=""
@@ -12,180 +21,11 @@ cmd=""
cmd_flag="" cmd_flag=""
icon="" icon=""
# Icon dictionary for NerdFont glyphs # Function to convert color names to hex codes
declare -A icons=(
["code"]="󱃖 " # Code icon
["git"]="󰊢 " # Git icon
["docs"]=" " # Docs icon
["web"]="󰖟 " # Web icon
["music"]=" " # Music icon
["bug"]=" " # Bug icon
["info"]=" " # Info icon
["question"]=" " # Question icon
["warning"]=" " # Warning icon
["error"]=" " # Error icon
["folder"]=" " # Folder icon
["file"]=" " # File icon
["lock"]=" " # Lock icon
["unlock"]=" " # Unlock icon
["key"]=" " # Key icon
["search"]=" " # Search icon
["clock"]=" " # Clock icon
["calendar"]=" " # Calendar icon
["download"]=" " # Download icon
["vim"]=" " # Vim icon
["nvim"]=" " # Neovim icon
["neovim"]=" " # Neovim icon
["python"]=" " # Python icon
["shell"]=" " # Shell icon
["rust"]=" " # Rust icon
["go"]=" " # Go icon
["java"]=" " # Java icon
["lua"]=" " # Lua icon
["cat"]="󰄛 " # Cat icon
["dog"]="󰩄 " # Dog icon
["fish"]="󰈺 " # Fish icon
["cow"]="󰆚 " # Cow icon
["bird"]="󱗆 " # Bird icon
["config"]=" " # Config icon
["home"]=" " # Home icon
["game"]=" " # Game icon
["image"]=" " # Image icon
["video"]=" " # Video icon
["pdf"]=" " # PDF icon
["music2"]=" " # Music2 icon
["archive"]=" " # Archive icon
["heart"]=" " # Heart icon
["md"]="󰍔 " # MarkDown icon
["apple"]=" " # Apple icon
["mac"]=" " # Apple icon
["google"]=" " # Google icon
["microsoft"]=" " # Microsoft icon
["ms"]=" " # Microsoft icon
["windows"]=" " # Windows icon
["slack"]=" " # Slack icon
["linux"]=" " # Linux icon
["ubuntu"]="󰕈 " # Linux icon
["archlinux"]=" " # ArchLinux icon
["arch"]=" " # ArchLinux icon
["debian"]=" " # Debian icon
["fedora"]=" " # Fedora icon
["freebsd"]=" " # FreeBSD icon
["gentoo"]=" " # Gentoo icon
["manjaro"]=" " # Manjaro icon
["nixos"]=" " # NixOS icon
["opensuse"]=" " # OpenSUSE icon
["suse"]=" " # OpenSUSE icon
["redhat"]="󱄛 " # RedHat icon
["centos"]="󱄛 " # RedHat icon
["endeavoros"]=" " # EndeavorOS icon
["endeavor"]=" " # EndeavorOS icon
["eos"]=" " # EndeavorOS icon
["github"]=" " # GitHub icon
["gh"]=" " # GitHub icon
["youtube"]=" " # YouTube icon
["yt"]=" " # YouTube icon
["poop"]="󰇷 " # Poop icon
["sun"]="󰖙 " # Sun icon
["moon"]=" " # Moon icon
["rain"]=" " # Rain icon
["cloud"]=" " # Cloud icon
["alien"]="󰢚 " # Alien icon
["lightbulb"]=" " # Lightbulb icon
["lightning"]=" " # Lightning icon
["night"]=" " # Night icon
["day"]=" " # Day icon
["chat"]="󰭹 " # Chat icon
["mail"]=" " # Mail icon
["terminal"]=" " # Terminal icon
["sleep"]=" " # Sleep icon
["bed"]=" " # Sleep icon
["note"]=" " # Note icon
["notes"]=" " # Note icon
["fire"]=" " # Fire icon
["trash"]=" " # Trash icon
["garbage"]=" " # Trash icon
["trashcan"]=" " # Trash icon
["recycle"]=" " # Trash icon
["water"]="󰖌 " # Water icon
["beer"]=" " # Beer icon
["coffee"]=" " # Coffee icon
["cake"]="󰃩 " # Cake icon
["package"]=" " # Package icon
["inbox"]=" " # Inbox icon
["outbox"]=" " # Outbox icon
["scissors"]=" " # Scissors icon
["stats"]=" " # Stats icon
["database"]=" " # Database icon
["link"]=" " # Link icon
["flag"]=" " # Flag icon
["pizza"]=" " # Pizza icon
["burger"]="󰚅 " # Burger icon
["success"]=" " # Success icon
["fail"]=" " # Fail icon
["warn"]=" " # Warn icon
["alert"]=" " # Warn icon
["car"]=" " # Car icon
["bicycle"]="󰂣 " # Bicycle icon
["bike"]="󰂣 " # Bicycle icon
["airplane"]=" " # Airplane icon
["plane"]=" " # Airplane icon
["boat"]="󰻈 " # Boat icon
["sailboat"]="󰻈 " # Boat icon
["ship"]=" " # Ship icon
["shipit"]=" " # Ship icon
["train"]=" " # Train icon
["subway"]=" " # Subway icon
["bus"]=" " # Bus icon
["motorbike"]=" " # Motorcycle icon
["motorcycle"]=" " # Motorcycle icon
["truck"]=" " # Truck icon
)
# Catppuccin Macchiato color palette with additional common colors
convert_color() { convert_color() {
case "$1" in local color_name="$1"
rosewater) echo "#f4dbd6" ;; echo "${colors[$color_name]:-$color_name}"
flamingo) echo "#f0c6c6" ;;
pink) echo "#f5bde6" ;;
mauve) echo "#c6a0f6" ;;
red) echo "#ed8796" ;;
maroon) echo "#ee99a0" ;;
peach) echo "#f5a97f" ;;
yellow) echo "#eed49f" ;;
green) echo "#a6da95" ;;
teal) echo "#8bd5ca" ;;
sky) echo "#91d7e3" ;;
sapphire) echo "#7dc4e4" ;;
blue) echo "#8aadf4" ;;
lavender) echo "#b7bdf8" ;;
text) echo "#cad3f5" ;;
subtext1) echo "#b8c0e0" ;;
subtext0) echo "#a5adcb" ;;
overlay2) echo "#939ab7" ;;
overlay1) echo "#8087a2" ;;
overlay0) echo "#6e738d" ;;
surface2) echo "#5b6078" ;;
surface1) echo "#494d64" ;;
surface0) echo "#363a4f" ;;
base) echo "#24273a" ;;
mantle) echo "#1e2030" ;;
crust) echo "#181926" ;;
black) echo "#181926" ;; # Crust
white) echo "#cad3f5" ;; # Text
gray) echo "#6e738d" ;; # Overlay0
grey) echo "#6e738d" ;; # Overlay0
silver) echo "#a5adcb" ;; # Subtext0
orange) echo "#f5a97f" ;; # Peach
brown) echo "#24273a" ;; # Base
purple) echo "#b7bdf8" ;; # Lavender
cyan) echo "#91d7e3" ;; # Sky
magenta) echo "#f5bde6" ;; # Pink
gold) echo "#eed49f" ;; # Yellow
*) echo "$1" ;; # If not a recognized color, assume it's already a hex code
esac
} }
# Function to show usage # Function to show usage
usage() { usage() {
echo "Usage: $0 [options] [command]" echo "Usage: $0 [options] [command]"
@@ -317,13 +157,8 @@ esac
# Set the title with the icon if provided # Set the title with the icon if provided
if [[ -n "$icon" ]]; then if [[ -n "$icon" ]]; then
if [[ "$type" == "tab" ]]; then
title_with_icon="$icon$title" title_with_icon="$icon$title"
title_without_icon="$title" title_without_icon="$title"
else
title_with_icon="$icon $title"
title_without_icon="$title"
fi
else else
title_with_icon="$title" title_with_icon="$title"
title_without_icon="$title" title_without_icon="$title"