feat(custom): add logic to load modules form custom, status and window so that the user cand define it's own modules or override any existing one
This commit is contained in:
parent
79229bd979
commit
ab869e5704
4 changed files with 76 additions and 11 deletions
31
custom/README.md
Normal file
31
custom/README.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
# User defined modules
|
||||
|
||||
## Description
|
||||
|
||||
This folder is used to store user defined modules.
|
||||
You can use this folder to add a new module or override any existing module.
|
||||
To override an existing module, make sure you use the same name for your module as the module you want to override.
|
||||
You can also override the window module for current and default window.
|
||||
|
||||
## Create a new module
|
||||
|
||||
Use the [Module template](#module-template) (or example.sh) as a starting point when creating a new module.
|
||||
Save the new module under this folder using the module name as the file name and .sh as the extension.
|
||||
Update the status module list with your module.
|
||||
```sh
|
||||
set -g @catppuccin_status_modules "... <module_name> ..."
|
||||
|
||||
```
|
||||
|
||||
## Module template
|
||||
|
||||
show_<module_name>() { # save this module in a file with the name <module_name>.sh
|
||||
local index=$1 # this variable is used by the module loader in order to know the position of this module
|
||||
local icon="$(get_tmux_option "@catppuccin_<module_name>_icon" "<Use an icon from [nerdfonts](https://www.nerdfonts.com/cheat-sheet)>")"
|
||||
local color="$(get_tmux_option "@catppuccin_<module_name>_color" "<Use one of the default theme colors (ex: $thm_orange), or provide a color code (ex: #ef9f76)>")"
|
||||
local text="$(get_tmux_option "@catppuccin_<module_name>_text" "<Provide the text that you want to be displayed>")"
|
||||
|
||||
local module=$( build_status_module "$index" "$icon" "$color" "$text" )
|
||||
|
||||
echo $module
|
||||
}
|
10
custom/example.sh
Normal file
10
custom/example.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
show_example() {
|
||||
local index=$1
|
||||
local icon="$(get_tmux_option "@catppuccin_test_icon" "")"
|
||||
local color="$(get_tmux_option "@catppuccin_test_color" "$thm_blue")"
|
||||
local text="$(get_tmux_option "@catppuccin_test_text" "It works!")"
|
||||
|
||||
local module=$( build_status_module "$index" "$icon" "$color" "$text" )
|
||||
|
||||
echo $module
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue