Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alacritty/alacritty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ args = [ "--login", "-c", "/opt/homebrew/bin/tmux new-session -A -D -s CheverJoh
# args = [ "--login" ]

[env]
TERM = "tmux-256color"
TERM = "xterm-256color"

[scrolling]
# 滚动历史记录的行数,例如此处设置,会保存最近的 10,000 行历史记录
Expand Down
15 changes: 14 additions & 1 deletion alacritty/mouse.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# 鼠标配置
[mouse]
hide_when_typing = false
hide_when_typing = false

# 双击选择单词的分隔符
double_click = { threshold = 300 }
triple_click = { threshold = 300 }

# 鼠标绑定
[[mouse.bindings]]
mouse = "Middle"
action = "PasteSelection"

[[mouse.bindings]]
mouse = "Right"
action = "PasteSelection"

60 changes: 60 additions & 0 deletions scripts/fix-mouse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

echo "🐭 Fixing Alacritty + tmux mouse support..."

# 1. Reload tmux configuration if in tmux
if [ -n "$TMUX" ]; then
echo "📋 Reloading tmux configuration..."
tmux source-file ~/.dotfiles/tmux/tmux.conf
echo "✅ Tmux config reloaded"
else
echo "ℹ️ Not in tmux session - config will apply on next tmux start"
fi

# 2. Test mouse support
echo ""
echo "🧪 Testing mouse support..."

# Check if we can enable mouse reporting
printf '\033[?1000h' # Enable mouse reporting
printf '\033[?1002h' # Enable cell motion mouse tracking
printf '\033[?1015h' # Enable urxvt mouse mode
printf '\033[?1006h' # Enable SGR mouse mode

echo "Mouse reporting enabled"

# 3. Instructions
echo ""
echo "🎯 Next steps:"
echo "1. If you're not in tmux, start a new tmux session:"
echo " tmux new-session -s main"
echo ""
echo "2. If still having issues, try these tmux commands:"
echo " tmux set -g mouse on"
echo " tmux set -g terminal-overrides 'xterm*:smcup@:rmcup@'"
echo ""
echo "3. Test mouse functionality:"
echo " - Click to position cursor"
echo " - Drag to select text"
echo " - Right-click to paste"
echo " - Scroll wheel to scroll"

# 4. Create a test environment
echo ""
echo "🔧 Creating test environment..."
cat > /tmp/mouse-test.txt << 'EOF'
This is a test file for mouse functionality.
Try clicking on different words.
Try selecting text by dragging.
Try scrolling with the mouse wheel.
Try right-clicking to paste.

Line 1: The quick brown fox jumps over the lazy dog.
Line 2: Pack my box with five dozen liquor jugs.
Line 3: How vexingly quick daft zebras jump!
Line 4: The five boxing wizards jump quickly.
Line 5: Bright vixens jump; dozy fowl quack.
EOF

echo "Test file created at /tmp/mouse-test.txt"
echo "Open it with: cat /tmp/mouse-test.txt"
40 changes: 40 additions & 0 deletions scripts/mouse-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

echo "=== Mouse Support Diagnostic ==="
echo "Current TERM: $TERM"
echo "TMUX session: ${TMUX:-Not in tmux}"
echo ""

echo "=== Testing mouse capabilities ==="
echo "1. Check if terminal supports mouse:"
if command -v tput >/dev/null 2>&1; then
if tput kmous >/dev/null 2>&1; then
echo " ✓ Terminal supports mouse"
else
echo " ✗ Terminal may not support mouse"
fi
else
echo " ? tput not available"
fi

echo ""
echo "2. Current terminal info:"
echo " TERM: $TERM"
echo " COLORTERM: ${COLORTERM:-not set}"
echo " ALACRITTY_SOCKET: ${ALACRITTY_SOCKET:-not set}"

echo ""
echo "3. Tmux mouse settings (if in tmux):"
if [ -n "$TMUX" ]; then
echo " Mouse mode: $(tmux show-options -g mouse | cut -d' ' -f2)"
echo " Terminal overrides: $(tmux show-options -g terminal-overrides)"
else
echo " Not currently in tmux session"
fi

echo ""
echo "=== Recommendations ==="
echo "If you see escape sequences when clicking:"
echo "1. Make sure you're in a tmux session"
echo "2. Check terminal-overrides in tmux config"
echo "3. Verify TERM variable is correct"
33 changes: 33 additions & 0 deletions scripts/test-mouse-tmux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

echo "🧪 Starting mouse test in tmux..."

# Kill any existing test session
tmux kill-session -t mouse-test 2>/dev/null

# Create new session with test content
tmux new-session -d -s mouse-test -c "$HOME"

# Send test content to the session
tmux send-keys -t mouse-test 'clear' Enter
tmux send-keys -t mouse-test 'echo "=== MOUSE TEST ==="' Enter
tmux send-keys -t mouse-test 'echo "Try the following:"' Enter
tmux send-keys -t mouse-test 'echo "1. Click anywhere to position cursor"' Enter
tmux send-keys -t mouse-test 'echo "2. Drag to select text"' Enter
tmux send-keys -t mouse-test 'echo "3. Right-click to paste selected text"' Enter
tmux send-keys -t mouse-test 'echo "4. Use mouse wheel to scroll"' Enter
tmux send-keys -t mouse-test 'echo "5. Click on pane borders to switch panes"' Enter
tmux send-keys -t mouse-test 'echo ""' Enter
tmux send-keys -t mouse-test 'cat /tmp/mouse-test.txt' Enter

# Split window for more testing
tmux split-window -h -t mouse-test
tmux send-keys -t mouse-test:0.1 'echo "Right pane - try clicking here!"' Enter
tmux send-keys -t mouse-test:0.1 'echo "Mouse should work in both panes"' Enter

# Select left pane
tmux select-pane -t mouse-test:0.0

echo "✅ Test session created!"
echo "🚀 Attach with: tmux attach -t mouse-test"
echo "🧹 Clean up with: tmux kill-session -t mouse-test"
17 changes: 15 additions & 2 deletions tmux/tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,29 @@ set -g set-clipboard on
# mouse behavior
set -g mouse on

# mouse wheel scrolling
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M

# mouse drag to copy
bind -T copy-mode-vi WheelUpPane select-pane \; send-keys -X -N 5 scroll-up
bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 5 scroll-down

# disable escape delay
set -sg escape-time 0

### LOOK && FEEL ###

# truecolor support
set -sa terminal-features ',tmux-256color:RGB'
set -sa terminal-features ',xterm-256color:RGB'

# default terminal is 256 colors
set -g default-terminal 'tmux-256color'
set -g default-terminal 'screen-256color'

# terminal overrides for mouse support
set -ga terminal-overrides ',xterm-256color:Tc'
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'
set -ga terminal-overrides ',*:sitm=\E[3m'

# default statusbar colors
set -g status-bg default
Expand Down