From 06554e65ed8f7dbfc74c1a6ee29fbcd4e002022a Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 14 Sep 2024 21:44:37 +0200 Subject: [PATCH 1/5] refactor: separate lint shfmt and shellcheck --- Makefile | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 5f1ff99..a436a49 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,12 @@ -.PHONY: check-scripts -check-scripts: - @# 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 %' +.PHONY: lint_shellcheck +lint_shellcheck: + find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" -o -iname "*.tmux" \) | \ + xargs -I % sh -c 'shellcheck %' + +.PHONY: lint_shfmt +lint_shfmt: + find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" -o -iname "*.tmux" \) | \ + xargs -I % sh -c 'shfmt -l -d %' + +.PHONY: check_scripts +check_scripts: lint_shellcheck lint_shfmt From 3d55a0adbcb454f6a5b8288ad37db1990df3af8e Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 14 Sep 2024 21:46:47 +0200 Subject: [PATCH 2/5] feat: add simple github action task --- .github/workflows/github-actions.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/github-actions.yml diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..6f76a98 --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,22 @@ +name: GitHub Actions +run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +on: [push] +jobs: + lint-shellcheck: + runs-on: ubuntu-latest + steps: + - name: install shellcheck + run: sudo apt-get install -y shellcheck + - name: checkout repo + uses: actions/checkout@main + - name: lint files against shellcheck + run: make lint_shellcheck + lint-shfmt: + runs-on: ubuntu-latest + steps: + - name: install shfmt + run: sudo apt-get install -y shfmt + - name: checkout repo + uses: actions/checkout@main + - name: lint files against shfmt + run: make lint_shfmt From 4c233b87f2eb88fafb02f35f0fc5b954e6eebc87 Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 14 Sep 2024 23:28:14 +0200 Subject: [PATCH 3/5] fix: linting bash files according to shfmt --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a436a49..6201b68 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ .PHONY: lint_shellcheck lint_shellcheck: - find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" -o -iname "*.tmux" \) | \ + find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" \) | \ xargs -I % sh -c 'shellcheck %' .PHONY: lint_shfmt lint_shfmt: - find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" -o -iname "*.tmux" \) | \ - xargs -I % sh -c 'shfmt -l -d %' + find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" \) | \ + xargs -I % sh -c 'shfmt -i=2 -l -d -ln=bash %' .PHONY: check_scripts check_scripts: lint_shellcheck lint_shfmt From faa605fffe617779820beeea13df88835fcab72e Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 14 Sep 2024 23:28:49 +0200 Subject: [PATCH 4/5] feat: move main method dedicated shell file --- gruvbox-tpm.tmux | 27 +-------------------------- src/gruvbox-main.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 26 deletions(-) create mode 100755 src/gruvbox-main.sh diff --git a/gruvbox-tpm.tmux b/gruvbox-tpm.tmux index 99849a9..b93207a 100755 --- a/gruvbox-tpm.tmux +++ b/gruvbox-tpm.tmux @@ -1,30 +1,5 @@ #!/usr/bin/env bash -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 -} - -main() { - local theme - theme=$(get_theme "$THEME_OPTION" "$DEFAULT_THEME") - tmux source-file "$CURRENT_DIR/tmux-gruvbox-${theme}.conf" -} - -main "$@" +source "./src/gruvbox-main.sh" # vim: ai et ft=bash diff --git a/src/gruvbox-main.sh b/src/gruvbox-main.sh new file mode 100755 index 0000000..271bc42 --- /dev/null +++ b/src/gruvbox-main.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +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 +} + +main() { + local theme + theme=$(get_theme "$THEME_OPTION" "$DEFAULT_THEME") + tmux source-file "$CURRENT_DIR/tmux-gruvbox-${theme}.conf" +} + +main "$@" From 18f34e2b213454ff4b070525281f6fe24f42013c Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 14 Sep 2024 23:40:46 +0200 Subject: [PATCH 5/5] feat: update changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6d72f3..f7a6751 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ 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) ### Changed