-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatppuccin-powerlevel10k-themes.plugin.zsh
42 lines (35 loc) · 1.29 KB
/
catppuccin-powerlevel10k-themes.plugin.zsh
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
# Define the apply_catppuccin function
apply_catppuccin() {
local theme="$1"
local flavour="$2"
# Check if both arguments are provided
if [[ -z "$theme" || -z "$flavour" ]]; then
echo "Error: Both theme and flavour must be provided."
echo "Usage: apply_catppuccin <theme> <flavour>"
return 1
fi
# List of valid Catppuccin flavours
local valid_flavours=("latte" "frappe" "macchiato" "mocha")
# Check if the provided flavour is valid
if [[ ! " ${valid_flavours[@]} " =~ " ${flavour} " ]]; then
echo "Error: Invalid flavour '${flavour}'."
echo "Valid flavours are: ${valid_flavours[*]}."
return 1
fi
# Construct the path to the theme file
local theme_file="${${(%):-%x}:A:h}/themes/.p10k-${theme}-catppuccin-${flavour}.zsh"
# Check if the theme file exists
if [[ ! -f "$theme_file" ]]; then
echo "Error: Theme '${theme}' not found."
return 1
fi
# Source the theme file
source "$theme_file"
# Check if the p10k.zsh file exists
if [[ -f "${ZDOTDIR:-$HOME}/.p10k.zsh" ]]; then
# Explicitly set POWERLEVEL9K_CONFIG_FILE to the .p10k.zsh file
typeset -g POWERLEVEL9K_CONFIG_FILE="${ZDOTDIR:-$HOME}/.p10k.zsh"
else
unset POWERLEVEL9K_CONFIG_FILE
fi
}