Skip to content

Commit

Permalink
updated tmux.conf to work with Ubuntu, added in guicolors so that tmu…
Browse files Browse the repository at this point in the history
…x doesn't mess up my highlights when using it
  • Loading branch information
darkskittlz committed Sep 17, 2024
1 parent 5066cb0 commit e6e3c8f
Show file tree
Hide file tree
Showing 3 changed files with 337 additions and 334 deletions.
300 changes: 171 additions & 129 deletions tmux.conf
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
unbind r
set -sg escape-time 10
set -gq allow-passthrough on
set -g mouse on
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-strategy-vim 'session'
set-option -sa terminal-features 'xterm-kitty'
# Set prefix
set -g prefix C-Space
unbind C-b
bind C-Space send-prefix
unbind r
bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!"

set -sa terminal-overrides ",xterm*:Tc"
set -g terminal-overrides 'xterm*:Tc'
set -g default-terminal "xterm-256color"

# Set the prefix to `ctrl + space` instead of `ctrl + b`
unbind C-b
set -g prefix C-Space
bind-key C-Space send-prefix

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?\.?(view|n?vim?x?)(-wrapped)?(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
set -sa terminal-overrides ".xterm*:Tc"
set -g mouse on

bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
bind-key -n M-H previous-window
bind-key -n M-L next-window

# Binds backtick character to switch to marked pane with prefix + m
bind \` switch-client -t'{marked}'

# Better split pane keybindings
bind-key '\' split-window -h
Expand All @@ -39,128 +25,184 @@ bind-key "_" split-window -fv -c "#{pane_current_path}"
unbind '"'
unbind %

bind-key -n M-H previous-window
bind-key -n M-L next-window

#swap windows around
bind -r "<" swap-window -d -t -1
bind -r ">" swap-window -d -t +1

# Set window and panes at 1, not 0
set -g base-index 1
set -g pane-base-index 1
set-window-option -g renumber-windows on

# Keep current path in newly created windows
bind c new-window -c "#{pane_current_path}"

# Pane Resizing: Prefix + Ctrl-h/j/k/l
bind -r C-j resize-pane -D 5
bind -r C-k resize-pane -U 5
bind -r C-h resize-pane -L 5
bind -r C-l resize-pane -R 5


#swap windows around
bind -r "<" swap-window -d -t -1
bind -r ">" swap-window -d -t +1


# Move selected text up and down with alt-j/k
unbind C-b
set -g prefix C-Space
bind-key C-Space send-prefix

# Tmux Bar Position
set-option -g status-position bottom
# Open panes in current directory
bind-key '"' split-window -v -c "#{pane_current_path}"
bind-key % split-window -h -c "#{pane_current_path}"

# act like vim
setw -g mode-keys vi
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R

# Setup 'y' to yank (copy), just like Vim
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi 'V' send -X select-line
bind-key -T copy-mode-vi 'r' send -X rectangle-toggle

#############################
########## Settings
#############################

bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' }
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' }
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' }
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' }
bind-key b set-option status

bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -L'
bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -D'
bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -U'
bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -R'

is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'resize-pane -L 1'
bind -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'resize-pane -D 1'
bind -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'resize-pane -U 1'
bind -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'resize-pane -R 1'

bind-key -T copy-mode-vi M-h resize-pane -L 1
bind-key -T copy-mode-vi M-j resize-pane -D 1
bind-key -T copy-mode-vi M-k resize-pane -U 1
bind-key -T copy-mode-vi M-l resize-pane -R 1
bind '"' split-window -v -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!"

# Plugins
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'catppuccin/tmux'
set -g @plugin 'niksingh710/minimal-tmux-status'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'jimeh/tmuxifier'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'


## Minimal Tmux Status

set -g @minimal-tmux-status-right " "
set -g @minimal-tmux-status-right-extra "🌲🌲🌲"
set -g @minimal-tmux-indicator-str "👻👾🤖"
set -g @minimal-tmux-expanded-icon " 󰊓 "
set -g @minimal-tmux-show-expanded-icons-for-all-tabs true
set -g @minimal-tmux-bg "#29a298"
bind-key b set-option status

# Focus events on
set-option -g focus-events on

# set vi-mode
set-window-option -g mode-keys vi
# Refresh status line every 5 seconds - Good for when music is playing / update time etc
set -g status-interval 5


# keybindings
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel


# start windows at 1
# Start window and pane indices at 1.
set -g base-index 1
setw -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows 1


# navigation
set -g @tmux-nvim-navigation true
set -g @tmux-nvim-navigation-cycle true
set -g @tmux-nvim-navigation-keybinding-left 'C-h'
set -g @tmux-nvim-navigation-keybinding-down 'C-j'
set -g @tmux-nvim-navigation-keybinding-up 'C-k'
set -g @tmux-nvim-navigation-keybinding-right 'C-l'


# resize
set -g @tmux-nvim-resize true
set -g @tmux-nvim-resize-step-x 1
set -g @tmux-nvim-resize-step-y 1
set -g @tmux-nvim-resize-keybinding-left 'M-h'
set -g @tmux-nvim-resize-keybinding-down 'M-j'
set -g @tmux-nvim-resize-keybinding-up 'M-k'
set -g @tmux-nvim-resize-keybinding-right 'M-l'


# Undercurl
set -g default-terminal "${TERM}"
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm' # undercurl support
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' # underscore colours - needs tmux-3.0
set -g pane-base-index 0

# Length of tmux status line
set -g status-left-length 30
set -g status-right-length 150

set-option -g status "on"

# Default statusbar color
set-option -g status-style bg=colour16,fg=colour255 # bg=bg1, fg=fg1

# Default window title colors
set-window-option -g window-status-style bg=colour214,fg=colour16 # bg=yellow, fg=bg1

# Default window with an activity alert
set-window-option -g window-status-activity-style bg=colour117,fg=colour255 # bg=bg1, fg=fg3

# Active window title colors
set-window-option -g window-status-current-style bg=red,fg=colour237 # fg=bg1

# Set active pane border color
set-option -g pane-active-border-style fg=colour214

# Set inactive pane border color
set-option -g pane-border-style fg=colour255

# Message info
set-option -g message-style bg=colour16,fg=colour207 # bg=bg2, fg=fg1

# Writing commands inactive
set-option -g message-command-style bg=colour239,fg=colour223 # bg=fg3, fg=bg1

# Pane number display
set-option -g display-panes-active-colour colour1 #fg2
set-option -g display-panes-colour colour255 #bg1

# Clock
set-window-option -g clock-mode-colour colour109

# Bell
set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg

set-option -g status-left "\
#[fg=colour7, bg=colour241]#{?client_prefix,#[bg=colour167],} ❐ #S \
#[fg=colour241, bg=colour16]#{?client_prefix,#[fg=colour167],}#{?window_zoomed_flag, 🔍,}"

set-option -g status-right "\
#[fg=colour27, bg=colour16] \
#[fg=colour16, bg=colour27] #(~/dotfiles/tmux/scripts/music.sh) \
#[fg=colour223, bg=colour16] #(~/dotfiles/tmux/scripts/uptime.sh) \
#[fg=colour246, bg=colour16]  %b %d '%y\
#[fg=colour109]  %H:%M \
#[fg=colour248, bg=colour239]"

set-window-option -g window-status-current-format "\
#[fg=colour16, bg=colour27]\
#[fg=colour255, bg=colour27] #I* \
#[fg=colour255, bg=colour27, bold] #W \
#[fg=colour27, bg=colour16]"

set-window-option -g window-status-format "\
#[fg=colour16,bg=colour239,noitalics]\
#[fg=colour255,bg=colour239] #I \
#[fg=colour255, bg=colour239] #W \
#[fg=colour239, bg=colour16]"

# Set the history limit so we get lots of scrollback.
setw -g history-limit 50000000

#############################
############# Tmux Vars
#############################

# $(echo $USER) - shows the current username
# %a --> Day of week (Mon)
# %A --> Day of week Expanded (Monday)

# %b --> Month (Jan)
# %d --> Day (31)
# %Y --> Year (2017)

# %D --> Month/Day/Year (12/31/2017)
# %v --> Day-Month-Year (31-Dec-2017)

# %r --> Hour:Min:Sec AM/PM (12:30:27 PM)
# %T --> 24 Hour:Min:Sec (16:30:27)
# %X --> Hour:Min:Sec (12:30:27)
# %R --> 24 Hour:Min (16:30)
# %H --> 24 Hour (16)
# %l --> Hour (12)
# %M --> Mins (30)
# %S --> Seconds (09)
# %p --> AM/PM (AM)

# For a more complete list view: https://linux.die.net/man/3/strftime

#colour0 (black)
#colour1 (red)
#colour2 (green)
#colour3 (yellow)
#colour4 (blue)
#colour7 (white)
#colour5 colour6 colour7 colour8 colour9 colour10 colour11 colour12 colour13 colour14 colour15 colour52 colour17

#D ()
#F ()
#H (hostname)
#I (window index)
#P ()
#S (session index)
#T (pane title)
#W (currnet task like vim if editing a file in vim or zsh if running zsh)

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"

run '/home/darkskittlz/.config/tmux/.tmux/plugins/tpm/tpm'
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
Loading

0 comments on commit e6e3c8f

Please sign in to comment.