rwx/sh/tmux.sh

212 lines
4.3 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
2025-01-19 02:15:13 +00:00
set-option -g pane-active-border-style fg=green
2025-01-18 21:27:50 +00:00
# regular style
2025-01-19 18:36:44 +00:00
set-option -g pane-border-style fg=blue
2025-01-18 21:27:50 +00:00
# ╭────────┬────────╮
# │ option │ status │
# ╰────────┴────────╯
2025-01-18 22:59:56 +00:00
# status lines
2025-01-19 18:34:27 +00:00
set-option -g status 5
2025-01-18 22:59:56 +00:00
2025-01-18 21:27:50 +00:00
# background color
2025-01-19 20:47:56 +00:00
set-option -g status-bg '#101010'
2025-01-18 21:27:50 +00:00
# foreground color
2025-01-19 20:47:56 +00:00
set-option -g status-fg white
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-19 17:46:49 +00:00
#[fg=cyan]#{pane_current_path}\
2025-01-19 23:14:14 +00:00
\
2025-01-19 16:39:54 +00:00
#[align=right]\
2025-01-19 22:18:25 +00:00
#[fg=yellow]%H:%M:%S\
2025-01-18 22:39:55 +00:00
'
# line 2
set-option -g status-format[1] '\
2025-01-19 22:58:12 +00:00
#{W:\
2025-01-19 17:37:09 +00:00
\
2025-01-19 23:23:18 +00:00
#[fg=yellow]#{window_index}\
2025-01-19 17:37:09 +00:00
\
2025-01-19 23:23:18 +00:00
#{?window_active,#[fg=green],\
#{?window_activity_flag,#[fg=red],#[fg=blue]}}\
2025-01-19 22:58:12 +00:00
#{window_name}\
2025-01-19 17:37:09 +00:00
\
2025-01-18 19:15:55 +00:00
}\
2025-01-19 16:20:05 +00:00
#[align=right]\
2025-01-20 11:09:42 +00:00
#[fg=yellow]%Y-%m-%d\
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-20 10:44:52 +00:00
#{S:\
2025-01-19 17:37:09 +00:00
\
2025-01-20 10:44:52 +00:00
#[fg=yellow]#{s/\\\$//:session_id}\
2025-01-18 22:20:56 +00:00
\
2025-01-20 11:17:42 +00:00
#{?session_many_attached,#[fg=red],\
2025-01-20 11:30:11 +00:00
#{?session_attached,#[fg=cyan],#[fg=blue]}}\
2025-01-20 10:44:52 +00:00
#{session_name}\
2025-01-19 17:37:09 +00:00
\
2025-01-18 19:15:55 +00:00
}\
2025-01-19 16:20:05 +00:00
#[align=right]\
2025-01-20 11:30:11 +00:00
#[fg=yellow]#{s/\\\$//:session_id}\
\
2025-01-20 11:09:42 +00:00
#[fg=green]#{session_name}\
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] '\
2025-01-19 18:34:27 +00:00
#{P:\
2025-01-19 18:15:42 +00:00
\
2025-01-19 23:23:18 +00:00
#[fg=yellow]#{pane_index}\
2025-01-19 18:34:27 +00:00
\
2025-01-19 23:23:18 +00:00
#{?pane_active,#[fg=green],#[fg=blue]}\
2025-01-20 10:44:52 +00:00
#{pane_current_command}\
2025-01-19 18:34:27 +00:00
\
}\
2025-01-19 15:55:58 +00:00
#[align=right]\
2025-01-20 11:11:45 +00:00
#[fg=yellow]#{host_short}\
2025-01-19 12:32:45 +00:00
'
2025-01-19 23:04:36 +00:00
# line 5
set-option -g status-format[4] '\
2025-01-20 10:44:52 +00:00
#{P:\
2025-01-20 10:39:43 +00:00
\
2025-01-20 10:44:52 +00:00
#[fg=yellow]#{pane_index}\
2025-01-20 10:39:43 +00:00
\
2025-01-20 10:44:52 +00:00
#{?pane_active,#[fg=green],#[fg=blue]}\
#{pane_width}×#{pane_height}\
2025-01-20 10:39:43 +00:00
\
}\
2025-01-19 23:10:19 +00:00
#[align=right]\
2025-01-20 10:44:52 +00:00
#[fg=blue] #{window_width}×#{window_height}\
2025-01-19 23:04:36 +00:00
'
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
2025-01-18 23:50:00 +00:00
# status lines
2025-01-19 12:33:56 +00:00
bind-key -n C-F10 set-option -g status off
2025-01-19 01:21:05 +00:00
bind-key -n C-F1 set-option -g status on
bind-key -n C-F2 set-option -g status 2
bind-key -n C-F3 set-option -g status 3
bind-key -n C-F4 set-option -g status 4
2025-01-19 12:32:45 +00:00
bind-key -n C-F5 set-option -g status 5
2025-01-18 23:50:00 +00:00
2025-01-18 21:38:40 +00:00
# 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
"
}