diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f5e0a4..0847f38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +### v0.1.1, 2026-06-16 +- fix: calling toggle_off before toggle_on (or after server restart) no longer blanks status-left +- fix: clear saved status-left state after each toggle-off so re-toggling captures the current value +- fix: suppress spurious stderr from tmux show-option on unset options during plugin init and first toggle +- 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 + ### v0.1.0, 2018-05-20 - initial work on the plugin - add readme diff --git a/remote.tmux b/remote.tmux index 80ed42b..df85763 100755 --- a/remote.tmux +++ b/remote.tmux @@ -25,16 +25,16 @@ main() { tmux set-option -g "$indicator_bg_option" "$default_indicator_bg" fi - local toggle_key=$(tmux show-option -gv "$toggle_key_option") - local on_key=$(tmux show-option -gv "$on_key_option") - local off_key=$(tmux show-option -gv "$off_key_option") - - tmux unbind -T root "$toggle_key" - tmux unbind -T off "$toggle_key" - tmux unbind -T root "$on_key" - tmux unbind -T off "$on_key" - tmux unbind -T root "$off_key" - tmux unbind -T off "$off_key" + local toggle_key; toggle_key=$(tmux show-option -gv "$toggle_key_option") + local on_key; on_key=$(tmux show-option -gv "$on_key_option") + local off_key; off_key=$(tmux show-option -gv "$off_key_option") + + tmux unbind -T root "$toggle_key" 2>/dev/null || true + tmux unbind -T off "$toggle_key" 2>/dev/null || true + tmux unbind -T root "$on_key" 2>/dev/null || true + tmux unbind -T off "$on_key" 2>/dev/null || true + tmux unbind -T root "$off_key" 2>/dev/null || true + tmux unbind -T off "$off_key" 2>/dev/null || true # Press the toggle key to toggle "remote mode"; disables host bindings for # using tmux in nested sessions diff --git a/scripts/helpers.sh b/scripts/helpers.sh index a066728..eed6985 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -1,5 +1,6 @@ option_not_set() { local option="$1" - local option_value=$(tmux show-option -gv "$option") + local option_value + option_value=$(tmux show-option -gv "$option" 2>/dev/null) [[ -z "$option_value" ]] } diff --git a/scripts/toggle_off.sh b/scripts/toggle_off.sh index 0fd343b..aded15d 100755 --- a/scripts/toggle_off.sh +++ b/scripts/toggle_off.sh @@ -3,8 +3,12 @@ tmux set -u prefix tmux set -u key-table -# Restore the original status-left saved by toggle_on +# 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)" -tmux set -g status-left "$saved" +if [[ -n "$saved" ]]; then + tmux set -g status-left "$saved" +fi +tmux set -gu @remote-saved-status-left tmux refresh-client -S diff --git a/scripts/toggle_on.sh b/scripts/toggle_on.sh index e4330b6..1716257 100755 --- a/scripts/toggle_on.sh +++ b/scripts/toggle_on.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Save the current status-left so toggle_off can restore it (only once) -saved="$(tmux show-option -gv @remote-saved-status-left)" +saved="$(tmux show-option -gv @remote-saved-status-left 2>/dev/null)" if [[ -z "$saved" ]]; then tmux set -g @remote-saved-status-left "$(tmux show-option -gv status-left)" fi diff --git a/tests/test_default_options.sh b/tests/test_default_options.sh index e1ea755..14623b7 100755 --- a/tests/test_default_options.sh +++ b/tests/test_default_options.sh @@ -1,9 +1,9 @@ - #/usr/bin/env bash +#!/usr/bin/env bash CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # bash helpers provided by 'tmux-test' - source $CURRENT_DIR/helpers/helpers.sh + source "$CURRENT_DIR/helpers/helpers.sh" # installs plugin from current repo in Vagrant (or on Travis) install_tmux_plugin_under_test_helper