rwx/sh/tmux.sh

172 lines
3.8 KiB
Bash
Raw Normal View History

2025-01-17 09:27:59 +00:00
# ╭──────┬───────╮
# │ tmux │ setup │
# ╰──────┴───────╯
rwx_tmux_setup() {
2025-01-17 23:19:15 +00:00
local file
file="${HOME}/.tmux.conf"
rwx_file_write "${file}" "\
2025-01-18 21:27:50 +00:00
# ╭────────╮
# │ option │
# ╰────────╯
# empty name for windows
set-option -g automatic-rename-format '#{pane_current_command}'
set-option -g automatic-rename on
2025-01-18 13:39:03 +00:00
# first index number
set-option -g base-index 1
2025-01-18 21:27:50 +00:00
2025-01-17 23:15:17 +00:00
# display duration
2025-01-17 23:37:58 +00:00
set-option -g display-time 1536
2025-01-17 09:27:59 +00:00
2025-01-17 23:42:26 +00:00
# extend history limit
set-option -g history-limit 1048576
2025-01-18 21:27:50 +00:00
# style for messages
set-option -g message-style bg=red,fg=white
# activity monitoring
set-window-option -g monitor-activity on
# silence monitoring
set-window-option -g monitor-silence 0
2025-01-17 11:15:11 +00:00
# enable mouse actions
2025-01-17 23:37:58 +00:00
set-option -g mouse on
2025-01-18 21:27:50 +00:00
# prefix with ^B or F12
set-option -g prefix C-b
set-option -g prefix2 F12
2025-01-17 11:15:11 +00:00
# renumber windows after closing one
2025-01-17 23:37:58 +00:00
set-option -g renumber-windows on
2025-01-17 09:27:59 +00:00
2025-01-17 13:33:35 +00:00
# enable title
2025-01-17 23:37:58 +00:00
set-option -g set-titles on
2025-01-18 21:27:50 +00:00
2025-01-17 13:33:35 +00:00
# set title to working directory
2025-01-18 20:04:26 +00:00
set-option -g set-titles-string '\
tmux / \
#{session_name} / \
#{window_index} #{window_name} / \
#{pane_index} #{pane_width}×#{pane_height}\
'
2025-01-17 09:27:59 +00:00
2025-01-18 21:27:50 +00:00
# status lines
set-option -g status 3
# ╭────────┬──────╮
# │ option │ pane │
# ╰────────┴──────╯
# first index number
set-option -g pane-base-index 1
# ╭────────┬──────┬────────╮
# │ option │ pane │ border │
# ╰────────┴──────┴────────╯
# active style
set-option -g pane-active-border-style bg=black,fg=green
# regular style
set-option -g pane-border-style bg=black,fg=gray
# ╭────────┬────────╮
# │ option │ status │
# ╰────────┴────────╯
# background color
2025-01-17 23:37:58 +00:00
set-option -g status-bg black
2025-01-18 21:27:50 +00:00
# foreground color
2025-01-17 23:37:58 +00:00
set-option -g status-fg gray
2025-01-18 21:27:50 +00:00
# first line
2025-01-18 20:10:57 +00:00
set-option -g status-format[0] '\
2025-01-18 20:26:17 +00:00
#{W:\
2025-01-18 19:20:21 +00:00
#{?window_active,#[fg=green],\
#{?window_activity_flag,#[fg=red],#[fg=default]}}\
2025-01-18 19:22:29 +00:00
#{window_index} \
2025-01-18 19:15:55 +00:00
#{window_name}\
2025-01-18 19:23:31 +00:00
#{?window_flags, #{window_flags},}\
2025-01-18 20:26:17 +00:00
\
2025-01-18 19:15:55 +00:00
}\
2025-01-18 20:52:29 +00:00
#[align=centre]\
2025-01-18 20:51:27 +00:00
#[fg=blue]#{session_name}\
2025-01-18 19:15:55 +00:00
#[align=right] \
2025-01-18 20:18:16 +00:00
#[fg=yellow]%Y-%m-%d\
'
2025-01-18 21:27:50 +00:00
# second line
2025-01-18 20:18:16 +00:00
set-option -g status-format[1] '\
2025-01-18 20:26:17 +00:00
#{P:\
2025-01-18 19:15:55 +00:00
#{?pane_active,#[fg=green],#[fg=default]}\
#{pane_index}\
2025-01-18 20:26:17 +00:00
\
2025-01-18 19:15:55 +00:00
}\
2025-01-18 20:52:29 +00:00
#[align=centre]\
2025-01-18 20:26:17 +00:00
#[fg=blue]#{pane_width}×#{pane_height}\
2025-01-18 19:15:55 +00:00
#[align=right] \
2025-01-18 20:18:16 +00:00
#[fg=yellow]%H:%M:%S\
2025-01-18 19:11:16 +00:00
'
2025-01-18 21:27:50 +00:00
# third line
2025-01-18 20:10:57 +00:00
set-option -g status-format[2] '\
#[fg=cyan]#{pane_current_path}\
'
2025-01-18 21:27:50 +00:00
# refresh period
2025-01-17 23:37:58 +00:00
set-option -g status-interval 1
2025-01-18 21:27:50 +00:00
# bar location
2025-01-17 23:37:58 +00:00
set-option -g status-position top
2025-01-17 09:27:59 +00:00
2025-01-18 21:27:50 +00:00
# ╭─────╮
# │ key │
# ╰─────╯
2025-01-17 09:27:59 +00:00
2025-01-18 21:27:50 +00:00
# select sessions with Alt & ↑ | ↓
bind-key -n M-Down switch-client -n
bind-key -n M-Up switch-client -p
2025-01-17 09:27:59 +00:00
2025-01-18 21:27:50 +00:00
# ╭─────┬────────╮
# │ key │ prefix │
# ╰─────┴────────╯
# reload configuration
bind-key r source-file ${file} \\; display-message 'source-file ${file}'
# toggle mouse
bind-key t set-option -g mouse \\; display-message 'mouse = #{mouse}'
# ╭─╮
# ╰─╯
2025-01-17 09:27:59 +00:00
2025-01-17 11:17:51 +00:00
# bind key to detach client
2025-01-17 23:37:58 +00:00
bind-key -n F6 detach-client
2025-01-17 09:27:59 +00:00
2025-01-17 18:51:17 +00:00
# swap window with next or previous
2025-01-17 23:37:58 +00:00
bind-key M-Left swap-window -t -1
bind-key M-Right swap-window -t +1
2025-01-17 09:27:59 +00:00
2025-01-17 11:27:55 +00:00
# create new window with F2
2025-01-17 23:37:58 +00:00
bind-key -n F2 new-window
2025-01-17 11:27:55 +00:00
# previous or next window with Alt & ← | →
2025-01-17 23:37:58 +00:00
bind-key -n M-Left previous-window
bind-key -n M-Right next-window
2025-01-17 09:27:59 +00:00
2025-01-17 13:25:25 +00:00
# select panes with Ctrl & Shift & ←↑↓→
2025-01-17 23:37:58 +00:00
bind-key -n C-S-Down select-pane -D
bind-key -n C-S-Left select-pane -L
bind-key -n C-S-Right select-pane -R
bind-key -n C-S-Up select-pane -U
2025-01-17 09:27:59 +00:00
2025-01-17 12:53:35 +00:00
# horizontal split with H
2025-01-17 23:37:58 +00:00
bind-key h split-window -h
2025-01-17 12:53:35 +00:00
# vertical split with V
2025-01-17 23:37:58 +00:00
bind-key v split-window -v
2025-01-17 09:27:59 +00:00
"
}