rwx/sh/tmux.sh

183 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 '\
2025-01-18 22:05:52 +00:00
#{session_name}\
2025-01-18 22:20:56 +00:00
- \
2025-01-18 22:10:25 +00:00
#{window_index}∕#{session_windows} #{window_name}\
2025-01-18 22:20:56 +00:00
- \
2025-01-18 22:10:25 +00:00
#{pane_index}∕#{window_panes} #{pane_current_command}\
2025-01-18 20:04:26 +00:00
'
2025-01-17 09:27:59 +00:00
2025-01-18 21:27:50 +00:00
# ╭────────┬──────╮
# │ 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 │
# ╰────────┴────────╯
2025-01-18 22:59:56 +00:00
# status lines
set-option -g status 4
2025-01-18 21:27:50 +00:00
# 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
2025-01-18 22:39:55 +00:00
# line 1
2025-01-18 20:10:57 +00:00
set-option -g status-format[0] '\
2025-01-18 22:39:55 +00:00
#[fg=cyan]#{pane_current_path}\
2025-01-18 22:59:56 +00:00
#[align=right] \
2025-01-18 23:24:49 +00:00
#[fg=green]#{session_name}\
2025-01-18 22:39:55 +00:00
'
# line 2
set-option -g status-format[1] '\
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
}\
#[align=right] \
2025-01-18 22:27:15 +00:00
#[fg=yellow]%H:%M:%S\
2025-01-18 20:18:16 +00:00
'
2025-01-18 21:27:50 +00:00
2025-01-18 22:39:55 +00:00
# line 3
set-option -g status-format[2] '\
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 22:20:56 +00:00
\
2025-01-18 22:59:56 +00:00
#{pane_current_command}\
2025-01-18 20:26:17 +00:00
\
2025-01-18 19:15:55 +00:00
}\
#[align=right] \
2025-01-18 22:27:15 +00:00
#[fg=yellow]%Y-%m-%d\
2025-01-18 19:11:16 +00:00
'
2025-01-18 21:27:50 +00:00
2025-01-18 22:59:56 +00:00
# line 4
set-option -g status-format[3] '\
#{P:\
#{?pane_active,#[fg=green],#[fg=default]}\
#{pane_index}\
\
#[fg=blue]#{pane_width}×#{pane_height}\
\
}\
#[align=right] \
#[fg=blue]#{window_width}×#{window_height}\
'
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-18 23:23:07 +00:00
set-option -g status-position bottom
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:38:40 +00:00
# detach client
bind-key -n F6 detach-client
# new window
bind-key -n F2 new-window
# select pane
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
# switch session
2025-01-18 21:27:50 +00:00
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:38:40 +00:00
# switch window
bind-key -n M-Left previous-window
bind-key -n M-Right next-window
2025-01-18 21:27:50 +00:00
# ╭─────┬────────╮
# │ key │ prefix │
# ╰─────┴────────╯
2025-01-18 21:38:40 +00:00
# split window
bind-key h split-window -h
bind-key v split-window -v
2025-01-18 21:27:50 +00:00
# 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-18 21:38:40 +00:00
# swap window
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
"
}