diff --git a/README.md b/README.md index 7b38851..ce0e39a 100644 --- a/README.md +++ b/README.md @@ -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 '' +# 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' @@ -60,6 +63,22 @@ set -g @floax-bind-menu 'P' set -g @floax-width '80%' set -g @floax-height '80%' +# The default location of the floating pane. +# Both may be a row or column number, +# or one of the following special values (from 'man tmux' or https://man.openbsd.org/OpenBSD-current/man1/tmux.1#display-menu): + # Value Flag Meaning + # C Both The centre of the terminal + # R -x The right side of the terminal + # P Both The bottom left of the pane + # M Both The mouse position + # W Both The window position on the status line + # S -y The line above or below the status line +For instance, to make it locate in the top-right +# set -g @floax-width 'R' +# set -g @floax-height '0' +set -g @floax-x 'C' +set -g @floax-y 'C' + # The border color can be changed, these are the colors supported by Tmux: # black, red, green, yellow, blue, magenta, cyan, white for the standard # terminal colors; brightred, brightyellow and so on for the bright variants; @@ -84,9 +103,13 @@ set -g @floax-session-name 'some-other-session-name' # Change the title of the floating window set -g @floax-title 'floax' + +# If you want to enable the status bar, you can set this to 'on' +set -g @floax-status-bar 'off' ``` ## Known issues 🐞 + - ~Sizing too much down will break the script~ ## Contributors 🙌 diff --git a/floax.tmux b/floax.tmux index 9ff47b6..a5a6344 100755 --- a/floax.tmux +++ b/floax.tmux @@ -6,14 +6,18 @@ source "$CURRENT_DIR/scripts/utils.sh" tmux bind-key $(tmux_option_or_fallback "@floax-bind" "p") run-shell "$CURRENT_DIR/floax.sh" tmux bind-key "$(tmux_option_or_fallback "@floax-bind-menu" "P")" run-shell "$CURRENT_DIR/menu.sh" -tmux setenv -g FLOAX_WIDTH "$(tmux_option_or_fallback '@floax-width' '80%')" -tmux setenv -g FLOAX_HEIGHT "$(tmux_option_or_fallback '@floax-height' '80%')" +tmux setenv -g FLOAX_WIDTH "$(tmux_option_or_fallback '@floax-width' '80%')" +tmux setenv -g FLOAX_HEIGHT "$(tmux_option_or_fallback '@floax-height' '80%')" +tmux setenv -g FLOAX_X "$(tmux_option_or_fallback '@floax-x' 'C')" +tmux setenv -g FLOAX_Y "$(tmux_option_or_fallback '@floax-y' 'C')" # Options: black, red, green, yellow, blue, magenta, cyan, white 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_STATUS_BAR "$(tmux_option_or_fallback '@floax-status-bar' 'off')" tmux setenv -g FLOAX_SESSION_NAME "$(tmux_option_or_fallback '@floax-session-name' "${DEFAULT_SESSION_NAME}")" eval "$(tmux showenv -s)" diff --git a/scripts/floax.sh b/scripts/floax.sh index f4b5240..d55ee84 100755 --- a/scripts/floax.sh +++ b/scripts/floax.sh @@ -2,6 +2,7 @@ CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$CURRENT_DIR/utils.sh" +FLOAX_STATUS_BAR=$(envvar_value FLOAX_STATUS_BAR) tmux setenv -g ORIGIN_SESSION "$(tmux display -p '#{session_name}')" if [ "$(tmux display-message -p '#{session_name}')" = "$FLOAX_SESSION_NAME" ]; then @@ -26,7 +27,7 @@ else else # Create a new session named 'scratch' and attach to it tmux new-session -d -c "$(tmux display-message -p '#{pane_current_path}')" -s "$FLOAX_SESSION_NAME" - tmux set-option -t "$FLOAX_SESSION_NAME" status off + tmux set-option -t "$FLOAX_SESSION_NAME" status "${FLOAX_STATUS_BAR}" tmux_popup fi fi diff --git a/scripts/utils.sh b/scripts/utils.sh index 62c5b8d..a57bd79 100755 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -14,34 +14,37 @@ tmux_option_or_fallback() { } FLOAX_WIDTH=$(envvar_value FLOAX_WIDTH) +FLOAX_X=$(envvar_value FLOAX_X) +FLOAX_Y=$(envvar_value FLOAX_Y) FLOAX_HEIGHT=$(envvar_value FLOAX_HEIGHT) 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() { @@ -105,9 +108,11 @@ pop() { -S fg="$FLOAX_BORDER_COLOR" \ -s fg="$FLOAX_TEXT_COLOR" \ -T "$FLOAX_TITLE" \ + -x "$FLOAX_X" \ + -y "$FLOAX_Y" \ -w "$FLOAX_WIDTH" \ -h "$FLOAX_HEIGHT" \ -b rounded \ -E \ - "tmux attach-session -t \"$FLOAX_SESSION_NAME\"" + "tmux attach-session -t \"$FLOAX_SESSION_NAME\"" } diff --git a/scripts/zoom-options.sh b/scripts/zoom-options.sh index 7d5b5a0..4b25aa1 100755 --- a/scripts/zoom-options.sh +++ b/scripts/zoom-options.sh @@ -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() {