Created
June 9, 2021 10:26
-
-
Save Nielius/55e5d1cd77185015570b940c57860c4e to your computer and use it in GitHub Desktop.
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
# My tmux config | |
# | |
# reload with `tmux source ~/.tmux.conf` | |
# | |
# | |
# Info on tmux | |
# | |
# There are three kinds of options: server options, session options and window options. | |
# For session and window options, there are global options (that apply by default) | |
# and individual options, that can be set for a session/window individually. | |
# | |
# `set-option -s' sets global options, which do not apply to any particular window or sessions | |
# `set-window-opiont` | |
# `set-option` sets session options; there is a separate set of global session options | |
# set is an alias for `set-option' | |
# `setw' is an alias for `set-window-option' | |
# The flag `-g' sets global options. | |
# The flag `-a' appends options: `set -g status-left "foo"' followed by `set -ag status-left "bar"' will result in `foobar'. | |
# taken from https://sanctum.geek.nz/arabesque/vi-mode-in-tmux/ | |
set-window-option -g mode-keys vi | |
bind-key -T copy-mode-vi 'v' send -X begin-selection | |
# bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel | |
# This works better on Linux systems: | |
# See e.g. https://unix.stackexchange.com/questions/131011/use-system-clipboard-in-vi-copy-mode-in-tmux | |
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' | |
# the rest is taken from (and slightly adapted) https://gist.github.com/tsl0922/d79fc1f8097dde660b34 | |
# Without this, in vim, there is a delay between pressing <Esc> and actually exiting insert mode. | |
# See https://stackoverflow.com/questions/13021196/how-do-i-get-vim-to-recognize-esc-key-faster | |
set -s escape-time 0 | |
# mouse behavior | |
setw -g mouse on | |
# This enables 24-bit color (i.e., the full 8x8x8 spectrum) | |
# Source: https://wiki.archlinux.org/index.php/Tmux#256_colors | |
# I don't quite understand how it works, and it seems to depend on the terminal you are running tmux in. | |
# This is what seems to work with both Konsole and Termite: | |
set-option -sa terminal-overrides ',XXX:RGB' | |
# set -ga terminal-overrides ",xterm-256color:Tc" # --- this is what I had before, but deoplete says that this is only for older versions of tmux | |
# This is what Archwiki recommended for termite (but it doens't seem to work with Konsole): | |
# set -ga terminal-overrides ",xterm-termite:Tc" | |
bind-key : command-prompt | |
bind-key r refresh-client | |
bind-key L clear-history | |
# bind-key space next-window | |
bind-key bspace previous-window | |
bind-key enter next-layout | |
# use vim-like keys for splits and windows | |
bind-key v split-window -h -c "#{pane_current_path}" | |
bind-key s split-window -v -c "#{pane_current_path}" | |
bind-key h select-pane -L | |
bind-key j select-pane -D | |
bind-key k select-pane -U | |
bind-key l select-pane -R | |
# bind-key Tab last-window | |
bind-key space last-window | |
# NUDB: open split window with a new note | |
bind-key C split-window -h "export EDITOR=vim; source ~/.bash/md-agenda-bash/md-agenda-functions.sh; createnote" | |
# smart pane switching with awareness of vim splits: | |
# What this does: | |
# if you're in vim, just send C-h/j/k/l to vim | |
# if you're not in vim, go to one of the other panes | |
# | |
# Technical details: | |
# the `-n' option should be for "use root key-table" (i.e., not with the prefix key) | |
# by default, you use the prefix key-table. | |
# you can set the current key table with `switch-client -Tnewkeytable` | |
# bind-key -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-h) || tmux select-pane -L" | |
# bind-key -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-j) || tmux select-pane -D" | |
# bind-key -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-k) || tmux select-pane -U" | |
# bind-key -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-l) || tmux select-pane -R" | |
# bind-key -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys 'C-\\') || tmux select-pane -l" | |
# Configure main-horizontal and main-vertical layouts | |
bind-key + select-layout main-horizontal # this changes the layout | |
bind-key = select-layout main-vertical | |
set-window-option -g other-pane-height 25 # sets height of the other panes in main-horizontal layout | |
set-window-option -g other-pane-width 80 # sets width of the other panes in main-vertical layout | |
bind-key a last-pane | |
bind-key q display-panes # useful! puts numbers in the panes and you can use the number to go to that pane | |
bind-key c new-window -c "#{pane_current_path}" | |
bind-key t next-window | |
bind-key T previous-window | |
bind-key [ copy-mode | |
bind-key ] paste-buffer | |
set-window-option -g display-panes-time 1500 | |
# Status Bar | |
set-option -g status-interval 1 | |
set-option -g status-left '' | |
set-option -g status-right '%l:%M%p' | |
set-window-option -g window-status-current-style "fg=magenta" | |
set-option -g status-fg default | |
# Status Bar solarized-dark (default) | |
set-option -ag status-style "bg=black" | |
set-option -ag pane-active-border-style "fg=yellow" | |
set-option -ag pane-border-style "fg=cyan" | |
# Status Bar solarized-light | |
if-shell "[ \"$COLORFGBG\" = \"11;15\" ]" "set-option -g status-style \"bg=white\"" | |
if-shell "[ \"$COLORFGBG\" = \"11;15\" ]" "set-option -g pane-active-border-style \"fg=white\"" | |
if-shell "[ \"$COLORFGBG\" = \"11;15\" ]" "set-option -g pane-border-style \"fg=white\"" | |
# Set window notifications | |
setw -g monitor-activity on | |
set -g visual-activity on | |
# Allow the arrow key to be used immediately after changing windows | |
set-option -g repeat-time 0 | |
# Tmux Plugin Manager | |
# ------------------- | |
# | |
# Source: https://github.com/tmux-plugins/tpm | |
# | |
# Installation instructions (besides this configuration file): | |
# | |
# Run | |
# git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm | |
# and restart tmux or use `tmux source ~/.tmux.conf'. | |
# | |
# Install plugins: add plugin in config as below; and press `prefix + I` (which fetches and sources the plugin) | |
# NB: this is a capital I! So shift is necessary. | |
# List of plugins | |
set -g @plugin 'tmux-plugins/tpm' | |
set -g @plugin 'tmux-plugins/tmux-sensible' | |
set -g @plugin 'jbnicolai/tmux-fpp' # Facebook PathPicker; use `prefix + f' to use within tmux | |
# bind-key / find-window # this is overwritten by Facebook PathPicker, but seems useful | |
# Saving and restoring current session (prefix + C-s : save, prefix + C-r : restore) | |
set -g @plugin 'tmux-plugins/tmux-resurrect' | |
set -g @plugin 'tmux-plugins/tmux-continuum' | |
# Automatic restore on tmux start | |
set -g @continuum-restore 'on' | |
# FZF buffer copy paste | |
# Triggered by prefix-tab | |
# https://github.com/laktak/extrakto | |
set -g @plugin 'laktak/extrakto' | |
# Other examples: | |
# set -g @plugin 'github_username/plugin_name' | |
# set -g @plugin 'git@github.com/user/plugin' | |
# set -g @plugin 'git@bitbucket.com/user/plugin' | |
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) | |
run -b '~/.tmux/plugins/tpm/tpm' | |
# It seems this has to be at the end of the configuration... | |
# Enable native Mac OS X copy/paste | |
set-option -g default-command "/bin/bash -c 'which reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace $SHELL -l || exec $SHELL -l'" | |
set-option -g default-shell /bin/bash | |
set-option -g default-command /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment