tmux: Redid config again without external dependencies

This commit is contained in:
Christian Baer 2024-11-05 20:53:10 +01:00
parent 1f6bf9e9c8
commit 87673142e3

View File

@ -1,54 +1,95 @@
# Start a session if none exists
### General Settings
# Enable mouse support in tmux
set -g mouse on
# Set the default terminal type to "tmux-256color" for better color support
set -g default-terminal "tmux-256color"
# Set the base index for windows to 1 (instead of the default 0)
set -g base-index 1
# Set the base index for panes to 1 (instead of the default 0)
setw -g pane-base-index 1
# Increase the history limit (useful for longer command histories)
set-option -g history-limit 10000
### Startup Configuration
# Start a new session named "main" if none exists
new-session -s main
# Start htop and split window
# Start htop and split the window when the session "main" is created
set-hook -t main session-created 'send-keys -t main:0 "sudo htop" C-m; split-window'
# remap prefix from 'C-b' to 'C-a'
### Key Bindings
# Remap the prefix key from 'C-b' (Ctrl-b) to 'C-a' (Ctrl-a)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Use C-b to send prefix twice so it acts on nested session
bind-key -n C-b send-prefix
# split panes using # and -
bind "#" split-window -h
bind "-" split-window -v
# Split panes using 'h' for horizontal and 'v' for vertical splits
bind "h" split-window -h
bind "v" split-window -v
unbind '"'
unbind %
# reload config file
# Reload the tmux configuration file with 'r'
bind r source-file $XDG_CONFIG_HOME/tmux/tmux.conf
# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
### Status and Window Configuration
# Set the status bar update interval to 1 second
set -g status-interval 1
# Options to make tmux more pleasant
set -g mouse on
set -g default-terminal "tmux-256color"
# Enable automatic renaming of windows
set-option -g automatic-rename on
# Ensure and load TPM
if "test ! -d $XDG_CONFIG_HOME/tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm $XDG_CONFIG_HOME/tmux/plugins/tpm && $XDG_CONFIG_HOME/tmux/plugins/tpm/bin/install_plugins'"
# Set window title to the current directory if the process is zsh, otherwise show the process name with arguments
set-option -g automatic-rename-format '#{?#{==:#{pane_current_command},zsh},#{pane_current_path},#(ps --no-headers -o args --ppid $(tmux display-message -p "#{pane_pid}"))}'
run $XDG_CONFIG_HOME/tmux/plugins/tpm/tpm
# Set the color of the clock mode
set -g clock-mode-colour "#8bd5ca"
# Configure the catppuccin plugin
set -g @catppuccin_flavor "macchiato"
set -g @catppuccin_window_status_style "rounded"
# Set the style for copy mode (foreground black, background a specific color, bold text)
set -g mode-style 'fg=black bg=#ed8796 bold'
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'catppuccin/tmux'
# Set the style for pane borders
set -g pane-border-style 'fg=white'
set -g pane-active-border-style 'fg=#8bd5ca'
# Make the status line pretty and add some modules
set -g status-right-length 100
set -g status-left-length 100
set -g status-left ""
set -g status-right "#{E:@catppuccin_status_application}"
# set -agF status-right "#{E:@catppuccin_status_cpu}"
set -ag status-right "#{E:@catppuccin_status_session}"
set -ag status-right "#{E:@catppuccin_status_uptime}"
# set -agF status-right "#{E:@catppuccin_status_battery}"
set -agF status-right "#{@catppuccin_status_host}"
### Status Bar Configuration
# Position the status bar at the bottom
set -g status-position bottom
# Align status bar items to the left
set -g status-justify left
# Set the style for the status bar
set -g status-style 'fg=white,bg=#262626'
# Clear the default left status
set -g status-left ''
# Set the maximum length for the left status
set -g status-left-length 30
## Session name in the status bar
set -ga status-left "#[bg=#444444,fg=white] #S "
# Display different colors for the session name based on whether the prefix is active
set -ga status-left '#{?client_prefix,#[bg=#ed8796] S ,#[bg=#a6da95] S }'
set -ga status-left '#[bg=#262626] '
# Set window status format to include the current directory or command
setw -g window-status-format '#[bg=#8787AF,fg=black] #I #[bg=#585B70,fg=white] #W #F '
# Set the current window status format to include the current directory or command
setw -g window-status-current-format '#[bg=#c6a0f6,fg=black] #I #[bg=#585B70,fg=white] #W #F '
# Set the separator between window statuses
set -g window-status-separator " "
# Status bar right settings (display host information)
set -g status-right "#[fg=black,bg=#7dc4e4] H #[fg=white,bg=brightblack] #H "
# Set the maximum length for the right status
set -g status-right-length 40