Skip to content

Commit

Permalink
feat: move main method dedicated shell file
Browse files Browse the repository at this point in the history
  • Loading branch information
egel committed Sep 14, 2024
1 parent 4c233b8 commit faa605f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
27 changes: 1 addition & 26 deletions gruvbox-tpm.tmux
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions src/gruvbox-main.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit faa605f

Please sign in to comment.