👻
今更ながらtmuxの設定をしてみた
自分の環境
- MacBook Pro 16-inch, 2019
- mac OS Sonoma 14.4.1
tmux.confは以下で、自分は手が大きいのでctrl + bのままにしている:
# Use zsh as the default shell
set-option -g default-shell /bin/zsh
# Enable 256 colors and true color support
set-option -g default-terminal "tmux-256color"
set -ga terminal-overrides ",xterm-256color:Tc"
# Set prefix key to C-b (default)
set -g prefix C-b
# Move status bar to the top
set-option -g status-position top
# Set status bar length
set-option -g status-left-length 90
set-option -g status-right-length 90
# Customize status bar content
set-option -g status-left "#[fg=green]#H #[fg=yellow]Pane:#P"
set-option -g status-right '#(pmset -g batt | grep -o "[0-9]*%") [%Y-%m-%d(%a) %H:%M]'
# Refresh status bar every second
set-option -g status-interval 1
# Center align window names in status bar
set-option -g status-justify centre
# Set status bar colors
set-option -g status-bg colour238
set-option -g status-fg colour255
# Enable vim-style pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Enable vim-style pane resizing
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Split panes using | (vertical) and - (horizontal)
bind | split-window -h
bind - split-window -v
# Use base index 1 for windows and panes
set-option -g base-index 1
# Enable mouse support
set-option -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{pane_in_mode}" "send-keys -M" "copy-mode -e"
# Enable vi keybindings in copy mode
setw -g mode-keys vi
# Configure copy mode for vim-like selections
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi V send -X select-line
bind -T copy-mode-vi C-v send -X rectangle-toggle
bind -T copy-mode-vi y send -X copy-selection \; run-shell "tmux save-buffer - | pbcopy" # macOS
# Paste from clipboard using C-p
bind-key C-p run-shell "tmux show-buffer | pbcopy" # macOS
# Ensure system clipboard support is enabled
set-option -g set-clipboard on
# Fix macOS clipboard issue with reattach-to-user-namespace
# Uncomment if running macOS
# set-option -g default-command "reattach-to-user-namespace -l zsh"
これでだいぶ快適になりそう。
Discussion