Skip to content

julian0xff/tmux-focus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tmux-focus

Focus-follows-mouse for tmux panes in Ghostty.

Hover your mouse over a tmux pane and it automatically gets focus — no clicking required. Just like Ghostty's native focus-follows-mouse, but for tmux panes.

Demo

Split your terminal into panes with tmux, then just move your mouse between them. The active pane follows your cursor.

Install

Requires macOS 13+ and Ghostty terminal.

git clone https://github.com/julian0xff/tmux-focus.git
cd tmux-focus
swift build -c release
cp .build/release/tmux-focus /usr/local/bin/

Or with Homebrew (coming soon):

brew install julian0xff/tap/tmux-focus

Usage

tmux-focus          # Start the daemon (run in background with &)
tmux-focus --stop   # Stop the daemon
tmux-focus --help   # Show all options

Start it in the background:

tmux-focus &

Options

Flag Description
--tmux <path> Path to tmux binary (auto-detected)
--padding-x <px> Override Ghostty window-padding-x
--padding-y <top,bottom> Override Ghostty window-padding-y
--hz <number> Mouse polling rate in Hz (default: 20)

How it works

  1. Monitors mouse movement via macOS global event monitor
  2. Detects the Ghostty window under the cursor
  3. Maps pixel coordinates to tmux cell coordinates using your Ghostty padding config
  4. Runs tmux select-pane when you hover over a different pane

Auto-configuration

The daemon reads your Ghostty config (~/.config/ghostty/config) to get the correct padding values. No manual configuration needed for most setups.

Safety

  • Only activates when Ghostty is the frontmost app
  • Only runs when tmux has 2+ panes (single pane = no-op)
  • Only calls tmux select-pane when the pane actually changes (not on every mouse move)
  • Throttled to 20Hz — negligible CPU usage (~0.1%)
  • Does nothing when tmux is not running

Auto-start

Add to your shell config (.zshrc / .bashrc):

# Start tmux-focus if tmux is running and daemon isn't
if command -v tmux-focus >/dev/null 2>&1 && tmux list-sessions &>/dev/null && ! pgrep -qf 'tmux-focus$'; then
    tmux-focus &>/dev/null &
    disown
fi

Requirements

  • macOS 13.0+
  • Ghostty terminal
  • tmux
  • Accessibility permissions (System Settings → Privacy & Security → Accessibility → Ghostty)

License

MIT

About

Focus-follows-mouse for tmux panes in Ghostty

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages