├── images └── Zap.gif ├── main.tmux ├── readme.md └── scripts ├── session_zap.sh └── zap.sh /images/Zap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleckAstan/tmux-zap/40eebfc58247338c3d77300bed8d7532dd87a9d8/images/Zap.gif -------------------------------------------------------------------------------- /main.tmux: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | DEFAULT_KEY="z" 4 | ZAP_KEY=$(tmux show-option -gqv @zap_key) 5 | ZAP_KEY=${ZAP_KEY:-$DEFAULT_KEY} 6 | 7 | if [ "$ZAP_KEY" = "$DEFAULT_KEY" ]; then 8 | tmux unbind-key -T prefix "$DEFAULT_KEY" 2>/dev/null 9 | fi 10 | 11 | ZAP_WIDTH=$(tmux show-option -gqv @zap_width) 12 | ZAP_WIDTH=${ZAP_WIDTH:-"90%"} 13 | ZAP_HEIGHT=$(tmux show-option -gqv @zap_height) 14 | ZAP_HEIGHT=${ZAP_HEIGHT:-"60%"} 15 | ZAP_MODE=$(tmux show-option -gqv @zap_mode) 16 | ZAP_MODE=${ZAP_MODE:-window} 17 | 18 | if [ "$ZAP_MODE" = "window" ]; then 19 | tmux bind-key "$ZAP_KEY" run-shell "tmux popup -E -w $ZAP_WIDTH -h $ZAP_HEIGHT \"$CURRENT_DIR/scripts/zap.sh\"" 20 | fi 21 | 22 | if [ "$ZAP_MODE" = "session" ]; then 23 | tmux bind-key "$ZAP_KEY" run-shell "tmux popup -E -w $ZAP_WIDTH -h $ZAP_HEIGHT \"$CURRENT_DIR/scripts/session_zap.sh\"" 24 | fi 25 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # tmux-zap 2 | 3 | `tmux-zap` is a minimal tmux plugin that lets you **instantly jump to any window from any session** using fuzzy search. 4 | 5 | 6 | ![tmux-zap demo](./images/Zap.gif) 7 | ## Features 8 | 9 | - Lists **all windows** from all tmux sessions. 10 | - Allows **fuzzy search** by window name. 11 | - **Instant switching** to the selected window. 12 | - **Customizable** keybinding and popup size. 13 | 14 | ## Installation 15 | 16 | ### With TPM (Tmux Plugin Manager) 17 | 18 | Add the following to your `.tmux.conf`: 19 | 20 | ```tmux 21 | set -g @plugin 'AleckAstan/tmux-zap' 22 | 23 | # Optional configurations 24 | set -g @zap_key 's' # default: 'z' 25 | set -g @zap_width '50%' # default: '60%' 26 | set -g @zap_height '40%' # default: '60%' 27 | ``` 28 | 29 | Then reload your tmux config and install the plugin with: 30 | 31 | ```bash 32 | # Press prefix + I (capital i) to install 33 | ``` 34 | 35 | ### Manual Installation 36 | 37 | ```bash 38 | git clone https://github.com/AleckAstan/tmux-zap ~/.tmux/plugins/tmux-zap 39 | ``` 40 | 41 | Add this to your `.tmux.conf`: 42 | 43 | ```tmux 44 | bind-key z run-shell ~/.tmux/plugins/tmux-zap/zap.tmux 45 | ``` 46 | 47 | ## Usage 48 | 49 | Press your configured keybinding (default is `prefix + z`, or `prefix + s` if set as above). 50 | 51 | 1. A popup window will appear listing all windows from all tmux sessions. 52 | 2. Type to fuzzy search for a window. 53 | 3. Press `Enter` to switch to the selected window. 54 | 55 | ## Configuration Options 56 | 57 | | Option | Default | Description | 58 | |------------------|---------|----------------------------------| 59 | | `@zap_key` | `z` | Keybinding to trigger the zap. | 60 | | `@zap_width` | `60%` | Width of the popup window. | 61 | | `@zap_height` | `60%` | Height of the popup window. | 62 | 63 | Example: 64 | 65 | ```tmux 66 | set -g @zap_key 's' 67 | set -g @zap_width '50%' 68 | set -g @zap_height '40%' 69 | ``` 70 | 71 | ## Requirements 72 | 73 | - [fzf](https://github.com/junegunn/fzf) 74 | - tmux >= 3.2 (popup support) 75 | 76 | ## License 77 | 78 | MIT 79 | 80 | -------------------------------------------------------------------------------- /scripts/session_zap.sh: -------------------------------------------------------------------------------- 1 | tmux list-sessions -F '#{session_name}' | 2 | fzf --prompt='Zap to session: ' \ 3 | --reverse \ 4 | | cut -d':' -f1,2 | 5 | while IFS=':' read -r session; do 6 | tmux switch-client -t "$session" 7 | done 8 | -------------------------------------------------------------------------------- /scripts/zap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | REQUIRED_TMUX_VERSION="3.2" 3 | 4 | version_ge() { 5 | [ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ] 6 | } 7 | 8 | if ! command -v fzf &> /dev/null; then 9 | echo "Error: fzf is not installed. Please install fzf first." 10 | exit 1 11 | fi 12 | 13 | if ! command -v tmux &> /dev/null; then 14 | echo "Error: tmux is not installed. Please install tmux first." 15 | exit 1 16 | fi 17 | 18 | CURRENT_TMUX_VERSION=$(tmux -V | awk '{print $2}') 19 | if ! version_ge "$CURRENT_TMUX_VERSION" "$REQUIRED_TMUX_VERSION"; then 20 | echo "Error: tmux $REQUIRED_TMUX_VERSION or higher is required. You have tmux $CURRENT_TMUX_VERSION." 21 | exit 1 22 | fi 23 | 24 | tmux list-windows -a -F '#{session_name}:#{window_index}:#{window_name}' | 25 | fzf --prompt='Zap to window: ' \ 26 | --reverse \ 27 | | cut -d':' -f1,2 | 28 | while IFS=':' read -r session window; do 29 | tmux switch-client -t "$session" 30 | tmux select-window -t "${session}:$window" 31 | done 32 | --------------------------------------------------------------------------------