Skip to content

Instantly share code, notes, and snippets.

@FilBot3
Last active December 12, 2022 15:32
Show Gist options
  • Save FilBot3/c02bc59937e2873e41de21f53c667302 to your computer and use it in GitHub Desktop.
Save FilBot3/c02bc59937e2873e41de21f53c667302 to your computer and use it in GitHub Desktop.
tmux Start-up script and Configuration

tmux startup and config

Overview

#!/usr/bin/env bash
# This requires that you have Vim or NeoVim installed to work. Otherwise change
# this to use Nano or Emacs instead.
set -x
set -e
# Create a new tmux session by issuing a command then detaching from that session.
# The Session is named AzDO. The Window is named Vim.
/usr/bin/tmux new-session -d -s AzDO -n Vim nvim .
# Now we'll create a new-window in the session AzDO and name the new window Console
# This by default creates a new terminal.
/usr/bin/tmux new-window -t AzDO -n Console
# Now we'll set the active window back to AzDO's first window
/usr/bin/tmux select-window -t AzDO:1
# After all that setup, we connect back to our detached tmux session named AzDO.
/usr/bin/tmux attach -t AzDO
# ~/.tmux.conf
# Phillip tmux Configuration
# Change the prefix key to C-a
set-option -g prefix C-a
# Remove the <C-b> binding.
unbind-key C-b
# This sends the <C-a> combo after doing <C-a> + <C-a>
bind-key C-a send-prefix
# Set the delay betweeen prefix and command
set-option -g base-index 1
set-option -s escape-time 1
# Start window count at 1 instead of 0
set-window-option -g pane-base-index 1
# Some extra key bind-keyings to select higher numbered windows
bind-key F1 select-window -t:10
bind-key F2 select-window -t:11
bind-key F3 select-window -t:12
bind-key F4 select-window -t:13
bind-key F5 select-window -t:14
bind-key F6 select-window -t:15
bind-key F7 select-window -t:16
bind-key F8 select-window -t:17
bind-key F9 select-window -t:18
bind-key F10 select-window -t:19
bind-key F11 select-window -t:20
bind-key F12 select-window -t:21
# Reload tmux Config. PREFIX + r
bind-key r source-file ~/.tmux.conf \; display "Reloaded config!"
# Stack panes horizontally
bind-key | split-window -h
# Stack panes vertically
bind-key - split-window -v
# Using Vim h,j,k,l movement
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# Cycle through windows, left
bind-key -r C-h select-window -t:-
# Cycle through windows, right
bind-key -r C-l select-window -t:+
# Resize panes, repeatedly, Left
bind-key -r H resize-pane -L 5
# Resize panes, repeatedly, Down
bind-key -r J resize-pane -D 5
# Resize panes, repeatedly, Up
bind-key -r K resize-pane -U 5
# Resize panes, repeatedly, Right
bind-key -r L resize-pane -R 5
# Turn off the mouse. Do this the right way you C.H.U.D.
set-option -g mouse off
# Set our default terminal so it uses all colors.
#set-option -g default-terminal "tmux-256color"
set-option -g default-terminal "xterm-256color"
# Set our status-bar colors
set-option -g status-style fg=white,bg=black
# Set the window list color
set-window-option -g window-status-style fg=cyan,bg=black
# Set the active window to be highlighted.
set-window-option -g window-status-current-style underscore,fg=white,bold,bg=black
# Set the border style for panes in a window
set-window-option -g pane-border-style fg=green,bg=black
# Set active pane border
set-window-option -g pane-active-border-style fg=white,bg=yellow
# Set unfocused panes to darker colors
set-window-option -g window-style fg=colour240,bg=colour235
# Set the focused pane to brighter colors
set-window-option -g window-active-style fg=white,bg=black
# Set tmux command-line message style
set-option -g message-style fg=white,bold,bg=black
# Center the Window List
set-option -g status-justify centre
# Blink on activity in a window
set-window-option -g monitor-activity on
set-option -g visual-activity on
# Set Vi movement during copy-mode
## This allows you to navigate using h,j,k,l and use the vi bindings listed in
## the tmux man page.
set-window-option -g mode-keys vi
# These next few options will require xclip or xselect(?) to be available on the
# system. Need to test with Wayland or XWayland. There may be a Wayland module
# already.
# Enter Copy Mode, then press PREFIX + <C-c> to copy the current buffer to
# xclip. This saves the WHOLE BUFFER.
bind-key C-c run "tmux save-buffer -a | xclip -i -sel clipboard > /dev/null"
# Enter Copy Mode, select the desired text, then press y to copy to the paste
# buffer in xclip.
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -sel clip -i"
# To paste, just do PREFIX then <C-v>. It will dump xclip into the buffer.
bind-key C-v run "tmux set-buffer \"$(xclip -sel clip -o)\"; tmux paste-buffer"
# This is makes tmux follow the parent terminal's transparency. I don't know why.
set-option -g status-style bg=default
set-option -g window-style bg=default
set-option -g window-active-style bg=default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment