Skip to content
Open
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
23 changes: 15 additions & 8 deletions eutmux.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ PLACE_HOLDERS=(
"DEEP_GRAY"
)

init(){
# set working directory to eutmux project path
pushd "${_DIR}" >/dev/null 2>/dev/null || exit ${EXIT_ABNORMAL}
}

setup(){
# constants
FORCE_SAVE_THEME=${FALSE}
Expand Down Expand Up @@ -96,9 +101,6 @@ setup(){
ROTATE_THEME=${FALSE}
CREATE_DYNMIC_THEME=${FALSE}

# set working directory to eutmux project path
pushd "${_DIR}" >/dev/null 2>/dev/null || exit ${EXIT_ABNORMAL}

# set config home and config file
EUTMUX_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}/eutmux"
mkdir -p "${EUTMUX_CONFIG_HOME}" >/dev/null 2>/dev/null
Expand All @@ -117,7 +119,7 @@ setup(){
tmux set-hook -g after-resize-pane "run-shell '${_DIR}/hooks/session-window-changed.hook'"
}

teardown(){
reset(){
popd >/dev/null 2>/dev/null || exit ${EXIT_ABNORMAL}
}

Expand Down Expand Up @@ -261,8 +263,12 @@ function save_dynamic_theme(){
current_dynamic_theme_cmd_filename="${current_dynamic_theme}${CMD_FILE_EXTENSION}"
current_dynamic_palette_filename="${current_dynamic_theme}${PALETTE_FILE_EXTENSION}"

if [ "${new_theme_name}" == "${current_dynamic_theme}" ];then
return
fi

if [ -e "${EUTMUX_CONFIG_HOME}/${current_dynamic_theme_filename}" ];then
cp -f "${EUTMUX_CONFIG_HOME}/${current_dynamic_theme_filename}" "${EUTMUX_CONFIG_HOME}/${new_theme_name}${THEME_FILE_EXTENSION}"
cp -f "${EUTMUX_CONFIG_HOME}/${current_dynamic_theme_filename}" "${EUTMUX_CONFIG_HOME}/${new_theme_name}${THEME_FILE_EXTENSION}"
cp -f "${EUTMUX_CONFIG_HOME}/${current_dynamic_palette_filename}" "${EUTMUX_CONFIG_HOME}/${new_theme_name}${PALETTE_FILE_EXTENSION}"
cp -f "${EUTMUX_CONFIG_HOME}/${current_dynamic_theme_cmd_filename}" "${EUTMUX_CONFIG_HOME}/${new_theme_name}${CMD_FILE_EXTENSION}"
fi
Expand All @@ -281,9 +287,9 @@ apply_theme(){
else
themes=$(show_all_themes)
echo "$themes" | grep -q "${theme_name}"
# if the target theme name not exist, then save the current dynamic theme to it
if [ $? -ne $TRUE ];then
tmux display-message -d "${DELAY}" "Not found theme: '${theme_name}'"
exit ${EXIT_ABNORMAL}
save_dynamic_theme ${theme_name}
fi
fi
THEME_NAME="${theme_name}"
Expand Down Expand Up @@ -422,6 +428,7 @@ usage(){
}

# set -x
init
setup
while getopts "ac:dDfhLp:rRt:T:" opt; do
case $opt in
Expand All @@ -440,5 +447,5 @@ while getopts "ac:dDfhLp:rRt:T:" opt; do
esac
done
main
teardown
reset
set +x
7 changes: 6 additions & 1 deletion hooks/session-window-changed.hook
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

# trap "echo $GITHUB_REPO_ROOT" DEBUG

function change_theme(){
set -x
local eutmux_script=${GITHUB_REPO_ROOT}/eu.tmux/eutmux.tmux
if [ ! -x ${eutmux_script} ];then
return 2
Expand All @@ -26,12 +29,14 @@ function change_theme(){
if [[ ( ${is_pane_maximized} -eq 1 ) || ( ${panes_total} -eq 1 ) ]]; then
if [ -n "${idename}" ];then
${eutmux_script} -t ${idename}
return 0
return $?
fi
fi
# for other cases, use default latset theme
${eutmux_script} -R
return $?
fi
set +x
}

change_theme
80 changes: 40 additions & 40 deletions template.theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,68 @@ terminal:
foreground: "#b7b7ff"
background: "#231f32"
status_line:
foreground: "C_06_01"
background: "C_06_17"
foreground: "C_14_10"
background: "C_14_53"
left_icon: ""
right_icon: ""
left_decorator: ""
right_decorator: ""
fg_format: "C_06_06"
bg_format: "C_06_13"
fg_icon: "C_06_06"
bg_icon: "C_06_15"
fg_decorator: "C_06_15"
bg_decorator: "C_06_17"
fg_format: "C_14_20"
bg_format: "C_14_25"
fg_icon: "C_14_20"
bg_icon: "C_14_30"
fg_decorator: "C_14_30"
bg_decorator: "C_14_50"
style: "nobold,nounderscore,noitalics"
status_left:
fg_format: "C_04_08"
bg_format: "C_06_17"
fg_icon: "C_06_06"
bg_icon: "C_06_13"
fg_decorator: "C_06_13"
bg_decorator: "C_06_17"
fg_format: "C_10_25"
bg_format: "C_14_53"
fg_icon: "C_14_01"
bg_icon: "C_10_45"
fg_decorator: "C_10_45"
bg_decorator: "C_14_53"
icon: "  "
decorator: ""
style: "nobold,nounderscore,noitalics"
window:
active:
fg_window: "C_04_14"
bg_window: "C_04_08"
fg_window_index: "C_04_14"
bg_window_index: "C_04_10"
fg_icon: "C_04_06"
bg_icon: "C_04_08"
fg_decorator: "C_04_10"
bg_decorator: "C_04_17"
fg_window: "C_14_59"
bg_window: "C_07_40"
fg_window_index: "C_14_59"
bg_window_index: "C_07_30"
fg_icon: "C_14_10"
bg_icon: "C_08_15"
fg_decorator: "C_07_30"
bg_decorator: "C_14_53"
icon: ""
decorator: ""
style: "nobold,nounderscore,noitalics"
inactive:
fg_window: "C_06_06"
bg_window: "C_06_13"
fg_window_index: "C_06_06"
bg_window_index: "C_06_15"
fg_window: "C_14_20"
bg_window: "C_14_35"
fg_window_index: "C_14_20"
bg_window_index: "C_14_45"
fg_icon: ""
bg_icon: ""
fg_decorator: "C_06_15"
bg_decorator: "C_06_17"
fg_decorator: "C_14_45"
bg_decorator: "C_14_53"
icon: ""
decorator: ""
style: "nobold,nounderscore,noitalics"
status_right:
icon: " "
decorator: ""
style: "nobold,nounderscore,noitalics"
fg_format: "C_06_06"
bg_format: "C_06_13"
fg_icon: "C_06_06"
bg_icon: "C_06_15"
fg_decorator: "C_06_15"
bg_decorator: "C_06_17"
fg_format: "C_14_20"
bg_format: "C_14_40"
fg_icon: "C_14_15"
bg_icon: "C_14_45"
fg_decorator: "C_14_45"
bg_decorator: "C_14_53"
directory:
fg_format: "C_05_06"
bg_format: "C_05_13"
fg_icon: "C_05_06"
bg_icon: "C_05_15"
fg_decorator: "C_05_15"
bg_decorator: "C_05_17"
fg_format: "C_14_15"
bg_format: "C_14_20"
fg_icon: "C_14_15"
bg_icon: "C_14_20"
fg_decorator: "C_14_20"
bg_decorator: "C_14_53"