diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d86ac02 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,34 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# EditorConfig is awesome: https://EditorConfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 2 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +# go +[*.go] +indent_style = tab +indent_size = 4 + +# python +[*.{ini,py,py.tpl,rst}] +indent_size = 4 + +# rust +[*.rs] +indent_size = 4 + +# documentation, utils +[*.{md,mdx,diff}] +trim_trailing_whitespace = false + +# windows shell scripts +[*.{cmd,bat,ps1}] +end_of_line = crlf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..beab4f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +custom +!custom/README.md +!custom/example.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..006383b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Catppuccin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..6c3436c --- /dev/null +++ b/README.md @@ -0,0 +1,538 @@ +

+ Logo
+ + Catppuccin for Tmux + +

+ +

+ + + +

+ +

+ +

+ +## Content + +1. [Themes](#themes) +2. [Installation](#installation) +3. [Overview](#overview) +4. [Configuration options](#configuration-options) + 1. [Window](#window) + 2. [Window default](#window-default) + 3. [Window current](#window-current) + 4. [Status](#status) + 4. [Pane](#pane) + 5. [Customizing modules](#customizing-modules) + 6. [Battery module](#battery-module) + 7. [CPU module](#CPU-module) + 8. [Weather module](#weather-module) + 9. [Load module](#load-module) + 10. [Uptime module](#uptime-module) +5. [Create a custom module](#create-a-custom-module) +6. [Configuration Examples](#configuration-examples) + 1. [Config 1](#config-1) + 2. [Config 2](#config-2) + 3. [Config 3](#config-3) + +## Themes + +- ๐ŸŒป [Latte](./catppuccin-latte.tmuxtheme) +- ๐Ÿชด [Frappรฉ](./catppuccin-frappe.tmuxtheme) +- ๐ŸŒบ [Macchiato](./catppuccin-macchiato.tmuxtheme) +- ๐ŸŒฟ [Mocha](./catppuccin-mocha.tmuxtheme) + +## Installation + +In order to have the icons displayed correctly please use/update your favorite [patched font](https://www.nerdfonts.com/font-downloads). +If you do not have a patched font installed, you can override or remove any icon. Check the documentation below on the options available. + +### TPM + +1. Install [TPM](https://github.com/tmux-plugins/tpm) +2. Add the Catppuccin plugin: + +```bash +set -g @plugin 'catppuccin/tmux' +# ...alongside +set -g @plugin 'tmux-plugins/tpm' +``` + +3. (Optional) Set your preferred flavor, it defaults to `"mocha"`: + +```bash +set -g @catppuccin_flavour 'latte' # or frappe, macchiato, mocha +``` + +### Manual + +1. Clone this repository to your desired location (e.g. + `~/.config/tmux/plugins/catppuccin`) +2. Add the following line to your `tmux.conf` file: + `run ~/.config/tmux/plugins/catppuccin/catppuccin.tmux` +3. (Optional) Set your preferred flavor and/or add configuration options as + listed in [Configuration Options](#configuration-options). +4. Reload Tmux by either restarting the session or reloading it with `tmux source-file ~/.tmux.conf` + +## Overview + +![Default](./assets/overview.png) +This is a diagram of how the theme is split between its components. + +## Configuration options + +All flavors support certain levels of customization that match our [Catppuccin +Style Guide][style-guide]. To add these customizations, add any of the following +options to your Tmux configuration. + +### Window + +#### Set the window left separator: +```sh +set -g @catppuccin_window_left_separator "โ–ˆ" +``` + +#### Set the window middle separator: +```sh +set -g @catppuccin_window_middle_separator "โ–ˆ" +``` + +#### Set the window right separator: +```sh +set -g @catppuccin_window_right_separator "โ–ˆ" +``` + +#### Position the number: +```sh +set -g @catppuccin_window_number_position "left" +``` +Values: +- left - the number will be on the left part of the window +- right - the number will be on the right part of the window + +#### Enable window status: +```sh +set -g @catppuccin_window_status_enable "yes" +``` +Values: +- yes - this will enable the window status part +- no - this will disable the window status part + +#### Enable window status icons instead of text: +```sh +set -g @catppuccin_window_status_icon_enable "yes" +``` +Values: +- yes - this will replace the windows status text with icons +- no - this will keep the windows status in text format + +#### Override windows status icons +```sh +set -g @catppuccin_icon_window_last "๓ฐ–ฐ " +set -g @catppuccin_icon_window_current "๓ฐ–ฏ " +set -g @catppuccin_icon_window_zoom "๓ฐŒ " +set -g @catppuccin_icon_window_mark "๓ฐƒ€ " +set -g @catppuccin_icon_window_silent "๓ฐ‚› " +set -g @catppuccin_icon_window_activity "๓ฑ…ซ " +set -g @catppuccin_icon_window_bell "๓ฐ‚ž " +``` + +### Window default + +#### Set the window default color fill: +```sh +set -g @catppuccin_window_default_fill "number" +``` +Values: +- number - only the number of the window part will have color +- all - the entire window part will have the same color +- none - the entire window part will have no color + +#### Override the window default colors: +```sh +set -g @catppuccin_window_default_color "color" # text color +set -g @catppuccin_window_default_background "color" +``` + +Values: +- color - a hexadecimal color value + +#### Override the window default text: +```sh +set -g @catppuccin_window_default_text "#{b:pane_current_path}" # use "#W" for application instead of directory +``` + +### Window current + +#### Set the window current color fill: +```sh +set -g @catppuccin_window_current_fill "number" +``` +Values: +- number - only the number of the window part will have color +- all - the entire window part will have the same color +- none - the entire window part will have no color + +#### Override the window current colors: +```sh +set -g @catppuccin_window_current_color "color" # text color +set -g @catppuccin_window_current_background "color" +``` + +Values: +- color - a hexadecimal color value + +#### Override the window current text: +```sh +set -g @catppuccin_window_current_text "#{b:pane_current_path}" # use "#W" for application instead of directory +``` + +#### Set the current directory format +```sh +set -g @catppuccin_window_current_format_directory_text "#{b:pane_current_path}" +``` +Use this to override the way the current directory is displayed. + +#### Set the directory format +```sh +set -g @catppuccin_window_format_directory_text "#{b:pane_current_path}" +``` +Use this to override the way the directory is displayed. + +### Pane + +#### Set the pane border style: + +```sh +set -g @catppuccin_pane_border_style "fg=blue" # Use a value compatible with the standard tmux 'pane-border-style' +``` + +#### Set the pane active border style: + +```sh +set -g @catppuccin_pane_active_border_style "fg=red" # Use a value compatible with the standard tmux 'pane-border-active-style' +``` + + +### Status +#### Set the default status bar visibility +```sh +set -g @catppuccin_status_default "off" # defaults to "on" +``` + +#### Set the status module left separator: +```sh +set -g @catppuccin_status_left_separator "๎‚ถ" +``` + +#### Set the status module right separator: +```sh +set -g @catppuccin_status_right_separator "โ–ˆ" +``` + +#### Set the status module right separator inverse: +```sh +set -g @catppuccin_status_right_separator_inverse "no" +``` +Values: +- yes - the colors will be inverted for the right separator +- no - the colors will not be inverted for the right separator + +#### Set the status connect separator: +```sh +set -g @catppuccin_status_connect_separator "yes" +``` +Values: +- yes - the background color of the separator will not blend in with the background color of tmux +- no - the background color of the separator will blend in with the background color of tmux + + +#### Set the status module color fill: +```sh +set -g @catppuccin_status_fill "icon" +``` +Values: +- icon - only the icon of the module will have color +- all - the entire module will have the same color + +#### Set the status module justify value: +```sh +set -g @catppuccin_status_justify "left" +``` +Values: +- left +- centre - puts the window list in the relative centre of the available free space +- right +- absolute-centre - uses the centre of the entire horizontal space + +### Pane + +```sh +tmux_orange="#fab387" +set -g @catppuccin_pane_status_enabled "yes" +set -g @catppuccin_pane_border_status "top" +set -g @catppuccin_pane_left_separator "๎‚ถ" +set -g @catppuccin_pane_right_separator "๎‚ด" +set -g @catppuccin_pane_middle_separator "โ–ˆ " +set -g @catppuccin_pane_number_position "left" +set -g @catppuccin_pane_default_fill "number" +set -g @catppuccin_pane_default_text "#{b:pane_current_path}" +set -g @catppuccin_pane_border_style "fg=$tmux_orange" +set -g @catppuccin_pane_active_border_style "fg=$tmux_orange" +set -g @catppuccin_pane_color "$tmux_orange" +set -g @catppuccin_pane_background_color "$tmux_orange" +``` + +#### Set the module list +```sh +set -g @catppuccin_status_modules_right "application session" +set -g @catppuccin_status_modules_left "" +``` +Provide a list of modules and the order in which you want them to appear in the status. + +Available modules: +- application - display the current window running application +- directory - display the basename of the current window path +- session - display the number of tmux sessions running +- user - display the username +- host - display the hostname +- date_time - display the date and time +- [battery](#battery-module) - display the battery + +### Customizing modules + +Every module (except the module "session") supports the following overrides: + +#### Override the specific module icon +```sh +set -g @catppuccin_[module_name]_icon "icon" +``` + +#### Override the specific module color +```sh +set -g @catppuccin_[module_name]_color "color" +``` + +#### Override the specific module text +```sh +set -g @catppuccin_[module_name]_text "text" +``` + +#### Removing a specific module option +```sh +set -g @catppuccin_[module_name]_[option] "null" +``` +This is for the situation where you want to remove the icon from a module. +Ex: +```sh +set -g @catppuccin_date_time_icon "null" +``` + +### Battery module + +#### Requirements +This module depends on [tmux-battery](https://github.com/tmux-plugins/tmux-battery/tree/master). + +#### Install +The preferred way to install tmux-battery is using [TPM](https://github.com/tmux-plugins/tpm). + +#### Configure +Load tmux-battery after you load catppuccin. +```sh +set -g @plugin 'catppuccin/tmux' +... +set -g @plugin 'tmux-plugins/tmux-battery' +``` + +Add the battery module to the status modules list. +```sh +set -g @catppuccin_status_modules_right "... battery ..." +``` + +### CPU module + +#### Requirements +This module depends on [tmux-cpu](https://github.com/tmux-plugins/tmux-cpu/tree/master). + +#### Install +The preferred way to install tmux-cpu is using [TPM](https://github.com/tmux-plugins/tpm). + +#### Configure +Load tmux-cpu after you load catppuccin. +```sh +set -g @plugin 'catppuccin/tmux' +... +set -g @plugin 'tmux-plugins/tmux-cpu' +``` + +Add the cpu module to the status modules list. +```sh +set -g @catppuccin_status_modules_right "... cpu ..." +``` + +### Weather module + +#### Requirements +This module depends on [tmux-weather](https://github.com/xamut/tmux-weather). + +#### Install +The preferred way to install tmux-weather is using [TPM](https://github.com/tmux-plugins/tpm). + +#### Configure +Load tmux-weather after you load catppuccin. +```sh +set -g @plugin 'catppuccin/tmux' +... +set -g @plugin 'xamut/tmux-weather' +``` + +Add the weather module to the status modules list. +```sh +set -g @catppuccin_status_modules_right "... weather ..." +``` + +### Load module + +#### Requirements +This module depends on [tmux-loadavg](https://github.com/jamesoff/tmux-loadavg). + +#### Install +The preferred way to install tmux-loadavg is using [TPM](https://github.com/tmux-plugins/tpm). + +#### Configure +Load tmux-loadavg after you load catppuccin. +```sh +set -g @plugin 'catppuccin/tmux' +... +set -g @plugin 'jamesoff/tmux-loadavg' +``` + +Add the load module to the status modules list. +```sh +set -g @catppuccin_status_modules_right "... load ..." +``` + +### Uptime module + +#### Requirements +This module depends on [tmux-uptime](https://github.com/robhurring/tmux-uptime). + +#### Install +The preferred way to install tmux-uptime is using [TPM](https://github.com/tmux-plugins/tpm). + +#### Configure +Load tmux-uptime after you load catppuccin. + +```sh +set -g @plugin 'catppuccin/tmux' +... +set -g @plugin 'robhurring/tmux-uptime' +``` + +Add the uptime module to the status modules list. +```sh +set -g @catppuccin_status_modules_right "... uptime ..." +``` + +## Create a custom module + +It is possible to add a new custom module or overwrite any of the existing modules. + +For further details, see the documentation in [custom/README.md](custom/README.md) + +Any file added to the custom folder will be preserved when updating catppuccin. + +## Configuration Examples +Below are provided a few configurations as examples or starting points. + +Note: +When switching between configurations run: +```sh +tmux kill-server +``` +To kill the tmux server and clear all global variables. + + +### Config 1 +![Default](./assets/config1.png) + +```sh +set -g @catppuccin_window_right_separator "โ–ˆย " +set -g @catppuccin_window_number_position "right" +set -g @catppuccin_window_middle_separator " | " + +set -g @catppuccin_window_default_fill "none" + +set -g @catppuccin_window_current_fill "all" + +set -g @catppuccin_status_modules_right "application session user host date_time" +set -g @catppuccin_status_left_separator "โ–ˆ" +set -g @catppuccin_status_right_separator "โ–ˆ" + +set -g @catppuccin_date_time_text "%Y-%m-%d %H:%M:%S" +``` + +### Config 2 +![Default](./assets/config2.png) + +```sh +set -g @catppuccin_window_left_separator "๎‚บโ–ˆ" +set -g @catppuccin_window_right_separator "โ–ˆ๎‚ผย " +set -g @catppuccin_window_number_position "right" +set -g @catppuccin_window_middle_separator " ๎‚บโ–ˆ" + +set -g @catppuccin_window_default_fill "number" + +set -g @catppuccin_window_current_fill "number" +set -g @catppuccin_window_current_text "#{pane_current_path}" + +set -g @catppuccin_status_modules_right "application session date_time" +set -g @catppuccin_status_left_separator "๎‚ถ" +set -g @catppuccin_status_right_separator " ๎‚ถ" +set -g @catppuccin_status_right_separator_inverse "yes" +set -g @catppuccin_status_fill "all" +set -g @catppuccin_status_connect_separator "no" +``` + +### Config 3 +![Default](./assets/config3.png) + +```sh +set -g @catppuccin_window_left_separator "๎‚ถ" +set -g @catppuccin_window_right_separator "๎‚ดย " +set -g @catppuccin_window_middle_separator " โ–ˆ" +set -g @catppuccin_window_number_position "right" + +set -g @catppuccin_window_default_fill "number" +set -g @catppuccin_window_default_text "#W" + +set -g @catppuccin_window_current_fill "number" +set -g @catppuccin_window_current_text "#W" + +set -g @catppuccin_status_modules_right "directory user host session" +set -g @catppuccin_status_left_separator " ๎‚ถ" +set -g @catppuccin_status_right_separator "๎‚ด" +set -g @catppuccin_status_right_separator_inverse "no" +set -g @catppuccin_status_fill "icon" +set -g @catppuccin_status_connect_separator "no" + +set -g @catppuccin_directory_text "#{pane_current_path}" +``` + +[style-guide]: https://github.com/catppuccin/catppuccin/blob/main/docs/style-guide.md + +## ๐Ÿ’ Thanks to + +- [Pocco81](https://github.com/catppuccin) +- [vinnyA3](https://github.com/vinnyA3) +- [rogeruiz](https://github.com/rogeruiz) + +  + +

