# Options {{{1
# Server {{{2
# Don't pile up more than 10 buffers (down from 50 by default).{{{
#
# Rationale: Keeping a tidy stack, with relevant information, could help us
# integrate tmux buffers in our workflow more often.
#
# However, maybe we could keep a big stack of buffers, and filter them by
# pressing `f` in the window opened by `choose-buffer`.
# Alternatively, we could also try to use fzf to fuzzy search through their
# contents...
#}}}
set -s buffer-limit 10
# What does this option control?{{{
#
# It sets the time in milliseconds for which tmux waits after an escape is input
# to determine if it is part of a function or meta key sequences.
# The default is 500 millisec onds.
#}}}
# Why do you reset it?{{{
#
# The default value introduces lag when we use Vim and escape from insert to
# normal mode. We want to reduce the timeout.
#}}}
# Why don't you set it to 0 ?{{{
#
# > Some people set it to zero but I consider that risky if you're connecting
# > over a wide-area network or there is anything else that might insert small
# > delays between the delivery of chars in such a sequence.
#
# Source: https://github.com/tmux/tmux/issues/353#issuecomment-294570322
#
# Basically, we should still let a few ms to be sure all the keys in a control
# sequence will have enough time to reach tmux.
#}}}
set -s escape-time 10
# If the terminal supports focus events, they will be requested by the tmux
# client and passed through to the tmux server, then to the programs it runs.
# Necessary to be able to listen to `FocusGained` and `FocusLost`.
# Also necessary for `pane-focus-[in|out]` hooks.
set -s focus-events on
# history of tmux commands (pfx :)
set -s history-file "$HOME/.tmux/command_history"
# What does this do?{{{
#
# It makes tmux sometimes send an OSC 52 sequence – which sets the terminal
# clipboard content – if there is an `Ms` entry in the terminfo description of
# the outer terminal.
#}}}
# What are the possible values of this option?{{{
#
# - `on`
# - `external`
# - `off`
#
# ---
#
# There are 3 ways to create a tmux buffer:
#
# 1. invoke the `set-buffer` or `load-buffer` tmux commands
# 2. copy text in copy mode (`send -X copy-selection`, `copy-pipe`, ...)
# 3. send an OSC 52 sequence from an application inside tmux (e.g. `$ printf ...`)
#
# `1.` always creates a tmux buffer; never sets the X clipboard.
# `2.` always creates a tmux buffer; sets the X clipboard via OSC 52 iff `set-clipboard` is not `off`.
# `3.` creates a tmux buffer *and* sets the X clipboard via OSC 52 iff `set-clipboard` is `on`.
#
# IOW, `external` makes tmux *automatically* set the X clipboard when you yank
# sth in copy mode via OSC 52, while `on` does the same, but also allows an
# application to *manually* set a tmux buffer/the X clipboard via a OSC 52.
#
# Source: https://unix.stackexchange.com/a/560464/289772
#}}}
# What is the possible drawback of the value `on`?{{{
#
# https://github.com/tmux/tmux/wiki/Clipboard#security-concerns
#}}}
# How to disable OSC 52 for some terminals, but not all?{{{
#
# # or use 'external'
# set -s set-clipboard on
# set -as terminal-overrides 'yourTERMname:Ms@'
# ^
# man terminfo /Similar Terminals/;/canceled
#}}}
set -s set-clipboard external
# Why do you move your 'terminal-overrides' settings in another file?{{{
#
# It makes it easier to source the settings only when the tmux server is started;
# not when we manually re-source `tmux.conf`.
#}}}
# Why do you need them to be sourced only once?{{{
#
# We *append* strings to the value of the 'terminal-overrides' option.
# I don't want to append the same strings again and again every time I re-source
# `tmux.conf`.
#}}}
# Why don't you simply reset the option before appending a value?{{{
#
# That would make us lose the default value of the option:
#
# terminal-overrides[0] "xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007:Cs=\\E]12;%p1%s\\007:Cr=\\E]112\\007:Ss=\\E[%p1%d q:Se=\\E[2 q"
# terminal-overrides[1] screen*:XT
#
# ---
#
# Besides, one of the value we append to 'terminal-overrides' depends on the value of `$TERM`.
#
# if '[ "$TERM" != "st-256color" ]' 'set -as terminal-overrides ",*:Cr=\\E]112\\007"'
# ^----------------------^
#
# And the value of `$TERM` will be correct only the first time we source `tmux.conf`.
#}}}
# What's the value of `$TERM` here?{{{
#
# The first time our `tmux.conf` is sourced, it matches the `$TERM` of the
# outer terminal; the next times, it's the value of 'default-terminal' (i.e.
# 'tmux-256color').
#}}}
# What's the meaning of this `if` guard?{{{
#
# The condition `[ "$TERM" != "tmux-256color" ]` is true only the first time our
# `tmux.conf` is sourced.
# So, this part of the guard means: