Skip to content

Commit

Permalink
Fix formatting and mention required plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
qadzek committed Mar 17, 2024
1 parent e0d6f84 commit 0c6d2d3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
47 changes: 26 additions & 21 deletions custom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@

## 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 that you use the same name for your module as the module you want to override.
You can also override the window module for the current and default window.
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 that you use the same name for your module as the module you
want to override. You can also override the window module for the current and
default window.

## Create a new module
## Creating A New Module

You can create a custom module by following these steps.
Note that changes will only take effect after reloading your Tmux configuration by executing `tmux source-file ~/.tmux.conf`.
> [!NOTE]
> Changes will only be applied after reloading your Tmux configuration by executing `tmux source-file ~/.tmux.conf`.
### New file
You can create a custom module by following the steps outlined below. This can be something you create entirely by yourself or integrating an existing Tmux plugin.

Create a new file in `~/.tmux/plugins/tmux/custom/<module_name>.sh`, to store the custom module. The extension has to be `.sh`. Making this file executable is not necessary.
1. Create a new file in `~/.tmux/plugins/tmux/custom/<module_name>.sh` to store the custom module.

### File content
- The file **must** end in `.sh`
- The file **does not** need to be set as executable.

Copy the following template to that file. Make sure to replace every instance of `<module_name>` by the name you chose as filename.
2. Copy the following template to this new file. Make sure to replace every instance of `<module_name>` by the name you chose as filename.

```bash
# If this module depends on an external Tmux plugin, say so in a comment.
# E.g.: Requires https://github.com/aaronpowell/tmux-weather

```sh
show_<module_name>() { # This function name must match the module name!
local index icon color text module

index=$1 # This variable is used internally by the module loader in order to know the position of this module
index=$1 # This variable is used internally by the module loader in order to know the position of this module

icon="$( get_tmux_option "@catppuccin_<module_name>_icon" "" )"
color="$( get_tmux_option "@catppuccin_<module_name>_color" "$thm_orange" )"
text="$( get_tmux_option "@catppuccin_<module_name>_text" "hello world" )"
Expand All @@ -35,27 +41,26 @@ show_<module_name>() { # This function name must match the module name!
}
```

### Status module list

Add the custom module to the list of modules in `.tmux.conf`
3. Add the custom module to the list of modules in `.tmux.conf`

```tmux
```bash
set -g @catppuccin_status_modules_right "... <module_name> ..."
```

### Customization
## Customization

Change the icon to one from [Nerd Fonts](https://www.nerdfonts.com/cheat-sheet).
Change the color to one of the [official colors](https://github.com/catppuccin/tmux/blob/main/catppuccin-macchiato.tmuxtheme), for instance `"$thm_orange"`, or to a hexadecimal color like `"#00ff00"`.

Change the color to one of the [official colors](../catppuccin-macchiato.tmuxtheme), for instance `"$thm_cyan"`, or to a hexadecimal color like `"#00ff00"`.

The text to display can either be:

- A static text, e.g. `"hello world"`.
- The output of a command, e.g. `"#( date +%T )"`.
- The output of a script, e.g. `"#( $HOME/my_script.sh )"` . Any script will do, e.g. a Bash or Python script that prints some text, but ensure that it is executable `chmod u+x my_script.sh`.
- The output of a script, e.g. `"#( $HOME/my_script.sh )"` . Any script will do, e.g. a Bash or Python script that prints some text, but ensure that it is executable: `chmod u+x my_script.sh`.
- An existing Tmux plugin, e.g. `" #{forecast} "` for the [Tmux Weather plugin](https://github.com/aaronpowell/tmux-weather).

Note that the icon and the color can be generated dynamically as well, by having a Bash script e.g. `echo` a hexadecimal color.
Note that the icon and the color can be generated dynamically as well, for instance by having a Bash script `echo` a hexadecimal color.

To modify how often the modules are updated, add the following to `.tmux.conf`:

Expand Down
3 changes: 3 additions & 0 deletions custom/example.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# If this module depends on an external Tmux plugin, say so in a comment.
# E.g.: Requires https://github.com/aaronpowell/tmux-weather

show_test() { # This function name must match the module name!
local index icon color text module

Expand Down

0 comments on commit 0c6d2d3

Please sign in to comment.