Skip to content

Commit

Permalink
feat: Adding config to configure prefix for quick actions on pane
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatheu committed Dec 12, 2024
1 parent 050ab7c commit 72186d7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ set -g @floax-bind '-n M-p'
# Setting the main key to toggle the floating pane on and off
set -g @floax-bind '<my-key>'

# Setting the prefix key for quick actions in the floating pane (zoom in, zoom out, reset, lock, unlock, etc)
set -g @floax-prefix 'C-M'

# When the pane is toggled, using this bind pops a menu with additional options
# such as resize, fullscreen, resetting to defaults and more.
set -g @floax-bind-menu 'P'
Expand Down
3 changes: 2 additions & 1 deletion floax.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ tmux setenv -g FLOAX_Y "$(tmux_option_or_fallback '@floax-y' 'C')"
tmux setenv -g FLOAX_BORDER_COLOR "$(tmux_option_or_fallback '@floax-border-color' 'magenta')"
tmux setenv -g FLOAX_TEXT_COLOR "$(tmux_option_or_fallback '@floax-text-color' 'blue')"
tmux setenv -g FLOAX_TITLE "$(tmux_option_or_fallback '@floax-title' "${DEFAULT_TITLE}")"
tmux setenv -g FLOAX_CHANGE_PATH "$(tmux_option_or_fallback '@floax-change-path' 'true')"
tmux setenv -g FLOAX_CHANGE_PATH "$(tmux_option_or_fallback '@floax-change-path' 'true')"
tmux setenv -g FLOAX_PREFIX "$(tmux_option_or_fallback '@floax-prefix' 'C')"
tmux setenv -g FLOAX_SESSION_NAME "$(tmux_option_or_fallback '@floax-session-name' "${DEFAULT_SESSION_NAME}")"

eval "$(tmux showenv -s)"
31 changes: 16 additions & 15 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,30 @@ FLOAX_BORDER_COLOR=$(envvar_value FLOAX_BORDER_COLOR)
FLOAX_TEXT_COLOR=$(envvar_value FLOAX_TEXT_COLOR)
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FLOAX_CHANGE_PATH=$(envvar_value FLOAX_CHANGE_PATH)
FLOAX_PREFIX=$(envvar_value FLOAX_PREFIX)
FLOAX_TITLE=$(envvar_value FLOAX_TITLE)
DEFAULT_TITLE='FloaX: C-M-s 󰘕  C-M-b 󰁌  C-M-f 󰊓  C-M-r 󰑓  C-M-e 󱂬  C-M-d '
DEFAULT_TITLE="FloaX: ${FLOAX_PREFIX}-s 󰘕  ${FLOAX_PREFIX}-b 󰁌  ${FLOAX_PREFIX}-f 󰊓  ${FLOAX_PREFIX}-r 󰑓  ${FLOAX_PREFIX}-e 󱂬  ${FLOAX_PREFIX}-d "
FLOAX_SESSION_NAME=$(envvar_value FLOAX_SESSION_NAME)
DEFAULT_SESSION_NAME='scratch'

set_bindings() {
tmux bind -n C-M-s run "$CURRENT_DIR/zoom-options.sh in"
tmux bind -n c-M-b run "$CURRENT_DIR/zoom-options.sh out"
tmux bind -n C-M-f run "$CURRENT_DIR/zoom-options.sh full"
tmux bind -n C-M-r run "$CURRENT_DIR/zoom-options.sh reset"
tmux bind -n C-M-e run "$CURRENT_DIR/embed.sh embed"
tmux bind -n C-M-d run "$CURRENT_DIR/zoom-options.sh lock"
tmux bind -n C-M-u run "$CURRENT_DIR/zoom-options.sh unlock"
tmux bind -n "${FLOAX_PREFIX}-s" run "$CURRENT_DIR/zoom-options.sh in"
tmux bind -n "${FLOAX_PREFIX}-b" run "$CURRENT_DIR/zoom-options.sh out"
tmux bind -n "${FLOAX_PREFIX}-f" run "$CURRENT_DIR/zoom-options.sh full"
tmux bind -n "${FLOAX_PREFIX}-r" run "$CURRENT_DIR/zoom-options.sh reset"
tmux bind -n "${FLOAX_PREFIX}-e" run "$CURRENT_DIR/embed.sh embed"
tmux bind -n "${FLOAX_PREFIX}-d" run "$CURRENT_DIR/zoom-options.sh lock"
tmux bind -n "${FLOAX_PREFIX}-u" run "$CURRENT_DIR/zoom-options.sh unlock"
}

unset_bindings() {
tmux unbind -n C-M-s
tmux unbind -n C-M-b
tmux unbind -n C-M-f
tmux unbind -n C-M-r
tmux unbind -n C-M-e
tmux unbind -n C-M-d
tmux unbind -n C-M-u
tmux unbind -n "${FLOAX_PREFIX}-s"
tmux unbind -n "${FLOAX_PREFIX}-b"
tmux unbind -n "${FLOAX_PREFIX}-f"
tmux unbind -n "${FLOAX_PREFIX}-r"
tmux unbind -n "${FLOAX_PREFIX}-e"
tmux unbind -n "${FLOAX_PREFIX}-d"
tmux unbind -n "${FLOAX_PREFIX}-u"
}

tmux_version() {
Expand Down
4 changes: 2 additions & 2 deletions scripts/zoom-options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ unlock_bindings() {

lock_bindings() {
unset_bindings
tmux bind -n C-M-u run "$CURRENT_DIR/zoom-options.sh unlock"
change_popup_title "Bindings locked. Unlock with [Ctrl-Alt-u]"
tmux bind -n "${FLOAX_PREFIX}-u" run "$CURRENT_DIR/zoom-options.sh unlock"
change_popup_title "Bindings locked. Unlock with [${FLOAX_PREFIX}-u]"
}

change_popup_title() {
Expand Down

0 comments on commit 72186d7

Please sign in to comment.