Last active
June 30, 2021 09:35
-
-
Save ejke/52eede8577bbb5bdaaeb931b48008c27 to your computer and use it in GitHub Desktop.
Ubuntu 20.04 tmux config
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
# --- GET tmux | |
# 1. $: brew install tmux | |
# 2. $: tmux | |
# 3. $: touch ~/.tmux.conf | |
# 4. $: tmux source-file ~/.tmux.conf # <- to attach config to that new file | |
# 5. Copy everything below and paste into the ~/.tmux.conf file | |
# --- .tmux.conf content: | |
# Config file for tmux shortcuts. | |
# Some kudos to https://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ | |
# ----------------------------------- | |
# Reload config file and show message | |
# ----------------------------------- | |
bind r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded" | |
# Run that command to activate changes if you don't trust the above | |
# tmux source-file ~/.tmux.conf | |
# --------------------------------------------- | |
# Remap prefix from 'Control-b' to 'Control-z'. | |
# --------------------------------------------- | |
unbind C-b | |
set-option -g prefix C-z | |
bind-key C-z send-prefix | |
# ------------------------- | |
# Split panes using h and v | |
# ------------------------- | |
unbind % | |
bind h split-window -h | |
unbind '"' | |
bind v split-window -v | |
# ------------------------- | |
# Tabs: informative | |
# ------------------------- | |
# add tab: c | |
# rename: , | |
# ------------------------------------------------ | |
# Switch panes using Alt+Arrow keys 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 | |
# ---------------------------------------------------------------- | |
# Enable mouse control (clickable windows, panes, resizable panes) | |
# ---------------------------------------------------------------- | |
set -g mouse on | |
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'" | |
bind -n WheelDownPane select-pane -t= \; send-keys -M | |
bind -n C-WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M | |
bind -T copy-mode-vi C-WheelUpPane send-keys -X halfpage-up | |
bind -T copy-mode-vi C-WheelDownPane send-keys -X halfpage-down | |
bind -T copy-mode-emacs C-WheelUpPane send-keys -X halfpage-up | |
bind -T copy-mode-emacs C-WheelDownPane send-keys -X halfpage-down | |
# To copy, left click and drag to highlight text in yellow, once you release left click yellow text will disappear and will automatically be available in clibboard | |
# Use vim keybindings in copy mode | |
setw -g mode-keys vi | |
# Update default binding of `Enter` to also use copy-pipe | |
unbind -T copy-mode-vi Enter | |
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -selection c" | |
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"; display-message "Selection copied!" | |
# ---------------------------- | |
# Increase scroll-back history | |
# ---------------------------- | |
set -g history-limit 1000000 | |
# ----------------------------------------- | |
# Highlight window when it has new activity | |
# ----------------------------------------- | |
set -g monitor-activity on | |
set -g visual-activity on | |
# -------------- | |
# Set status bar | |
# -------------- | |
set -g status on | |
set -g status-interval 5 | |
set -g status-position top # top, bottom | |
set -g status-justify left # left, centre, right | |
set -g status-style fg=default,bold,bg=default | |
# Display message style | |
set -g message-command-style fg=green,bg=black | |
set -g message-style fg=green,bold,reverse,bg=black | |
# Left status - time, my name | |
set -g status-left-length 70 | |
set -g status-left '#[fg=colour143,dim]🕛 %m-%d %R#(acpi | cut -d ',' -f 2) 💻 #[fg=colour143] #(whoami) |' | |
# Right status - get the current git branch without the star | |
set -g status-right-length 70 | |
set -g status-right '🐙 #(cd #{pane_current_path}; git rev-parse --abbrev-ref HEAD)' | |
# Generic tab style | |
# set -g window-status-separator '|' | |
set -g window-status-separator ' ' | |
set -g window-status-format ' #F#W ' | |
set -g window-status-style fg=magenta,dim,bg=default | |
# Current tab style | |
set -g window-status-current-format '#[default]|🐟 #F#W|' | |
set -g window-status-current-style fg=colour13,bold,bg=colour234 | |
# invalid options commented out: | |
# set -g window-status-current-bg white | |
# set -g window-status-current-fg black | |
# set -g window-status-current-attr bold | |
set -g window-status-activity-style fg=green,bold,bg=black |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment