Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- fix: split `local` declarations from command substitution assignments to preserve tmux exit codes
- fix: suppress expected "key not found" errors from unbind calls on fresh plugin load
- fix: broken shebang in test_default_options.sh (was missing `!` and indented); quote `$CURRENT_DIR` in source
- refactor: toggle_on.sh and toggle_off.sh now source variables.sh and use named
variables for all option keys rather than hardcoded strings, so renames stay in sync

### v0.1.0, 2018-05-20
- initial work on the plugin
Expand Down
7 changes: 5 additions & 2 deletions scripts/toggle_off.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!/usr/bin/env bash

CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/variables.sh"

tmux set -u prefix
tmux set -u key-table

# Restore the original status-left saved by toggle_on, then clear the saved value so
# the next toggle_on cycle saves the current status-left rather than the stale snapshot.
saved="$(tmux show-option -gv @remote-saved-status-left 2>/dev/null)"
saved="$(tmux show-option -gv "$saved_status_left_option" 2>/dev/null)"
if [[ -n "$saved" ]]; then
tmux set -g status-left "$saved"
fi
tmux set -gu @remote-saved-status-left
tmux set -gu "$saved_status_left_option"

tmux refresh-client -S
13 changes: 8 additions & 5 deletions scripts/toggle_on.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/usr/bin/env bash

CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/variables.sh"

# Save the current status-left so toggle_off can restore it (only once)
saved="$(tmux show-option -gv @remote-saved-status-left 2>/dev/null)"
saved="$(tmux show-option -gv "$saved_status_left_option" 2>/dev/null)"
if [[ -z "$saved" ]]; then
tmux set -g @remote-saved-status-left "$(tmux show-option -gv status-left)"
tmux set -g "$saved_status_left_option" "$(tmux show-option -gv status-left)"
fi

# Read indicator options
text="$(tmux show-option -gv @remote-indicator-text)"
fg="$(tmux show-option -gv @remote-indicator-fg)"
bg="$(tmux show-option -gv @remote-indicator-bg)"
text="$(tmux show-option -gv "$indicator_text_option")"
fg="$(tmux show-option -gv "$indicator_fg_option")"
bg="$(tmux show-option -gv "$indicator_bg_option")"

tmux set prefix None
tmux set key-table off
Expand Down
1 change: 1 addition & 0 deletions scripts/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ off_key_option="@remote-off-key"
indicator_text_option="@remote-indicator-text"
indicator_fg_option="@remote-indicator-fg"
indicator_bg_option="@remote-indicator-bg"
saved_status_left_option="@remote-saved-status-left"

# default option values
default_toggle_key="F12"
Expand Down
Loading