+

Copyright © 2021-present Catppuccin Org +

+ diff --git a/bamboo-dark.tmuxtheme b/bamboo-dark.tmuxtheme new file mode 100644 index 0000000..b4e1c1b --- /dev/null +++ b/bamboo-dark.tmuxtheme @@ -0,0 +1,17 @@ +# NOTE: you can use vars with $ and ${} as long as the str is double quoted: "" +# WARNING: hex colors can't contain capital letters + +# --> Bamboo (Dark) +thm_bg="#1e1e2e" +thm_fg="#cdd6f4" +thm_cyan="#89dceb" +thm_black="#181825" +thm_gray="#313244" +thm_magenta="#cba6f7" +thm_pink="#f5c2e7" +thm_red="#f38ba8" +thm_green="#a6e3a1" +thm_yellow="#f9e2af" +thm_blue="#89b4fa" +thm_orange="#fab387" +thm_black4="#585b70" diff --git a/bamboo.tmux b/bamboo.tmux new file mode 100644 index 0000000..dc757d6 --- /dev/null +++ b/bamboo.tmux @@ -0,0 +1,399 @@ +#!/usr/bin/env bash +PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +get_tmux_option() { + local option value default + option="$1" + default="$2" + value=$(tmux show-option -gqv "$option") + + if [ -n "$value" ] + then + if [ "$value" = "null" ] + then + echo "" + + else + echo "$value" + fi + + else + echo "$default" + + fi +} + +set() { + local option=$1 + local value=$2 + tmux_commands+=(set-option -gq "$option" "$value" ";") +} + +setw() { + local option=$1 + local value=$2 + tmux_commands+=(set-window-option -gq "$option" "$value" ";") +} + +build_window_icon() { + local window_status_icon_enable=$(get_tmux_option "@bamboo_window_status_icon_enable" "yes") + local custom_icon_window_last=$(get_tmux_option "@bamboo_icon_window_last" "๓ฐ–ฐ ") + local custom_icon_window_current=$(get_tmux_option "@bamboo_icon_window_current" "๓ฐ–ฏ ") + local custom_icon_window_zoom=$(get_tmux_option "@bamboo_icon_window_zoom" "๓ฐŒ ") + local custom_icon_window_mark=$(get_tmux_option "@bamboo_icon_window_mark" "๓ฐƒ€ ") + local custom_icon_window_silent=$(get_tmux_option "@bamboo_icon_window_silent" "๓ฐ‚› ") + local custom_icon_window_activity=$(get_tmux_option "@bamboo_icon_window_activity" "๓ฑ…ซ ") + local custom_icon_window_bell=$(get_tmux_option "@bamboo_icon_window_bell" "๓ฐ‚ž ") + + if [ "$window_status_icon_enable" = "yes" ] + then + # #!~[*-]MZ + local show_window_status="#{?window_activity_flag,${custom_icon_window_activity},}#{?window_bell_flag,${custom_icon_window_bell},}#{?window_silence_flag,${custom_icon_window_silent},}#{?window_active,${custom_icon_window_current},}#{?window_last_flag,${custom_icon_window_last},}#{?window_marked_flag,${custom_icon_window_mark},}#{?window_zoomed_flag,${custom_icon_window_zoom},}" + fi + + if [ "$window_status_icon_enable" = "no" ] + then + local show_window_status="#F" + fi + + echo "$show_window_status" +} + +build_pane_format() { + local number=$1 + local color=$2 + local background=$3 + local text=$4 + local fill=$5 + + if [ "$pane_status_enable" = "yes" ] + then + if [ "$fill" = "none" ] + then + local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$pane_left_separator" + local show_number="#[fg=$thm_fg,bg=$thm_gray]$number" + local show_middle_separator="#[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics]$pane_middle_separator" + local show_text="#[fg=$thm_fg,bg=$thm_gray]$text" + local show_right_separator="#[fg=$thm_gray,bg=$thm_bg]$pane_right_separator" + fi + + if [ "$fill" = "all" ] + then + local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$pane_left_separator" + local show_number="#[fg=$background,bg=$color]$number" + local show_middle_separator="#[fg=$background,bg=$color,nobold,nounderscore,noitalics]$pane_middle_separator" + local show_text="#[fg=$background,bg=$color]$text" + local show_right_separator="#[fg=$color,bg=$thm_bg]$pane_right_separator" + fi + + if [ "$fill" = "number" ] + then + local show_number="#[fg=$background,bg=$color]$number" + local show_middle_separator="#[fg=$color,bg=$background,nobold,nounderscore,noitalics]$pane_middle_separator" + local show_text="#[fg=$thm_fg,bg=$background]$text" + + if [ "$pane_number_position" = "right" ] + then + local show_left_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$pane_left_separator" + local show_right_separator="#[fg=$color,bg=$thm_bg]$pane_right_separator" + fi + + if [ "$pane_number_position" = "left" ] + then + local show_right_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$pane_right_separator" + local show_left_separator="#[fg=$color,bg=$thm_bg]$pane_left_separator" + fi + + fi + + local final_pane_format + + if [ "$pane_number_position" = "right" ] + then + final_pane_format="$show_left_separator$show_text$show_middle_separator$show_number$show_right_separator" + fi + + if [ "$pane_number_position" = "left" ] + then + final_pane_format="$show_left_separator$show_number$show_middle_separator$show_text$show_right_separator" + fi + + echo "$final_pane_format" + fi +} + +build_window_format() { + local number=$1 + local color=$2 + local background=$3 + local text=$4 + local fill=$5 + + if [ "$window_status_enable" = "yes" ] + then + local icon="$( build_window_icon )" + text="$text $icon" + fi + + if [ "$fill" = "none" ] + then + local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" + local show_number="#[fg=$thm_fg,bg=$thm_gray]$number" + local show_middle_separator="#[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics]$window_middle_separator" + local show_text="#[fg=$thm_fg,bg=$thm_gray]$text" + local show_right_separator="#[fg=$thm_gray,bg=$thm_bg]$window_right_separator" + + fi + + if [ "$fill" = "all" ] + then + local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" + local show_number="#[fg=$background,bg=$color]$number" + local show_middle_separator="#[fg=$background,bg=$color,nobold,nounderscore,noitalics]$window_middle_separator" + local show_text="#[fg=$background,bg=$color]$text" + local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator" + + fi + + if [ "$fill" = "number" ] + then + local show_number="#[fg=$background,bg=$color]$number" + local show_middle_separator="#[fg=$color,bg=$background,nobold,nounderscore,noitalics]$window_middle_separator" + local show_text="#[fg=$thm_fg,bg=$background]$text" + + if [ "$window_number_position" = "right" ] + then + local show_left_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" + local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator" + fi + + if [ "$window_number_position" = "left" ] + then + local show_right_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_right_separator" + local show_left_separator="#[fg=$color,bg=$thm_bg]$window_left_separator" + fi + + fi + + local final_window_format + + if [ "$window_number_position" = "right" ] + then + final_window_format="$show_left_separator$show_text$show_middle_separator$show_number$show_right_separator" + fi + + if [ "$window_number_position" = "left" ] + then + final_window_format="$show_left_separator$show_number$show_middle_separator$show_text$show_right_separator" + fi + + echo "$final_window_format" +} + +build_status_module() { + local index=$1 + local icon=$2 + local color=$3 + local text=$4 + + if [ "$status_fill" = "icon" ] + then + local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" + + local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon " + local show_text="#[fg=$thm_fg,bg=$thm_gray] $text" + + local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" + + if [ "$status_connect_separator" = "yes" ] + then + local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" + local show_right_separator="#[fg=$thm_gray,bg=$thm_gray,nobold,nounderscore,noitalics]$status_right_separator" + + else + local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator" + local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" + fi + + fi + + if [ "$status_fill" = "all" ] + then + local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" + + local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon " + local show_text="#[fg=$thm_bg,bg=$color]$text" + + local show_right_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_right_separator" + + if [ "$status_connect_separator" = "yes" ] + then + local show_left_separator="#[fg=$color,nobold,nounderscore,noitalics]$status_left_separator" + local show_right_separator="#[fg=$color,bg=$color,nobold,nounderscore,noitalics]$status_right_separator" + + else + local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator" + local show_right_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" + fi + + fi + + if [ "$status_right_separator_inverse" = "yes" ] + then + if [ "$status_connect_separator" = "yes" ] + then + local show_right_separator="#[fg=$thm_gray,bg=$color,nobold,nounderscore,noitalics]$status_right_separator" + else + local show_right_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$status_right_separator" + fi + fi + + if [ $(($index)) -eq 0 ] + then + local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator" + fi + + echo "$show_left_separator$show_icon$show_text$show_right_separator" +} + +load_modules() { + local modules_list=$1 + shift + local module_directories=("$@") + + local -i module_index=0; + local module_name + local module_path + local loaded_modules + local IN=$modules_list + + # https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash#15988793 + while [ "$IN" != "$iter" ] ;do + # extract the substring from start of string up to delimiter. + iter=${IN%% *} + # delete this first "element" AND next separator, from $IN. + IN="${IN#$iter }" + # Print (or doing anything with) the first "element". + + module_name=$iter + + for module_dir in "${module_directories[@]}" ; do + module_path="$module_dir/$module_name.sh" + + if [ -r "$module_path" ]; then + source "$module_path" + loaded_modules="$loaded_modules$( "show_$module_name" "$module_index" )" + module_index+=1 + break + fi + done + done + + echo "$loaded_modules" +} + +main() { + local theme + theme="$(get_tmux_option "@bamboo_flavour" "dark")" + + # Aggregate all commands in one array + local tmux_commands=() + + # NOTE: Pulling in the selected theme by the theme that's being set as local + # variables. + # shellcheck source=bamboo-frappe.tmuxtheme + # https://github.com/dylanaraps/pure-sh-bible#parsing-a-keyval-file + while IFS='=' read -r key val; do + # Skip over lines containing comments. + # (Lines starting with '#'). + [ "${key##\#*}" ] || continue + + # '$key' stores the key. + # '$val' stores the value. + eval "local $key"="$val" + done < "${PLUGIN_DIR}/bamboo-${theme}.tmuxtheme" + + # module directories + local custom_path="$(get_tmux_option "@bamboo_custom_plugin_dir" "${PLUGIN_DIR}/custom")" + local modules_custom_path=$custom_path + local modules_status_path=$PLUGIN_DIR/status + local modules_window_path=$PLUGIN_DIR/window + local modules_pane_path=$PLUGIN_DIR/pane + + # status + local status_default=$(get_tmux_option "@bamboo_status_default" "on") + local status_justify=$(get_tmux_option "@bamboo_status_justify" "left") + + set status "$status_default" + set status-justify "$status_justify" + set status-bg "${thm_bg}" + set status-left-length "100" + set status-right-length "100" + + # messages + set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" + set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" + + # panes + local pane_status_enable=$(get_tmux_option "@bamboo_pane_status_enabled" "no") # yes + local pane_border_status=$(get_tmux_option "@bamboo_pane_border_status" "off") # bottom + local pane_border_style=$(get_tmux_option "@bamboo_pane_border_style" "fg=${thm_gray}") + local pane_active_border_style=$(\ + get_tmux_option "@bamboo_pane_active_border_style" \ + "#{?pane_in_mode,fg=${thm_yellow},#{?pane_synchronized,fg=${thm_magenta},fg=${thm_orange}}}" + ) + local pane_left_separator=$(get_tmux_option "@bamboo_pane_left_separator" "โ–ˆ") + local pane_middle_separator=$(get_tmux_option "@bamboo_pane_middle_separator" "โ–ˆ") + local pane_right_separator=$(get_tmux_option "@bamboo_pane_right_separator" "โ–ˆ") + local pane_number_position=$(get_tmux_option "@bamboo_pane_number_position" "left") # right, left + local pane_format=$(load_modules "pane_default_format" "$modules_custom_path" "$modules_pane_path") + + setw pane-border-status "$pane_border_status" + setw pane-active-border-style "$pane_active_border_style" + setw pane-border-style "$pane_border_style" + setw pane-border-format "$pane_format" + + + # windows + setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" + setw window-status-separator "" + setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" + + # --------=== Statusline + + local window_left_separator=$(get_tmux_option "@bamboo_window_left_separator" "โ–ˆ") + local window_right_separator=$(get_tmux_option "@bamboo_window_right_separator" "โ–ˆ") + local window_middle_separator=$(get_tmux_option "@bamboo_window_middle_separator" "โ–ˆ ") + local window_number_position=$(get_tmux_option "@bamboo_window_number_position" "left") # right, left + local window_status_enable=$(get_tmux_option "@bamboo_window_status_enable" "no") # right, left + + local window_format=$(load_modules "window_default_format" "$modules_custom_path" "$modules_window_path") + local window_current_format=$(load_modules "window_current_format" "$modules_custom_path" "$modules_window_path") + + setw window-status-format "$window_format" + setw window-status-current-format "$window_current_format" + + local status_left_separator=$(get_tmux_option "@bamboo_status_left_separator" "๎‚ถ") + local status_right_separator=$(get_tmux_option "@bamboo_status_right_separator" "โ–ˆ") + local status_right_separator_inverse=$(get_tmux_option "@bamboo_status_right_separator_inverse" "no") + local status_connect_separator=$(get_tmux_option "@bamboo_status_connect_separator" "yes") + local status_fill=$(get_tmux_option "@bamboo_status_fill" "icon") + + local status_modules_right=$(get_tmux_option "@bamboo_status_modules_right" "application session") + local loaded_modules_right=$(load_modules "$status_modules_right" "$modules_custom_path" "$modules_status_path") + + local status_modules_left=$(get_tmux_option "@bamboo_status_modules_left" "") + local loaded_modules_left=$(load_modules "$status_modules_left" "$modules_custom_path" "$modules_status_path") + + set status-left "$loaded_modules_left" + set status-right "$loaded_modules_right" + + # --------=== Modes + # + setw clock-mode-colour "${thm_blue}" + setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" + + tmux "${tmux_commands[@]}" +} + +main "$@" diff --git a/pane/pane_default_format.sh b/pane/pane_default_format.sh new file mode 100644 index 0000000..a3f177c --- /dev/null +++ b/pane/pane_default_format.sh @@ -0,0 +1,12 @@ +show_pane_default_format() { + local number="#{pane_index}" + local color="$(get_tmux_option "@catppuccin_pane_color" "$thm_green")" + local background="$(get_tmux_option "@catppuccin_pane_background_color" "$thm_gray")" + local text="$(get_tmux_option "@catppuccin_pane_default_text" "#{b:pane_current_path}")" + local fill="$(get_tmux_option "@catppuccin_pane_default_fill" "number")" # number, all, none + local active="#{pane_active}" + + local default_pane_format=$( build_pane_format "$number" "$color" "$background" "$text" "$fill") + + echo "$default_pane_format" +} diff --git a/status/application.sh b/status/application.sh new file mode 100644 index 0000000..56f2e76 --- /dev/null +++ b/status/application.sh @@ -0,0 +1,10 @@ +show_application() { + local index=$1 + local icon=$(get_tmux_option "@catppuccin_application_icon" "๏†ฎ") + local color=$(get_tmux_option "@catppuccin_application_color" "$thm_pink") + local text=$(get_tmux_option "@catppuccin_application_text" "#W") + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} diff --git a/status/battery.sh b/status/battery.sh new file mode 100644 index 0000000..7ad978f --- /dev/null +++ b/status/battery.sh @@ -0,0 +1,23 @@ +show_battery() { + tmux set-option -g @batt_icon_charge_tier8 '๓ฐน' + tmux set-option -g @batt_icon_charge_tier7 '๓ฐ‚' + tmux set-option -g @batt_icon_charge_tier6 '๓ฐฟ' + tmux set-option -g @batt_icon_charge_tier5 '๓ฐพ' + tmux set-option -g @batt_icon_charge_tier4 '๓ฐฝ' + tmux set-option -g @batt_icon_charge_tier3 '๓ฐผ' + tmux set-option -g @batt_icon_charge_tier2 '๓ฐป' + tmux set-option -g @batt_icon_charge_tier1 '๓ฐบ' + tmux set-option -g @batt_icon_status_charged '๓ฐšฅ' + tmux set-option -g @batt_icon_status_charging '๓ฐ‚„' + tmux set-option -g @batt_icon_status_discharging '๓ฐ‚ƒ' + tmux set-option -g @batt_icon_status_unknown '๓ฐ‚‘' + + local index=$1 + local icon=$(get_tmux_option "@catppuccin_battery_icon" "#{battery_icon}") + local color=$(get_tmux_option "@catppuccin_battery_color" "$thm_yellow") + local text=$(get_tmux_option "@catppuccin_battery_text" "#{battery_percentage}") + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} diff --git a/status/cpu.sh b/status/cpu.sh new file mode 100644 index 0000000..0d43359 --- /dev/null +++ b/status/cpu.sh @@ -0,0 +1,14 @@ +show_cpu() { + tmux set-option -g @cpu_low_bg_color "$thm_yellow" # background color when cpu is low + tmux set-option -g @cpu_medium_bg_color "$thm_orange" # background color when cpu is medium + tmux set-option -g @cpu_high_bg_color "$thm_red" # background color when cpu is high + + local index=$1 + local icon=$(get_tmux_option "@catppuccin_cpu_icon" "๏‹›") + local color="$(get_tmux_option "@catppuccin_cpu_color" "#{cpu_bg_color}")" + local text="$(get_tmux_option "@catppuccin_cpu_text" "#{cpu_percentage}")" + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} diff --git a/status/date_time.sh b/status/date_time.sh new file mode 100644 index 0000000..9f7030e --- /dev/null +++ b/status/date_time.sh @@ -0,0 +1,11 @@ +show_date_time() { + local index=$1 + local icon="$(get_tmux_option "@catppuccin_date_time_icon" "๓ฐƒฐ")" + local color="$(get_tmux_option "@catppuccin_date_time_color" "$thm_blue")" + local text="$(get_tmux_option "@catppuccin_date_time_text" "%Y-%m-%d %H:%M")" + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} + diff --git a/status/directory.sh b/status/directory.sh new file mode 100644 index 0000000..1ff293d --- /dev/null +++ b/status/directory.sh @@ -0,0 +1,10 @@ +show_directory() { + local index=$1 + local icon=$(get_tmux_option "@catppuccin_directory_icon" "๏ป") + local color=$(get_tmux_option "@catppuccin_directory_color" "$thm_pink") + local text=$(get_tmux_option "@catppuccin_directory_text" "#{b:pane_current_path}") + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} diff --git a/status/host.sh b/status/host.sh new file mode 100644 index 0000000..5abd71e --- /dev/null +++ b/status/host.sh @@ -0,0 +1,10 @@ +show_host() { + local index=$1 + local icon=$(get_tmux_option "@catppuccin_host_icon" "๓ฐ’‹") + local color=$(get_tmux_option "@catppuccin_host_color" "$thm_magenta") + local text=$(get_tmux_option "@catppuccin_host_text" "#H") + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} diff --git a/status/load.sh b/status/load.sh new file mode 100644 index 0000000..942c7f3 --- /dev/null +++ b/status/load.sh @@ -0,0 +1,11 @@ +show_load() { + local index=$1 + local icon="$(get_tmux_option "@catppuccin_load_icon" "๓ฐŠš")" + local color="$(get_tmux_option "@catppuccin_load_color" "$thm_blue")" + local text="$(get_tmux_option "@catppuccin_load_text" "#{load_full}")" + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} + diff --git a/status/session.sh b/status/session.sh new file mode 100644 index 0000000..58d6c90 --- /dev/null +++ b/status/session.sh @@ -0,0 +1,10 @@ +show_session() { + local index=$1 + local icon=$(get_tmux_option "@catppuccin_session_icon" "๎ž•") + local color=$(get_tmux_option "@catppuccin_session_color" "#{?client_prefix,$thm_red,$thm_green}") + local text=$(get_tmux_option "@catppuccin_session_text" "#S") + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} diff --git a/status/uptime.sh b/status/uptime.sh new file mode 100644 index 0000000..f531d57 --- /dev/null +++ b/status/uptime.sh @@ -0,0 +1,11 @@ +# Requires https://github.com/robhurring/tmux-uptime. +show_uptime() { + local index=$1 + local icon="$(get_tmux_option "@catppuccin_uptime_icon" "๓ฐ”Ÿ")" + local color="$(get_tmux_option "@catppuccin_uptime_color" "$thm_green")" + local text="$(get_tmux_option "@catppuccin_uptime_text" "#{uptime}")" + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} diff --git a/status/user.sh b/status/user.sh new file mode 100644 index 0000000..1d4d03e --- /dev/null +++ b/status/user.sh @@ -0,0 +1,10 @@ +show_user() { + local index=$1 + local icon=$(get_tmux_option "@catppuccin_user_icon" "๏€‡") + local color=$(get_tmux_option "@catppuccin_user_color" "$thm_cyan") + local text=$(get_tmux_option "@catppuccin_user_text" "#(whoami)") + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} diff --git a/status/weather.sh b/status/weather.sh new file mode 100644 index 0000000..943ac30 --- /dev/null +++ b/status/weather.sh @@ -0,0 +1,11 @@ +# Requires https://github.com/xamut/tmux-weather. +show_weather() { + local index=$1 + local icon="$(get_tmux_option "@catppuccin_weather_icon" "๏‹‰")" + local color="$(get_tmux_option "@catppuccin_weather_color" "$thm_yellow")" + local text="$(get_tmux_option "@catppuccin_weather_text" "#{weather}")" + + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) + + echo "$module" +} diff --git a/window/window_current_format.sh b/window/window_current_format.sh new file mode 100644 index 0000000..46b4a18 --- /dev/null +++ b/window/window_current_format.sh @@ -0,0 +1,11 @@ +show_window_current_format() { + local number="#I" + local color=$(get_tmux_option "@catppuccin_window_current_color" "$thm_orange") + local background=$(get_tmux_option "@catppuccin_window_current_background" "$thm_bg") + local text="$(get_tmux_option "@catppuccin_window_current_text" "#{b:pane_current_path}")" # use #W for application instead of directory + local fill="$(get_tmux_option "@catppuccin_window_current_fill" "number")" # number, all, none + + local current_window_format=$( build_window_format "$number" "$color" "$background" "$text" "$fill" ) + + echo "$current_window_format" +} diff --git a/window/window_default_format.sh b/window/window_default_format.sh new file mode 100644 index 0000000..5afcfe6 --- /dev/null +++ b/window/window_default_format.sh @@ -0,0 +1,11 @@ +show_window_default_format() { + local number="#I" + local color=$(get_tmux_option "@catppuccin_window_default_color" "$thm_blue") + local background=$(get_tmux_option "@catppuccin_window_default_background" "$thm_gray") + local text="$(get_tmux_option "@catppuccin_window_default_text" "#{b:pane_current_path}")" # use #W for application instead of directory + local fill="$(get_tmux_option "@catppuccin_window_default_fill" "number")" # number, all, none + + local default_window_format=$( build_window_format "$number" "$color" "$background" "$text" "$fill" ) + + echo "$default_window_format" +}