From faa605fffe617779820beeea13df88835fcab72e Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 14 Sep 2024 23:28:49 +0200 Subject: [PATCH] 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 "$@"