Last active
November 18, 2021 10:26
-
-
Save lrivallain/c9286c5223f64370d024fc29e0e7bba2 to your computer and use it in GitHub Desktop.
Tmux configuration file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########### | |
# general # | |
########### | |
# Prefix: CTRL+b | |
set-option -g prefix C-b | |
# 2nd prefix: CTRL+space | |
set-option -g prefix2 C-Space | |
set-window-option -g mode-keys vi | |
set-option -g default-shell /bin/zsh | |
# to prevent ssh from renaming window name | |
set-option -g allow-rename off | |
# disable mouse | |
setw -g mouse off | |
# start window numbering at 1 | |
set -g base-index 1 | |
# Set parent terminal title to reflect current window in tmux session | |
set -g set-titles on | |
set -g set-titles-string '#W - #T' # program name, active(or not) | |
# "#I:#W [#P:#{pane_current_command}]" | |
# automatically renumber windows | |
set -g renumber-windows on | |
# # Keep windows around after they exit | |
# set -g remain-on-exit on | |
############# | |
# shortcuts # | |
############# | |
# clear screen and scroll history by simply pressing Ctrl+K | |
# -n allows it to run without needing of prefix key | |
bind -n C-k send-keys -R \; send-keys C-l \; clear-history | |
# Custom keys to change pane without using prefix | |
bind -n S-Left select-pane -L | |
bind -n S-Right select-pane -R | |
bind -n S-Up select-pane -U | |
bind -n S-Down select-pane -D | |
# NOTE - S-M-<arrow> DOES NOT WORK on tmux 3.2 | |
# bind -n S-M-Left select-pane -L | |
# bind -n S-M-Right select-pane -R | |
# bind -n S-M-Up select-pane -U | |
# bind -n S-M-Down select-pane -D | |
# Remap pane/window splitting to use current pane path | |
bind % split-window -h -c "#{pane_current_path}" | |
bind '"' split-window -c "#{pane_current_path}" | |
bind c new-window -c "#{pane_current_path}" | |
# Additional sane pane splitting shortcut | |
bind | split-window -h -c "#{pane_current_path}" | |
bind - split-window -c "#{pane_current_path}" | |
# M-Enter to zoom pane | |
bind z resize-pane -Z | |
# bind prefix+0 to select last window instead of window 0 | |
bind 0 select-window -t:$ | |
# bind M-(number) to select window without having to use prefix | |
# also bind M-0 to select last window | |
bind -n M-1 select-window -t 1 | |
bind -n M-2 select-window -t 2 | |
bind -n M-3 select-window -t 3 | |
bind -n M-4 select-window -t 4 | |
bind -n M-5 select-window -t 5 | |
bind -n M-6 select-window -t 6 | |
bind -n M-7 select-window -t 7 | |
bind -n M-8 select-window -t 8 | |
bind -n M-9 select-window -t 9 | |
bind -n M-0 select-window -t:$ | |
# Capture pane content and store it into `/tmux.log | |
bind-key S capture-pane -b temp-capture-buffer -S - \; save-buffer -b temp-capture-buffer ~/tmux.log \; delete-buffer -b temp-capture-buffer \; display " Pane content stored at ~/tmux.log" | |
# A key to toggle between smallest and largest sizes if a window is visible in | |
# multiple places | |
bind F set -w window-size | |
# Keys to toggle monitoring activity in a window and the synchronize-panes option | |
bind m set monitor-activity | |
bind y set synchronize-panes\; display 'synchronize-panes #{?synchronize-panes,on,off}' | |
# Toogle mouse usage | |
bind M set mouse\; display 'mouse #{?mouse,on,off}' | |
###### | |
# ui # | |
###### | |
# modes | |
setw -g clock-mode-colour colour5 | |
setw -g mode-style 'fg=colour1 bg=colour18 bold' | |
# panes | |
set -g pane-border-style 'fg=colour244 bg=colour235' | |
set -g pane-active-border-style 'fg=colour77 bg=colour235' | |
set -g pane-border-format ' [#P] <#{pane_current_command}> @ #{pane_current_path} #{?window_zoomed_flag,#[fg=colour228]Z#[fg=colour77] ,}' | |
set -g pane-border-status 'top' | |
# statusbar | |
set -g status-style 'bg=colour234 fg=colour250' | |
set -g status-left '#[fg=colour228,bg=colour234] #S ' # sesion name | |
set -g status-right '#[fg=colour250,bg=colour236] %d %b %H:%M ' # date/clock | |
set -g status-right-length 50 | |
set -g status-left-length 50 | |
set -g status-justify centre | |
setw -g window-status-current-style 'fg=colour1 bg=colour28 bold' | |
setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour250]#F ' | |
setw -g window-status-style 'fg=colour9 bg=colour236' | |
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F ' | |
setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold' | |
setw -g window-status-separator '' | |
# messages | |
set -g message-style 'fg=colour237 bg=colour3 bold' | |
# Ring the bell if any background window rang a bell | |
set -g bell-action any | |
# Watch for activity in background windows | |
setw -g monitor-activity on | |
# If running inside tmux ($TMUX is set), then change the status line to red | |
%if #{TMUX} | |
set -g status-bg red | |
%endif | |
set -g @plugin 'tmux-plugins/tpm' | |
# https://github.com/tmux-plugins/tmux-sensible | |
set -g @plugin 'tmux-plugins/tmux-sensible' | |
# https://github.com/wfxr/tmux-power | |
set -g @plugin 'wfxr/tmux-power' | |
set-option -g @tmux_power_theme 'forest' | |
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) | |
run '~/.tmux/plugins/tpm/tpm' | |
# Press prefix + I (capital i, as in Install) to fetch the plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# An example of a per-user session script | |
session_name=$USER | |
echo "Starting tmux server..." | |
tmux start-server | |
echo "Testing for existing session named ${session_name}..." | |
if ! tmux list-sessions | grep -q "${session_name}\:"; then | |
echo "Creating session ${session_name}..." | |
# create session | |
tmux new-session -d -s $session_name | |
# session content | |
tmux rename-window -t $session_name":1" local1 | |
tmux split-window -t $session_name":1" -v -p 50 | |
tmux new-window -t $session_name":2" -n local2 | |
tmux split-window -t $session_name":2" -v -p 50 | |
# attach to first window | |
tmux select-window -t 1 | |
fi | |
# attach session | |
echo "Attaching to the session ${session_name}..." | |
tmux attach-session -t $session_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment