Merge feature/tmux-config into develop

This commit is contained in:
bchanot
2026-10-06 12:27:34 +02:00
8 changed files with 352 additions and 16 deletions
+3
View File
@@ -87,3 +87,6 @@ choices. Full install.sh not run on this Mac. BDR-015/016, LRN-014, BLK-007. Mer
## 2026-10-06
- Cut v1.0.0: first tagged release, develop → main via /release-candidate. CHANGELOG.md bootstrapped from 31 develop commits, version.txt created. Tag pushed. Pre-existing shellcheck SC2148 on bashrc files untouched.
## 2026-10-06 (pm) — macOS tmux config + cloudpex offer
Done: tmux.conf (sohorx vi-style, tpm) deployed on macOS → ~/.config/tmux, tpm cloned + plugins fetched headless, libtmux via pip --user (PEP 668 fallback). XDG_CACHE_HOME exported in osx rc files (config needs it, else resurrect dir = "/tmux/"). cloudpex: unconditional install → [y/N] offer with the other Linux extras. Verified: shellcheck, temp-HOME run x3, tmux parses config. Branch feature/tmux-config → develop.
+8
View File
@@ -99,3 +99,11 @@ Same branch. Prompt at start of Darwin block (MACOS_SHELL=bash|zsh env overrides
- [x] README + CLAUDE.md layout
- [x] Verify: shellcheck, bash -n, render to temp HOME, `git config --file` reads values
- [x] `git-delta` added to apt + brew lists (gitconfig pager = delta)
## Feature — macOS tmux config (tmux.conf + tpm) ; cloudpex becomes an offer (2026-10-06)
Branch: feature/tmux-config (off develop, "met ca dans develop" = finish into develop). tmux already in the brew list.
- [x] install.sh `deploy_tmux_config` (Darwin): tmux.conf → ~/.config/tmux/tmux.conf (differing one → .backup-<date>, stray ~/.tmux.conf moved aside since tmux reads it first), clone tpm, headless `install_plugins`, libtmux for tmux-window-name (non-fatal)
- [x] bashrc-osx + zshrc-osx: export XDG_CACHE_HOME (tmux.conf resurrect dir needs it, else "/tmux/")
- [x] README macOS step + CLAUDE.md layout
- [x] shellcheck, bash -n, zsh -n; run deploy_tmux_config against a temp HOME; tmux parses the config
- [x] cloudpex: `install_cloudpex` → `offer_cloudpex` ([y/N] via confirm, with the other Linux offers); README/CLAUDE.md wording
+2 -1
View File
@@ -22,6 +22,7 @@ vim/autoload/ pathogen loader (committed)
vim/colors/ molokai colorscheme (committed)
bash/bashrc-{linux,osx} OS-detected bashrc (exports USER/EMAIL identity)
gitconfig user-scope ~/.gitconfig template, @USER@/@EMAIL@ filled at install
tmux.conf tmux config (vi keys, tpm plugins) → ~/.config/tmux/tmux.conf, macOS only
zsh/{zshrc-osx,bchanot.zsh-theme} macOS zsh option: oh-my-zsh zshrc + theme porting the bash prompt
bin/{dt,dtach-router,claude-provider} CLI scripts deployed to ~/.local/bin
etc/profile.d/disk-usage-warning.sh login-time low-disk warning → /etc/profile.d (Linux only)
@@ -31,7 +32,7 @@ etc/default/earlyoom earlyoom args, spare sshd / kill node fi
etc/fail2ban/jail.d/local.conf sshd jail: journal backend, all-ports ban, LAN ignored (always)
etc/apt/apt.conf.d/20auto-upgrades unattended security upgrades on (always)
etc/ssh/sshd_config.d/20-hardening.conf sshd limits that cannot lock out, sshd -t gated (always)
cloudpex/{cloudpex,install.sh,README.md} on-demand SMB mount helper → /usr/local/bin; site values
cloudpex/{cloudpex,install.sh,README.md} on-demand SMB mount helper → /usr/local/bin, offered [y/N]; site values
prompted at install → /etc/cloudpex.conf, never in the script (FR docs)
.claude/{tasks,memory,audits}/ Claude working state
```
+7 -5
View File
@@ -16,8 +16,9 @@ curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/master/remote-instal
| Path | Purpose |
| -------------------- | -------------------------------------------------------------- |
| `install.sh` | Linux: installs apt packages + Docker + code-server + RDP (gnome-remote-desktop), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools, a low-disk login warning and the `cloudpex` NAS mount helper; ends by offering two system changes (`/tmp` on disk, SSH memory guard). macOS: same tooling through Homebrew (see [macOS](#macos)), then prints what was not installed compared with Linux. |
| `cloudpex/` | On-demand SMB mount of a NAS share (`cloudpex` command + its installer). Site values (host, share, SMB user, mount point, SMB version) are prompted at install and stored in `/etc/cloudpex.conf`, never in the script. French README inside. |
| `install.sh` | Linux: installs apt packages + Docker + code-server + RDP (gnome-remote-desktop), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools and a low-disk login warning; ends by offering three extras (`/tmp` on disk, SSH memory guard, the `cloudpex` NAS mount helper). macOS: same tooling through Homebrew (see [macOS](#macos)), deploys the tmux config, then prints what was not installed compared with Linux. |
| `tmux.conf` | tmux config (vi keys, mouse, status bar, tpm plugins: resurrect + continuum session restore, window-name). Deployed on macOS to `~/.config/tmux/tmux.conf`. |
| `cloudpex/` | On-demand SMB mount of a NAS share (`cloudpex` command + its installer, offered `[y/N]` at the end of a Linux install). Site values (host, share, SMB user, mount point, SMB version) are prompted at install and stored in `/etc/cloudpex.conf`, never in the script. French README inside. |
| `etc/tmpfiles.d/tmp.conf` | Cleanup rules for a disk-backed `/tmp` (wiped at boot, 10-day purge). Deployed by the `/tmp` on disk offer. |
| `etc/systemd/ssh.service.d/override.conf` | `ssh.service` drop-in: sshd exempt from the OOM killer + memory reclaim protection. Deployed by the SSH memory guard offer. |
| `etc/default/earlyoom` | earlyoom arguments: spare sshd/systemd, kill node/java first. Deployed by the SSH memory guard offer. |
@@ -71,7 +72,7 @@ What it does:
9. On Linux, installs `etc/profile.d/disk-usage-warning.sh` to `/etc/profile.d/` (needs `sudo`) so each login warns when `/` or `/home` cross 85% usage.
10. On Linux, installs **code-server** (VS Code in the browser) via its vendor script — skipped if already present — and enables the `code-server@<login>` systemd service (login from `id -un`: the bashrc overrides `$USER`).
11. On Linux, installs **`ubuntu-desktop-minimal`** (GDM + GNOME Shell, ~1.5 GB): the RDP remote login below hands out a GNOME session, which a bare server install does not have. Then sets up **RDP remote login** via `gnome-remote-desktop` (Wayland-native): installs the daemon + `openssl`, generates a self-signed TLS cert once, and prompts interactively for shared "gate" credentials (skipped when no terminal is attached, or already set). Disables `xrdp` if present; opens UFW port `3389` only when UFW is already active. Finally, when `lspci` sees an NVIDIA GPU, runs `ubuntu-drivers install` to put on the driver the distro recommends for the card (no version pinned; loads at the next reboot). Skipped on machines without an NVIDIA GPU.
12. On Linux, installs the **`cloudpex`** NAS mount helper to `/usr/local/bin` via `cloudpex/install.sh`, which prompts for the NAS host, share name, SMB user, mount point and SMB version and writes them to `/etc/cloudpex.conf` (root, `0600`; an existing config is shown and kept unless you say `n`; skipped when no terminal is attached). Nothing is mounted, no password stored, see [`cloudpex/README.md`](cloudpex/README.md).
12. On Linux, at the very end, **offers** (`[y/N]`) to install the **`cloudpex`** NAS mount helper to `/usr/local/bin` via `cloudpex/install.sh`, which prompts for the NAS host, share name, SMB user, mount point and SMB version and writes them to `/etc/cloudpex.conf` (root, `0600`; an existing config is shown and kept unless you say `n`; skipped when no terminal is attached). Nothing is mounted, no password stored, see [`cloudpex/README.md`](cloudpex/README.md).
13. On Linux, installs the **security baseline**, always, no prompt: **fail2ban** (+ `nftables`) with `etc/fail2ban/jail.d/local.conf` (sshd jail reading the journal, bans the offending IP on every port so the SSH port does not matter, 5 failures in 10 min → 1 h ban, loopback and private LAN ranges never banned); **unattended-upgrades** enabled through `etc/apt/apt.conf.d/20auto-upgrades`; and the **sshd drop-in** `etc/ssh/sshd_config.d/20-hardening.conf` (`PermitRootLogin no`, `MaxAuthTries 3`, `LoginGraceTime 20`), checked with `sshd -t` and removed again if sshd rejects it, then `reload ssh`. Authentication methods, port and user lists are left as they are.
14. On Linux, at the very end, **offers** (`[y/N]`, skipped when no terminal is attached) to move **`/tmp` to disk**: Ubuntu mounts `/tmp` as a RAM-backed tmpfs capped at 50% of RAM, which agent runs fill, halving the RAM and breaking every shell with "No space left on device". Accepting masks `tmp.mount` and installs `etc/tmpfiles.d/tmp.conf` (wipe at boot, 10-day purge). Effective at the next reboot.
15. On Linux, at the very end, **offers** to keep **SSH reachable under memory pressure**: installs the `ssh.service` drop-in (`OOMScoreAdjust=-1000`, `MemoryMin=256M`) and `earlyoom` with `etc/default/earlyoom` (kills the largest process, `node`/`java` first and never `sshd`, once free RAM and swap both drop under 10%). Restarting `ssh` keeps open sessions. Note: `MemoryMin` protects the sshd daemon only; login sessions live in `user.slice`, so no setting can reserve RAM for a future shell. earlyoom acting in time is the real protection.
@@ -104,9 +105,10 @@ The same `./install.sh` detects macOS and replaces `apt-get` with Homebrew. It f
3. Docker: `colima` (the Linux VM) + `docker docker-compose docker-buildx`. Writes `~/.docker/config.json` with `cliPluginsExtraDirs` so `docker compose` works, only when that file does not exist yet (otherwise prints the line to add).
4. Starts `colima`, `code-server` and `mariadb` as `brew services` (the `systemctl enable --now` equivalent), skipping any already started.
5. Deploys `bashrc-osx`, then appends one line to `~/.bash_profile` that sources `~/.bashrc`: macOS terminals open login shells, which never read `~/.bashrc` on their own. Done for both choices, so `bash` stays usable.
6. **bash** chosen: makes brew's bash 5 the login shell (adds it to `/etc/shells` with `sudo`, then `chsh`, which asks for your password). macOS ships bash 3.2, too old for the bashrc.
6. Deploys `tmux.conf` to `~/.config/tmux/tmux.conf` (brew's tmux reads it there), clones [tpm](https://github.com/tmux-plugins/tpm) into `~/.config/tmux/plugins/tpm` and fetches the listed plugins headlessly (resurrect + continuum restore your sessions, window-name renames windows after what runs in them). A `~/.tmux.conf` would be read instead, so one found is moved to `~/.tmux.conf.backup-<date>`; a differing `~/.config/tmux/tmux.conf` becomes `tmux.conf.backup-<date>`. `libtmux` (needed by window-name) goes in the python user site; brew's python blocks that by default, so the install retries with `--break-system-packages`. Both plugin steps only warn on failure: `prefix` + `I` inside tmux fetches the plugins. Prefix is `C-a`.
7. **bash** chosen: makes brew's bash 5 the login shell (adds it to `/etc/shells` with `sudo`, then `chsh`, which asks for your password). macOS ships bash 3.2, too old for the bashrc.
**zsh** chosen: installs oh-my-zsh with its official script (unattended, skipped if `~/.oh-my-zsh` exists), deploys `zsh/zshrc-osx` to `~/.zshrc` and the `bchanot` theme to `~/.oh-my-zsh/custom/themes/`, then makes `/bin/zsh` the login shell. An existing `~/.zshrc` that differs from the repo's is saved as `~/.zshrc.backup-<date>` (outside `~/Oldconfig`, which every run wipes). Move your machine-specific lines (nvm, bun, tokens) into `~/.zshrc.local`: the deployed zshrc loads it.
7. Ends with the list of what the Linux install has and this one does not: `gcc` (Apple clang answers to `gcc`), `valgrind`, `dkms`, `net-tools`, `openssh-server` and the RDP desktop (both built into macOS, switched on in System Settings > Sharing), `cifs-utils`, `php-imagick`, the NVIDIA driver, the disk-usage warning, `cloudpex`, the security baseline and the two end-of-install offers.
8. Ends with the list of what the Linux install has and this one does not: `gcc` (Apple clang answers to `gcc`), `valgrind`, `dkms`, `net-tools`, `openssh-server` and the RDP desktop (both built into macOS, switched on in System Settings > Sharing), `cifs-utils`, `php-imagick`, the NVIDIA driver, the disk-usage warning, `cloudpex`, the security baseline and the two end-of-install offers.
### CLI scripts (`bin/`)
+3
View File
@@ -17,6 +17,9 @@ alias grep='grep --color=auto'
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# XDG cache dir: tmux.conf saves resurrect/continuum sessions under it
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
# Ensure ~/.local/bin is on PATH (pipx CLIs + personal scripts from bin/)
case ":$PATH:" in
*":$HOME/.local/bin:"*) ;;
+58 -10
View File
@@ -152,11 +152,11 @@ unwire_dtach_profile() {
' "$profile" > "$profile.tmp" && mv "$profile.tmp" "$profile"
}
# NAS helper: deploys the on-demand CloudPex SMB mount command to /usr/local/bin
# (see cloudpex/README.md). Nothing is mounted and no credential is stored.
# Linux-only (cifs-utils); the helper's own installer is idempotent.
install_cloudpex() {
echo "Installing the cloudpex mount helper"
# NAS helper, on request: deploys the on-demand CloudPex SMB mount command to
# /usr/local/bin (see cloudpex/README.md). Nothing is mounted and no credential is
# stored. Linux-only (cifs-utils); the helper's own installer is idempotent.
offer_cloudpex() {
confirm "Install the cloudpex NAS mount helper (on-demand SMB mount)?" || return 0
bash "$SCRIPT_DIR/cloudpex/install.sh"
}
@@ -418,6 +418,55 @@ setup_macos_shell() {
fi
}
# tmux: tmux.conf goes to ~/.config/tmux/tmux.conf (tmux >= 3.1 reads it there)
# with tpm, which the config runs, in ~/.config/tmux/plugins/tpm. tmux reads a
# ~/.tmux.conf first, so one found is moved aside; a differing config is kept as
# tmux.conf.backup-<date>, outside ~/Oldconfig which every run wipes. Idempotent.
deploy_tmux_config() {
local dir="$HOME/.config/tmux" stamp
stamp="$(date +%Y%m%d-%H%M%S)"
mkdir -p "$dir"
if [ -e "$HOME/.tmux.conf" ]; then
echo "Moving ~/.tmux.conf to ~/.tmux.conf.backup-$stamp (it would shadow $dir/tmux.conf)"
mv "$HOME/.tmux.conf" "$HOME/.tmux.conf.backup-$stamp"
fi
if [ -e "$dir/tmux.conf" ] && ! cmp -s "$dir/tmux.conf" "$SCRIPT_DIR/tmux.conf"; then
echo "Saving the current tmux.conf to $dir/tmux.conf.backup-$stamp"
mv "$dir/tmux.conf" "$dir/tmux.conf.backup-$stamp"
fi
echo "Deploying tmux.conf to $dir"
cp "$SCRIPT_DIR/tmux.conf" "$dir/tmux.conf"
install_tmux_plugins "$dir/plugins/tpm"
}
# tpm plus the plugins tmux.conf lists, fetched now so the first tmux start is
# complete. tpm's script starts a tmux server to read @tpm_plugins, and the config
# expects XDG_CACHE_HOME (exported by the rc files, not loaded by this script).
# Failures only warn: prefix+I fetches the plugins from inside tmux.
install_tmux_plugins() {
local tpm="$1"
if [ ! -d "$tpm" ]; then
echo "Cloning tpm"
git clone --quiet https://github.com/tmux-plugins/tpm "$tpm"
fi
echo "Installing tmux plugins"
XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" "$tpm/bin/install_plugins" \
|| echo "tmux plugins not installed — press prefix+I inside tmux" >&2
install_libtmux
}
# tmux-window-name (a listed plugin) is a python script importing libtmux. Brew's
# python refuses pip installs outside a venv (PEP 668), so the user-site install
# is retried with that guard lifted. Non-fatal: without it, windows keep tmux's
# own automatic-rename.
install_libtmux() {
python3 -c 'import libtmux' 2>/dev/null && return 0
echo "Installing libtmux (tmux-window-name plugin)"
python3 -m pip install --quiet --user libtmux 2>/dev/null \
|| python3 -m pip install --quiet --user --break-system-packages libtmux \
|| echo "libtmux not installed — tmux-window-name stays inactive" >&2
}
# macOS terminals open LOGIN shells, which read ~/.bash_profile and never ~/.bashrc.
# Appends one line sourcing ~/.bashrc. Idempotent: skipped when already present.
wire_bash_profile() {
@@ -545,9 +594,6 @@ if command -v apt-get >/dev/null 2>&1; then
# Low-disk login warning (system-wide profile.d snippet).
install_disk_warning
# On-demand NAS mount helper (cloudpex/).
install_cloudpex
# Security baseline: brute-force bans, automatic security updates, sshd limits.
install_fail2ban
install_unattended_upgrades
@@ -626,11 +672,12 @@ chmod +x "$HOME"/.local/bin/dt "$HOME"/.local/bin/dtach-router "$HOME"/.local/bi
# Remove any stale dtach wiring from ~/.profile (the menu now ships in ~/.bashrc; see above).
unwire_dtach_profile
# Optional system changes, offered last so the base install is complete even when
# declined. Linux/systemd only. Each prompts [y/N] on a terminal, is skipped otherwise.
# Optional pieces, offered last so the base install is complete even when
# declined. Linux only. Each prompts [y/N] on a terminal, is skipped otherwise.
if command -v apt-get >/dev/null 2>&1; then
offer_tmp_on_disk
offer_ssh_memory_guard
offer_cloudpex
fi
# macOS: login shells skip ~/.bashrc unless ~/.bash_profile sources it (kept even
@@ -638,6 +685,7 @@ fi
# Linux install has that this one does not.
if [ "$(uname -s)" = "Darwin" ]; then
wire_bash_profile
deploy_tmux_config
setup_macos_shell "${macos_shell:-bash}"
print_macos_gaps
fi
+268
View File
@@ -0,0 +1,268 @@
# --------------------------------------------------------------------------- #
# #
# Module: tmux.conf By: sohorx <banlin.adrien@gmail.com> #
# #
# Created: 2015/04/01 18:17:25 Updated: 2016/04/01 18:17:25 #
# #
# --------------------------------------------------------------------------- #
# Note: {{{ #
# minimalist tmux configuration which behave a bit like vi #
# }}} #
# --------------------------------------------------------------------------- #
# Global options: {{{
# --------------
set -g bell-action none # make it Shut up!
set-option -g default-shell $SHELL # set shell
set -g default-terminal "screen-256color" # term colors
#set -ga terminal-overrides ",*256col*:Tc" # term cap only
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q,*256col*:Tc' # cursor control
setw -g mode-keys vi # vi mode
set -s escape-time 1 # Fix terminal name issues
set -g set-titles on # Turn on window titles
setw -g automatic-rename on # Automatically set window title
set -g mouse on # mouse cap
set-window-option -g clock-mode-colour brightwhite # set colour clock
set -g focus-events on # for vim (?)
set-option -g automatic-rename on # auto rename session
set-option -g status-interval 5 # rename session interval
set -g status on # enable status bar at start
# https://github.com/3rd/image.nvim/?tab=readme-ov-file#tmux
set -gq allow-passthrough on # image.nvim requirements
set -g visual-activity off # image.nvim requirements
# ------------------------------------------------------------------------- }}}
# Change default strings: {{{
# ----------------------
# Set window title string
set -g set-titles-string '#S :: #W :: #F#P #{pane_current_command}'
#set-option -g automatic-rename-format "#{b:pane_current_path}"
# ------------------------------------------------------------------------- }}}
# Variables: {{{
# ---------
is_vim='tmux show -v "@tmux_vim_#{pane_id}" | grep yes' # check if is vim
# is_vim Note: {{{
# vim is actually changing values of a variable to make it visible by tmux.
# Without this, tmux would have to grep the current pane to see what is
# running. ex:
# echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"
# }}}
resurrect_root_dir="$XDG_CACHE_HOME/tmux/resurect"
# chunk of status bar variables and coloration
#sep_st='#[fg=brightwhite,bg=brightblue]'
#sep_c='#[fg=black]'
#
#sep_d='#[fg=brightwhite,bold]'
#sep_e='#[default,fg=brightblack]#[bg=brightblack]#[fg=brightwhite]'
#sep_f='#[fg=black]'
#
#sep_g='#[fg=blue,bold]'
#sep_h='#[default,fg=brightwhite]#[fg=blue,bg=brightwhite,bold]'
#sep_i='#[default,bg=brightwhite,fg=black]'
#
#sep_b='#[fg=brightyellow]#[default, bg=brightyellow, fg=black]'
#sep_a='#[fg=yellow]#[bg=yellow, fg=black]'
#
#sep_off="#[fg=brightred]#[bg=brightred, fg=brightwhite, bold] OFF"
#sep_on="#[fg=green]#[bg=green, fg=brightwhite, bold] ON"
#
#brightwhite_fg="#[fg=brightwhite]"
##
sep_st='#[fg=brightwhite,bg=brightblue]'
sep_c='#[fg=black] '
sep_d='#[fg=brightwhite,bold] '
sep_e='#[default,fg=brightblack] #[bg=brightblack]#[fg=brightwhite]'
sep_f='#[fg=black]'
sep_g='#[fg=brightblue,bold] '
sep_h='#[default,fg=brightwhite] #[fg=black,bg=brightwhite,bold]'
sep_i='#[default,bg=brightwhite,fg=black]'
sep_b='#[fg=brightyellow] #[default, bg=brightyellow, fg=black]'
sep_a='#[fg=yellow] #[bg=yellow, fg=black]'
sep_off="#[fg=brightred] #[bg=brightred, fg=brightwhite, bold] OFF"
sep_on="#[fg=green]#[bg=green, fg=brightwhite, bold] ON"
brightwhite_fg="#[fg=brightwhite]"
# ------------------------------------------------------------------------- }}}
# Key bindings: {{{
# ------------
# Unbindings
unbind [
unbind C-b # (prefix)
unbind C-n # (nav)
unbind l
unbind C-p
unbind v # (selection)
unbind y # (copy)
unbind p # (pasting)
unbind % # (sp)
unbind '"' # (vs)
unbind-key -T copy-mode-vi MouseDragEnd1Pane # (mouse setting) {{{
# disable "release mouse drag to copy and exit copy-mode"
# ref: https://github.com/tmux/tmux/issues/140
# }}}
set -g prefix C-a # bind screen like prefix
# specific commands
bind-key C-o command-prompt "new-session -s %1 -c ~"
bind R source-file ~/.config/tmux/tmux.conf \; display-message "Config reloaded..."
# Resizing key bindings
bind-key -r C-l resize-pane -R 5
bind-key -r C-k resize-pane -U 5
bind-key -r C-j resize-pane -D 5
bind-key -r C-h resize-pane -L 5
bind-key -r C-n next-window \; set status on
bind-key -r C-p previous-window \; set status on
# Moving accross pane (and vim)
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
#bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
bind Escape copy-mode # bind vi-like 'normal' mode
bind -Tcopy-mode-vi 'v' send -X begin-selection # bind vi-like visual mode
bind -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "xsel -b -i" # xsel copy
bind p run "xsel -b -o | tmux load-buffer - ; tmux paste-buffer" # xsel paste
# bind vi-like copy/paste through 'normal' mode, (Note) {{{
# It is encouraged to use xsel instead of xclip, because xclip does not close
# STDOUT after it has read from tmux's buffer. As such, tmux doesn't know
# that the copy task has completed, and continues to wait for xclip's
# termination, thereby rendering tmux unresponsive.
# Here an example of copy paste with pbcopy/pbpaste (macos)
# bind -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "pbcopy"
# bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"
# }}}
bind-key -Tcopy-mode-vi Escape send -X cancel # cancel v mode
bind-key -Tcopy-mode-vi ^v send -X rectangle-toggle # cancel v mode
bind-key -T copy-mode-vi MouseDown1Pane select-pane\; send-keys -X clear-selection
bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -eM\" \"send-keys -M\"' 'copy-mode -eM'
# (note) {{{
# The `bind-key -T copy-m...` let a single click do selection clearing for us.
# The `bind -n MouseDrag1Pane if -Ft= ...` changes the default binding of
# MouseDrag1Pane, the only difference is that we use `copy-mode -eM` instead
# of `copy-mode -M`, so that WheelDownPane can trigger copy-mode to exit when
# copy-mode is entered by MouseDrag1Pane
# }}}
bind-key k "split-window -v -b -c '#{pane_current_path}'"
bind-key h "split-window -h -b -c '#{pane_current_path}'"
bind-key j "split-window -v -c '#{pane_current_path}'"
bind-key l "split-window -h -c '#{pane_current_path}'"
bind q kill-window # Kill window
bind Q kill-session # Kill the session (not server)
bind C-c neww \; set status on # enable status bar
bind c neww \; set status on # disable status bar
# Enable disable bindings and change status bar with it {{{
bind -T root F10 set status off
bind -T root F9 set status on
bind -T root F12 \
set prefix None \; \
set key-table off \;\
set focus-events off \; \
set status-right '#{brightwhite_fg} #h #{sep_b} %a %d/%m/%Y #{sep_a} %H:%M #{sep_off} : #{continuum_status} ' \;\
set status on\; \
refresh-client -S\;
bind -T off F11 \
set -u prefix \;\
set -u key-table \;\
set -u focus-events \;\
set status-right '#{brightwhite_fg} #h #{sep_b} %a %d/%m/%Y #{sep_a} %H:%M #{sep_on} : #{continuum_status} ' \;\
set status on\;\
refresh-client -S\;
# }}}
# ------------------------------------------------------------------------- }}}
# Plugins: {{{
# -------
# To make plugins works, the run tpm must be done by the main file.
#
# run '~/.config/tmux/plugins/tpm/tpm'
##
set -g @tpm_plugins ' \
tmux-plugins/tpm \
ofirgall/tmux-window-name \
tmux-plugins/tmux-sensible \
tmux-plugins/tmux-resurrect \
tmux-plugins/tmux-continuum \
'
# plugins options
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-processes ' \
irb \
ipython \
~ranger \
pry \
ri \
"~bundle exec ri" \
"~bundle exec pry" \
"~pipenv shell" \
"~pipenv run" \
glow \
"~vaas-infra ssh" \
"~vaas-cli -s vaas-infra.dev.alphalink.fr ssh" \
ssh \
mosh \
tig \
'
set -g @resurrect-strategy-session 'always'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '15' # save every minutes
set -g @resurrect-dir "$XDG_CACHE_HOME/tmux/$TMUX_SOCKET_NAME"
# ------------------------------------------------------------------------- }}}
# Status Bar: {{{
# ----------
set -wg mode-style bg=black,fg=brightwhite
set-window-option -g window-status-separator ''
set -g status-position bottom
set -g status-left-length 42
set -g status-right-length 80
set -g status-justify left
#setw -g status-style bg=black
setw -g status-style bg=default
set -g status-left '#{sep_st} λ #S #{sep_c}'
# setw -g window-status-format '#{sep_d} #I #{sep_e} #W #{sep_f}'
# setw -g window-status-current-format '#{sep_g} #I #{sep_h} #W #{sep_i}'
# set -g status-right '#{brightwhite_fg} #h #{sep_b} %a %d/%m/%Y #{sep_a} %H:%M #{sep_on} : #{continuum_status} '
setw -g window-status-format '#{sep_e} #W #{sep_f}'
setw -g window-status-current-format '#{sep_h} #W #{sep_i}'
set -g status-right '#{sep_b} #h #{sep_e}#{sep_on} : #{continuum_status} '
# set Panel borders
set -g pane-active-border-style fg=white,bg=white
set -g pane-border-style fg=white,bg=default
# set Message text
set-option -g message-style bg=default,fg=red
set-option -g message-command-style bg=default,fg=brightwhite
# ------------------------------------------------------------------------- }}}
run '~/.config/tmux/plugins/tpm/tpm'
+3
View File
@@ -26,6 +26,9 @@ alias grep='grep --color=auto'
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# XDG cache dir: tmux.conf saves resurrect/continuum sessions under it
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
# Ensure ~/.local/bin is on PATH (pipx CLIs + personal scripts from bin/)
case ":$PATH:" in
*":$HOME/.local/bin:"*) ;;