From 48c8dcb2b600462c0711ed97129fc95ebf2bd7f7 Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Thu, 5 Sep 2024 22:53:48 +0200 Subject: [PATCH 1/5] feat: enhance code quality for project files --- .editorconfig | 16 ++++++++++++++++ Makefile | 4 ++++ README.md | 30 ++++++++++++++++++++++++++++++ gruvbox-tpm.tmux | 28 ++++++++++++++-------------- 4 files changed, 64 insertions(+), 14 deletions(-) create mode 100644 Makefile diff --git a/.editorconfig b/.editorconfig index e29c6fe..0595d35 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,3 +19,19 @@ trim_trailing_whitespace = false # windows shell scripts [*.{cmd,bat,ps1}] end_of_line = crlf + +[*.sh] +indent_style = space +indent_size = 4 + +shell_variant = posix # like -ln=posix +binary_next_line = true # like -bn +switch_case_indent = true # like -ci +space_redirects = true # like -sr +keep_padding = true # like -kp +function_next_line = true # like -fn +never_split = true # like -ns + +[Makefile] +indent_style = tab +indent_size = 8 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..049620c --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +.PHONY: check-scripts +check-scripts: + # Fail if any of these files have warnings + shellcheck ./gruvbox-tmp.tmux diff --git a/README.md b/README.md index 1c0137f..b6c3690 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,36 @@ set -g @tmux-gruvbox 'dark' # or 'light', 'dark-transparent', 'light-transparent Hit `prefix + I` to fetch the plugin and source it. Your Tmux should be updated with the theme at this point. +## Development + +To run project locally pull the repo to desired place + +```bash +cd $HOME/privatespace/ +git clone ... +``` + +and in `~/.tmux.conf` set + +```bash +# cd to tmux plugin directory +cd ~/.tmux/plugins/ + +# create simlink to +ln -sf $HOME/privatespace/tmux-gruvbox/ tmux-gruvbox + +# set desired options... +set -g @tmux-gruvbox 'dark-transparent' +``` + +### Linters & formatters + +To keep the files clean we use few program to help us achieve it: + +1. Editorconfig (make sure your editor have it) +2. Markdown (prettier/prettierd) +3. Shell (shellcheck, shfmt) + ## License GPLv3 - Maciej Sypień diff --git a/gruvbox-tpm.tmux b/gruvbox-tpm.tmux index 4f7693b..005be20 100755 --- a/gruvbox-tpm.tmux +++ b/gruvbox-tpm.tmux @@ -1,27 +1,27 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" THEME_OPTION="@tmux-gruvbox" 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 + 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 } main() { - local theme - theme=$(get_theme "$THEME_OPTION" "$DEFAULT_THEME") - tmux source-file "$CURRENT_DIR/tmux-gruvbox-${theme}.conf" + local theme + theme=$(get_theme "$THEME_OPTION" "$DEFAULT_THEME") + tmux source-file "$CURRENT_DIR/tmux-gruvbox-${theme}.conf" } -main +main "$@" # vi: ft=bash From d084c5bf849184f8936a8157f1d036cf9a208e07 Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 14 Sep 2024 19:43:09 +0200 Subject: [PATCH 2/5] feat: use 2 indent for sh,tmux files --- .editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 0595d35..d3b3e1a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -20,9 +20,9 @@ trim_trailing_whitespace = false [*.{cmd,bat,ps1}] end_of_line = crlf -[*.sh] +[*.{sh,tmux}] indent_style = space -indent_size = 4 +indent_size = 2 shell_variant = posix # like -ln=posix binary_next_line = true # like -bn From 2fb3dc8d45c1b2c057718beb688b488cd165da60 Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 14 Sep 2024 19:47:00 +0200 Subject: [PATCH 3/5] feat: add command for checking script --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 049620c..5f1ff99 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ .PHONY: check-scripts check-scripts: - # Fail if any of these files have warnings - shellcheck ./gruvbox-tmp.tmux + @# Fail if any of these files have warnings + find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" -o -iname "*.tmux" \) | xargs -I % sh -c 'shellcheck %' + find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" -o -iname "*.tmux" \) | xargs -I % sh -c 'shfmt -l -d %' From 92c67eb87d0243e98429e37216a9b3654ada857f Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 14 Sep 2024 19:48:32 +0200 Subject: [PATCH 4/5] fix(shfmt): arrays are a bash/mksh feature (parsed as bash via -ln=auto) --- gruvbox-tpm.tmux | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gruvbox-tpm.tmux b/gruvbox-tpm.tmux index 005be20..99849a9 100755 --- a/gruvbox-tpm.tmux +++ b/gruvbox-tpm.tmux @@ -1,8 +1,11 @@ #!/usr/bin/env bash -CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -THEME_OPTION="@tmux-gruvbox" -DEFAULT_THEME="dark" +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" @@ -24,4 +27,4 @@ main() { main "$@" -# vi: ft=bash +# vim: ai et ft=bash From ed4430b0b50d0e059d8bd253fc9c8f8cdd3523f5 Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 14 Sep 2024 19:54:20 +0200 Subject: [PATCH 5/5] feat: update readme --- README.md | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b6c3690..ff5426d 100644 --- a/README.md +++ b/README.md @@ -56,25 +56,33 @@ Hit `prefix + I` to fetch the plugin and source it. Your Tmux should be updated ## Development -To run project locally pull the repo to desired place +To run project locally: -```bash -cd $HOME/privatespace/ -git clone ... -``` +1. clone the repo to desired place -and in `~/.tmux.conf` set + ```bash + cd $HOME/projects/ + git clone ... + ``` -```bash -# cd to tmux plugin directory -cd ~/.tmux/plugins/ +1. create symlink in plugin dir to the cloned repo: -# create simlink to -ln -sf $HOME/privatespace/tmux-gruvbox/ tmux-gruvbox + ```bash + # cd to tmux plugin directory + cd ~/.tmux/plugins/ -# set desired options... -set -g @tmux-gruvbox 'dark-transparent' -``` + # create simlink to cloned repo + ln -sf $HOME/projects/tmux-gruvbox/ tmux-gruvbox + ``` + +1. and in `~/.tmux.conf` set + + ```bash + # add plugin + set -g @plugin 'egel/tmux-gruvbox' + # set desired options... + set -g @tmux-gruvbox 'dark' + ``` ### Linters & formatters