Files
AstroVim_Config/.config/.tmux.conf
2025-02-20 20:52:06 +07:00

270 lines
10 KiB
Bash

# Terminal colors
set -g default-terminal "tmux-256color"
set -sag terminal-features ",*:RGB"
set -sag terminal-features ",*:usstyle"
# set-option -g focus-events on
# -- general -------------------------------------------------------------------
# Activity
# set -g monitor-activity on
# set -g visual-activity on
# set -g monitor-activity off
# set -g bell-action none
# set -g visual-bell off
# Status
set -g status-interval 1
set -sg escape-time 10
set -g repeat-time 500
set -g display-time 1500
set -g history-limit 5000 # boost history
set -g mouse on
set -g xterm-keys on
bind-key -T copy-mode-vi 'v' send -X begin-selection # start selecting text with "v"
bind-key -T copy-mode-vi 'y' send -X copy-selection # copy text with "y"
unbind -T copy-mode-vi MouseDragEnd1Pane # don't exit copy mode when dragging with mouse
# choose tree format
set -g @custom_choose_tree_format "\
#{?pane_format,\
#{?pane_marked,#[bg=#{@thm_surface_1}],}\
#[fg=#{@thm_green}]  #{session_name} \
#{E:#{@custom_separator}}#[fg=#{@thm_maroon}]  #{pane_current_command} \
#{E:#{@custom_separator}}#[fg=#{@thm_blue}]  #{pane_current_path} \
#{?window_zoomed_flag,#{?pane_active,#{E:#{@custom_separator}}#[fg=#{@thm_yellow}]  zoom ,},}\
#{?pane_marked,#{E:#{@custom_separator}}#[fg=#{@thm_yellow}]  marked ,}\
#{?pane_active,#{E:#{@custom_separator}}#[fg=#{@thm_yellow}]  active ,}\
,}\
#{?window_format,\
#{?window_marked_flag,#[bg=#{@thm_surface_1}],}\
#{?window_active,#{#[fg=#{@thm_peach},reverse]},\
#{?window_last_flag,#[fg=#{@thm_peach}],#[fg=#{@thm_rosewater}]}\
}\
 #I #{window_name} \
#{#[fg=#{@thm_rosewater},none]}\
#{?#{==:#{window_panes},1},\
#[fg=#{@thm_green}]  #{session_name} \
#{E:#{@custom_separator}}#[fg=#{@thm_maroon}]  #{pane_current_command} \
#{E:#{@custom_separator}}#[fg=#{@thm_blue}]  #{pane_current_path} \
#{?window_marked_flag,#{E:#{@custom_separator}}#[fg=#{@thm_yellow}]  marked ,}\
,}\
,}\
#{?session_format,\
#{session_windows} windows\
#{?session_grouped, (group #{session_group}: #{session_group_list}),}\
#{?session_attached, (attached),}\
,}
"
# Windows
bind-key -T copy-mode-vi 'v' send -X begin-selection # start selecting text with "v"
bind-key -T copy-mode-vi 'y' send -X copy-selection # copy text with "y"
# Panes
bind -r h select-pane -L # move left
bind -r j select-pane -D # move down
bind -r k select-pane -U # move up
bind -r l select-pane -R # move right
# pane resizing
bind -r H resize-pane -L 2
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r L resize-pane -R 2
# bind -r \} swap-pane -D
# bind -r \{ swap-pane -U
# bind -r space select-layout -n
bind V split-window -h -c "#{pane_current_path}"
bind v split-window -v -c "#{pane_current_path}"
# bind j choose-tree -F "#{E:@custom_choose_tree_format}" -Z "join-pane -h -s "%%""
# bind J choose-tree -F "#{E:@custom_choose_tree_format}" -Z "join-pane -v -s "%%""
bind w choose-tree -F "#{E:@custom_choose_tree_format}" -Z "select-window -t "%%""
# find session
bind C-f command-prompt -p find-session 'switch-client -t %%'
# maximize current pane
# bind + run "cut -c3- '#{TMUX_CONF}' | sh -s _maximize_pane '#{session_name}' '#D'"
# window navigation
unbind n
unbind p
unbind C-l
bind -r h previous-window # select previous window
bind -r l next-window
bind Tab last-window # move to last active window
# -- copy mode -----------------------------------------------------------------
bind Enter copy-mode # enter copy mode
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi C-v send -X rectangle-toggle
bind -T copy-mode-vi y send -X copy-selection-and-cancel
bind -T copy-mode-vi Escape send -X cancel
bind -T copy-mode-vi H send -X start-of-line
bind -T copy-mode-vi L send -X end-of-line
# reload config file
bind r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'catppuccin/tmux'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'tmux-plugins/tmux-resurrect' # persist tmux sessions after computer restart
set -g @plugin 'tmux-plugins/tmux-continuum' # automatically saves sessions for you every 15 minutes
# Configure Catppuccin
set -g @catppuccin_flavor "macchiato"
set -g @catppuccin_status_background "none" # none == default
set -g @catppuccin_pane_status_enabled "off"
set -g @catppuccin_pane_border_status "off"
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'
set-window-option -g mode-keys vi
# Configure battery
# set -g @batt_icon_charge_tier8 ''
# set -g @batt_icon_charge_tier7 ''
# set -g @batt_icon_charge_tier6 ''
# set -g @batt_icon_charge_tier5 ''
# set -g @batt_icon_charge_tier4 ''
# set -g @batt_icon_charge_tier3 ''
# set -g @batt_icon_charge_tier2 ''
# set -g @batt_icon_charge_tier1 ''
# set -g @batt_icon_status_charged ''
# set -g @batt_icon_status_charging ''
# set -g @batt_icon_status_discharging ''
# set -g @batt_icon_status_attached ''
# set -g @batt_icon_status_unknown ''
# Configure Cpu
set -g @cpu_percentage_format "%03d%%"
# Configure Mem
set -g @ram_percentage_format "%03d%%"
# status left look and feel
set -g status-left-length 80
set -g status-left ""
# status right look and feel
set -g status-right-length 160
set -g status-right ""
# custom var
set -g @custom_separator "#[fg=#{@thm_overlay_0},none]|"
# session
set -ga status-right "#[fg=#{@thm_green},bg=default]"
set -ga status-right "#{?client_prefix,#[#{fg=#{@thm_green}}]#[reverse]#[bold],}"
set -ga status-right " #{?#{e|>:#{window_width},90}, #S,} "
set -ga status-right "#{?client_prefix,#[none],}"
set -ga status-right "#{E:#{@custom_separator}}"
# application
set -ga status-right "#[fg=#{@thm_maroon},bg=default]"
set -ga status-right " #{?#{e|>:#{window_width},80}, #{pane_current_command},} "
set -ga status-right "#{E:#{@custom_separator}}"
# directory
set -ga status-right "#[fg=#{@thm_blue},bg=default]"
set -ga status-right " #{?#{e|>:#{window_width},80}, #{=/24/...:#{b:pane_current_path}},} "
set -ga status-right "#{E:#{@custom_separator}}"
# window zoom flag
set -ga status-right "#{?window_zoomed_flag,"
set -ga status-right "#[fg=#{@thm_yellow}]#[bg=default]"
set -ga status-right " #{?#{e|>:#{window_width},110}, zoom,} "
set -ga status-right "#{E:#{@custom_separator}}"
set -ga status-right ",}"
# pane marked flag
set -ga status-right "#{?pane_marked,"
set -ga status-right "#[fg=#{@thm_yellow}]#[bg=default]"
set -ga status-right " #{?#{e|>:#{window_width},110}, marked,} "
set -ga status-right "#{E:#{@custom_separator}}"
set -ga status-right ",}"
# cpu
# set -ga status-right "#[fg=#{@thm_teal},bg=default]"
# set -ga status-right " #{?#{e|>:#{window_width},115}, #{cpu_percentage},} "
# set -ga status-right "#{E:#{@custom_separator}}"
# ram
# set -ga status-right "#[fg=#{@thm_sky},bg=default]"
# set -ga status-right " #{?#{e|>:#{window_width},115}, #{ram_percentage},} "
# set -ga status-right "#{E:#{@custom_separator}}"
# battery
# set -ga status-right "#[fg=#{@thm_pink},bg=default]"
# set -ga status-right "#{?#{e|>:#{window_width},105},"
# set -ga status-right " #{?#{battery_percentage},#{battery_icon} #{battery_percentage},#{@batt_icon_status_charged} cable} "
# set -ga status-right ","
# set -ga status-right " #{?#{battery_percentage},#{battery_icon},#{@batt_icon_status_charged}} "
# set -ga status-right "}"
# set -ga status-right "#{E:#{@custom_separator}}"
# date
set -ga status-right "#[fg=#{@thm_lavender},bg=default]"
set -ga status-right " #{?#{e|>:#{window_width},95}, %Y-%m-%d,} "
set -ga status-right "#{E:#{@custom_separator}}"
# time
# set -ga status-right "#[fg=#{@thm_fg},bg=default]"
# set -ga status-right " #{?#{e|>:#{window_width},85}, %H:%M,} "
# bootstrap tpm
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# Configure Tmux
set -g status 2
set -g status-position top
set -g status-style "bg=#{@thm_mantle}"
set -g status-justify "left"
set -gF status-format[1] "#[fg=#{@thm_surface_2},bg=#{@thm_bg}]\
───────────────────────────────────────────────────────────────────────────────\
───────────────────────────────────────────────────────────────────────────────\
───────────────────────────────────────────────────────────────────────────────\
───────────────────────────────────────────────────────────────────────────────\
───────────────────────────────────────────────────────────────────────────────\
───────────────────────────────────────────────────────────────────────────────\
"
# pane border look and feel
setw -g pane-border-status off
setw -g pane-border-format ""
setw -g pane-active-border-style "bg=default,fg=#{@thm_peach}"
setw -g pane-border-style "bg=default,fg=#{@thm_overlay_1}"
setw -g pane-border-lines single
# window look and feel
set -gF window-status-separator "#[fg=#{@thm_overlay_0}]"
set -wg automatic-rename on
set -g automatic-rename-format "window"
set -g window-status-format " #{?#{==:#{window_name},window},#I,#W} "
set -g window-status-style "fg=#{@thm_rosewater},bg=default"
set -g window-status-last-style "fg=#{@thm_peach}"
set -g window-status-activity-style "fg=#{@thm_red},bold"
set -g window-status-bell-style "fg=#{@thm_red},bold"
set -g window-status-current-format " #{?#{==:#{window_name},window},#I,#W} "
set -g window-status-current-style "fg=#{@thm_peach},bold,reverse"
# show startup screen
# hook to run fastfetch on session jreation
# set-hook -g after-new-session 'send-keys " clear && fastfetch" C-m'