Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/v2.0.0 #35

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added light and dark transparent themes [#18](https://github.com/egel/tmux-gruvbox/issues/18)
- Added editorconfig
- Added code linters for shellcheck & shfmt [#33](https://github.com/egel/tmux-gruvbox/issues/33)
- Added customizable statusbar [#31](https://github.com/egel/tmux-gruvbox/issues/31)
- Added support for 16-bit colors palette light & dark [#34](https://github.com/egel/tmux-gruvbox/issues/34)

### Changed

Expand All @@ -22,6 +24,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed

- Fixed incorrect spacings in template file
- Improved README with more examples
- Reduced repo size by outsource images to external platform [#36](https://github.com/egel/tmux-gruvbox/issues/36)

### Security

Expand Down
136 changes: 112 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img src="./docs/assets/img/logo-v1@0.5x.png" width="200px">
<img src="https://i.imgur.com/Ukyf4Iu.png" width="200px" referrerpolicy="no-referrer">
<h1>Gruvbox theme for Tmux</h1>
</div>

Expand All @@ -11,74 +11,155 @@ Theme with 'retro groove' flavor for [Tmux][github-tmux], based on Pavel Pertsev
-->

<div align="center">
<a href="./docs/assets/img/gruvbox-dark-and-light-theme-structure.png" title="Grovbox dark and light themes for Tmux">
<img src="./docs/assets/img/gruvbox-dark-and-light-theme-structure@0.5x.png"
<a href="https://i.imgur.com/uGyGwlC.png" title="Grovbox dark and light themes for Tmux">
<img src="https://i.imgur.com/p6lUnzb.png"
title="Grovbox dark and light themes for Tmux"
width="100%"
height="auto"
style="max-width: 800px; text-align: center; border-radius: 12px; overflow:hidden;" />
style="max-width: 800px; text-align: center; border-radius: 12px; overflow:hidden;"
referrerpolicy="no-referrer"
/>
</a>
</div>

> Screenshot made from macOS [alacritty][github-alacritty] terminal with xterm-256color and [Hack Nerd Font Regular][github-nerd-fonts].<br/>
> Backgrounds by [Aleksandar Pasaric][pexcel-1] and [Vishnu Murali][pexcel-2].
> Screenshot made with dark & light themes (16-bit) from macOS [alacritty][github-alacritty] terminal with xterm-256color and [Hack Nerd Font Regular][github-nerd-fonts]. Backgrounds by [Aleksandar Pasaric][pexcel-1] and [Vishnu Murali][pexcel-2].

## Installation

**Available Themes**
### Install via [TPM][github-tpm] (recommended)

- [`dark`](./docs/assets/img/gruvbox-dark-theme.png)
- [`light`](./docs/assets/img/gruvbox-light-theme.png)
- `dark-transparent` (experimental)
- `light-transparent` (experimental)
Add plugin at the top list of TPM plugins in `.tmux.conf` and select desired theme.

### Install manually
```bash
# ~/.tmux.conf
set -g @plugin 'egel/tmux-gruvbox'
# set desired options...
set -g @tmux-gruvbox 'dark' # or 'light'
```

The simplest way is just:
Hit `prefix + I` to fetch the plugin and source it. Your Tmux should be updated with the theme at this point.

### Install manually

> [!TIP]
> Always make a backup of your config files before any action.
> If you do not have github account [download](https://github.com/egel/tmux-gruvbox/archive/refs/heads/main.zip) it and unzip.

1. Clone the project to desired location

```bash
cd ~/projects/
git clone ...
```

1. Add theme at to top of your `~/.tmux.conf` config.

```bash
# ~/.tmux.conf
run ~/projects/tmux-gruvbox/tmux-gruvbox.tmux
# set desired options...
set -g @tmux-gruvbox 'dark' # or light
```

## Configuration options

### Theme

- default value: `dark256`
- available themes:
- `dark` ([preview][imgur-img-gruvbox-dark-16bit-1x])
- `light` ([preview][imgur-img-gruvbox-light-16bit-1x])
- `dark256` ([preview][imgur-img-gruvbox-dark256-1x])
- `light256` ([preview][imgur-img-gruvbox-light256-1x])

```bash
cat tmux-gruvbox-dark.conf >> ~/.tmux.conf
set -g @tmux-gruvbox 'dark' # dark256, light, light256
```

### Install through [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm)
### Transparent status-bar

Add plugin to the list of TPM plugins in `.tmux.conf` and select desired theme.
- default value: `'false'`
- tmux >= 3.2 (experimental)

```bash
set -g @plugin 'egel/tmux-gruvbox'
set -g @tmux-gruvbox 'dark' # or 'light', 'dark-transparent', 'light-transparent'
set -g @tmux-gruvbox-statusbar-alpha 'true'
```

Hit `prefix + I` to fetch the plugin and source it. Your Tmux should be updated with the theme at this point.
### Left Status (Section A)

- default value: `'#S'`

```bash
set -g @tmux-gruvbox-left-status-a '#S' # tmux's session name
```

### Right Status (Section X)

- default value: `'%Y-%m-%d'`

This section is customizable for user, and by default contains current date.

```bash
# set date in US notation
set -g @tmux-gruvbox-right-status-x '%m/%d/%Y' # e.g.: 01/31/2024
```

```bash
# or set date in EU notation
set -g @tmux-gruvbox-right-status-x '%d.%m.%Y' # e.g.: 30.01.2024
```

### Right Status (Section Y)

- default value: `'%H:%M'`

This section is customizable for user, and by default contains current time.

```bash
# set US time format
set -g @tmux-gruvbox-right-status-y '%I:%M %p' # 09:54 PM
```

### Right Status (Section Z)

- default value: `'#h'`

This section is customizable for user, and by default contains hostname.

```bash
# display hostname and enhance section with other plugin
set -g @tmux-gruvbox-right-status-z '#h #{tmux_mode_indicator}'
```

> [!TIP]
> Make sure the themes' settings are defined before all other plugins,
> otherwise content from external plugins may not be displayed correctly by
> the theme.

## Development

To run project locally:

1. clone the repo to desired place
1. clone the repository to desired place

```bash
cd $HOME/projects/
git clone ...
```

1. create symlink in plugin dir to the cloned repo:
1. create a symlink to the cloned repository (best in the standard [TPM][github-tpm] plugin directory):

```bash
# cd to tmux plugin directory
cd ~/.tmux/plugins/

# create simlink to cloned repo
# create symlink to cloned repo
ln -sf $HOME/projects/tmux-gruvbox/ tmux-gruvbox
```

1. and in `~/.tmux.conf` set

```bash
# add plugin
# ~/.tmux.conf
set -g @plugin 'egel/tmux-gruvbox'
# set desired options...
set -g @tmux-gruvbox 'dark'
Expand All @@ -101,6 +182,13 @@ GPLv3 - Maciej Sypień
[github-hack]: https://github.com/chrissimpkins/Hack
[github-nerd-fonts]: https://github.com/ryanoasis/nerd-fonts
[github-alacritty]: https://github.com/alacritty/alacritty
[github-tpm]: https://github.com/tmux-plugins/tpm
[tmux-color-solarized]: https://github.com/seebi/tmux-colors-solarized
[pexcel-1]: https://www.pexels.com/photo/urban-photo-of-an-alley-2411688/
[pexcel-2]: https://www.pexels.com/photo/lights-hanging-above-the-alley-in-a-city-at-night-27044195/
[imgur-img-gruvbox-dark-light-comparision-1x]: https://i.imgur.com/uGyGwlC.png
[imgur-img-gruvbox-dark-light-comparision-0.5x]: https://i.imgur.com/p6lUnzb.png
[imgur-img-gruvbox-dark-16bit-1x]: https://i.imgur.com/ae88LQI.png
[imgur-img-gruvbox-dark256-1x]: https://i.imgur.com/kzQTTCa.png
[imgur-img-gruvbox-light-16bit-1x]: https://i.imgur.com/fvpdRjg.png
[imgur-img-gruvbox-light256-1x]: https://i.imgur.com/tQsl6LA.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed docs/assets/img/gruvbox-dark-theme.png
Binary file not shown.
Binary file removed docs/assets/img/gruvbox-light-theme.png
Binary file not shown.
1 change: 1 addition & 0 deletions gruvbox-tpm.tmux
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash

# shellcheck disable=SC1091
source "./src/gruvbox-main.sh"

# vim: ai et ft=bash
106 changes: 89 additions & 17 deletions src/gruvbox-main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,97 @@
SCRIPT_SRC="$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}")"
readonly SCRIPT_SRC
CURRENT_DIR=$(cd "${SCRIPT_SRC}" >/dev/null 2>&1 && pwd) readonly CURRENT_DIR
readonly THEME_OPTION="@tmux-gruvbox"
readonly DEFAULT_THEME="dark"

get_theme() {
local option="$1"
local default_value="$2"
local option_value
option_value=$(tmux show-option -gqv "$option")
if [ -z "$option_value" ]; then
echo "$default_value"
else
echo "$option_value"
fi
}
readonly CURRENT_DIR

# hold the array of all command to configure tmux theme
declate -a TMUX_CMDS

# load libraries
# shellcheck disable=1091
source "${CURRENT_DIR}/src/helper_methods.sh"
# shellcheck disable=1091
source "${CURRENT_DIR}/src/tmux_utils.sh"

readonly TMUX_GRUVBOX="@tmux-gruvbox"
readonly TMUX_GRUVBOX_STATUSBAR_ALPHA="@tmux-gruvbox-statusbar-alpha"
readonly TMUX_GRUVBOX_LEFT_STATUS_A="@tmux-gruvbox-left-status-a"
readonly TMUX_GRUVBOX_RIGHT_STAUTS_X="@tmux-gruvbox-right-status-x"
readonly TMUX_GRUVBOX_RIGHT_STAUTS_Y="@tmux-gruvbox-right-status-y"
readonly TMUX_GRUVBOX_RIGHT_STAUTS_Z="@tmux-gruvbox-right-status-z"

# define simple theme options (no color interpolation required)
DEFAULT_THEME="dark"
DEFAULT_STATUSBAR_ALPHA=false
# defaults for theme option (with color interpolation)
DEFAULT_LEFT_STATUS_A='#S'
DEFAULT_RIGHT_STATUS_X='%Y-%m-%d'
DEFAULT_RIGHT_STATUS_Y='%H:%M'
DEFAULT_RIGHT_STATUS_Z='#h'

main() {
local theme
theme=$(get_theme "$THEME_OPTION" "$DEFAULT_THEME")
tmux source-file "$CURRENT_DIR/tmux-gruvbox-${theme}.conf"
TMUX_CMDS=() # clear

# load proper palette for the theme asap to avoid additional variable interpolation
local _theme
_theme=$(tmux_get_option "${TMUX_GRUVBOX}" "${DEFAULT_THEME}")
_statusbar_alpha=$(tmux_get_option "${TMUX_GRUVBOX_STATUSBAR_ALPHA}" "${DEFAULT_STATUSBAR_ALPHA}")

case "$_theme" in
light)
# shellcheck disable=1091
source "${CURRENT_DIR}/src/palette_gruvbox_light.sh"
# shellcheck disable=1091
source "${CURRENT_DIR}/src/theme_gruvbox_light.sh"
;;
light256)
# shellcheck disable=1091
source "${CURRENT_DIR}/src/palette_gruvbox_light256.sh"
# shellcheck disable=1091
source "${CURRENT_DIR}/src/theme_gruvbox_light256.sh"
;;
dark)
# shellcheck disable=1091
source "${CURRENT_DIR}/src/palette_gruvbox_dark.sh"
# shellcheck disable=1091
source "${CURRENT_DIR}/src/theme_gruvbox_dark.sh"
;;
dark256 | *)
# shellcheck disable=1091
source "${CURRENT_DIR}/src/palette_gruvbox_dark256.sh"
# shellcheck disable=1091
source "${CURRENT_DIR}/src/theme_gruvbox_dark.sh"
;;
esac

local _status_left _status_right _window_status_current_format _window_status_format
_status_left_a=$(tmux_get_option "$TMUX_GRUVBOX_LEFT_STATUS_A" "$DEFAULT_LEFT_STATUS_A")
_status_right_x=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_X" "$DEFAULT_RIGHT_STATUS_X")
_status_right_y=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_Y" "$DEFAULT_RIGHT_STATUS_Y")
_status_right_z=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_Z" "$DEFAULT_RIGHT_STATUS_Z")

theme_args=(
"$_status_left_a"
"$_status_right_x"
"$_status_right_y"
"$_status_right_z"
"$_statusbar_alpha"
)

case $_theme in
light256)
# light256 have slightly different colors placement then regular light 16-bit
theme_set_light256 "${theme_args[@]}"
;;
light)
theme_set_light "${theme_args[@]}"
;;
dark | dark256 | *)
theme_set_dark "${theme_args[@]}"
;;
esac

# execute commands with tmux as array of options
tmux "${TMUX_CMDS[@]}"
}

main "$@"
19 changes: 19 additions & 0 deletions src/helper_methods.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# simply print passed array
#
# example
#
# myarray=()
# print_array myarray
#
print_array() {
local -n arr # -n available over bash 4.3
arr=$1

echo ""
echo "begin >>>"
printf "%s\n" "${arr[@]}"
echo "<<< end"
echo ""
}
Loading