Merge bugfix/tmux-macos-keys into develop
This commit is contained in:
@@ -107,3 +107,10 @@ Branch: feature/tmux-config (off develop, "met ca dans develop" = finish into de
|
||||
- [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
|
||||
|
||||
## tmux follow-ups (2026-10-06, branch bugfix/tmux-macos-keys)
|
||||
- [x] tmux.conf: pbcopy/pbpaste, `bind C-a send-prefix`, is_vim via pane_current_command
|
||||
- [x] pane moves ctrl+u/h/j/k (arrow layout, AZERTY/QWERTY invariant), resize mirrors with prefix; C-l free
|
||||
- [x] splits: prefix i (side by side) and prefix - (stacked), h/j/k/l kept
|
||||
- [x] Linux: deploy_tmux_config on both OSes (gated on tmux), clipboard if-shell (pbcopy else tmux buffer + OSC 52), XDG_CACHE_HOME in bashrc-linux
|
||||
- [x] Verified: shellcheck/bash -n, macOS test server, Ubuntu 24.04 container (tmux 3.4) full deploy + bindings + split + plugins + libtmux
|
||||
|
||||
@@ -22,7 +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
|
||||
tmux.conf tmux config (vi keys, tpm plugins) → ~/.config/tmux/tmux.conf, both OSes (tmux ≥ 3.1)
|
||||
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)
|
||||
|
||||
@@ -17,7 +17,7 @@ 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 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`. |
|
||||
| `tmux.conf` | tmux config (vi keys, mouse, status bar, tpm plugins: resurrect + continuum session restore, window-name). Deployed on both OSes to `~/.config/tmux/tmux.conf` (tmux ≥ 3.1). |
|
||||
| `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. |
|
||||
@@ -66,7 +66,7 @@ What it does:
|
||||
3. Moves any existing `~/.vim`, `~/.vimrc`, `~/.bashrc`, `~/.Sublivim` to `~/Oldconfig`.
|
||||
4. Clones the `syntastic` and `nerdtree` vim plugins into `~/.vim/bundle/`.
|
||||
5. Copies the tracked vim files into `~/.vim` and symlinks `~/.vimrc`.
|
||||
6. Picks the bashrc by OS: macOS → `bashrc-osx` (falls back to `bashrc-linux` if missing), everything else → `bashrc-linux`. Copies it to `~/.bashrc`. Then renders `gitconfig` into `~/.gitconfig` with that bashrc's `USER` / `EMAIL`. A different existing `~/.gitconfig` is saved as `~/.gitconfig.backup-<date>`; an identical one is left alone. It is the global level only: a repo's own `.git/config` still overrides it. `core.excludesfile` points at `~/.gitignore`, ignored by git when the file does not exist.
|
||||
6. Picks the bashrc by OS: macOS → `bashrc-osx` (falls back to `bashrc-linux` if missing), everything else → `bashrc-linux`. Copies it to `~/.bashrc`. Then renders `gitconfig` into `~/.gitconfig` with that bashrc's `USER` / `EMAIL`. A different existing `~/.gitconfig` is saved as `~/.gitconfig.backup-<date>`; an identical one is left alone. It is the global level only: a repo's own `.git/config` still overrides it. `core.excludesfile` points at `~/.gitignore`, ignored by git when the file does not exist. Then deploys `tmux.conf` to `~/.config/tmux/tmux.conf` (both OSes, tmux ≥ 3.1: Ubuntu 22.04+, brew), clones [tpm](https://github.com/tmux-plugins/tpm) and fetches the listed plugins headlessly; details under [macOS](#macos) step 6, the step is the same. On Linux, `y` copies into tmux's buffer and the terminal clipboard through OSC 52; macOS uses `pbcopy`/`pbpaste`.
|
||||
7. Installs Python CLIs via `pipx` (`PyMuPDF` → `pymupdf`, `Markdown` → `markdown_py`) — skipped if `pipx` is absent.
|
||||
8. Copies the `bin/` scripts (`dt`, `dtach-router`, `claude-provider`) into `~/.local/bin`. The dtach session-resume menu ships in the deployed bashrc (both OSes), so every interactive shell offers it — including VS Code Remote-SSH terminals, which are non-login and never read `~/.profile`. The installer also strips any older dtach block left in `~/.profile` so a plain SSH login doesn't prompt twice.
|
||||
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.
|
||||
@@ -105,7 +105,7 @@ 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. 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`.
|
||||
6. Deploys `tmux.conf` to `~/.config/tmux/tmux.conf` (same step on Linux), 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.
|
||||
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.
|
||||
|
||||
@@ -7,6 +7,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:"*) ;;
|
||||
|
||||
+13
-8
@@ -418,10 +418,11 @@ 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.
|
||||
# tmux, both OSes: tmux.conf goes to ~/.config/tmux/tmux.conf (read there since
|
||||
# tmux 3.1: Ubuntu 22.04+, brew) 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)"
|
||||
@@ -456,9 +457,9 @@ install_tmux_plugins() {
|
||||
}
|
||||
|
||||
# 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.
|
||||
# python and Ubuntu 23.04+ refuse 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)"
|
||||
@@ -654,6 +655,11 @@ cp "$SCRIPT_DIR/$bashrc" "$HOME/.bashrc"
|
||||
# User-scope git config, identity taken from the bashrc just deployed.
|
||||
deploy_gitconfig "$SCRIPT_DIR/$bashrc"
|
||||
|
||||
# tmux config + plugins (tmux comes from the apt or brew list above).
|
||||
if command -v tmux >/dev/null 2>&1; then
|
||||
deploy_tmux_config
|
||||
fi
|
||||
|
||||
# Python CLIs via pipx (run as the user, never sudo). Skipped if pipx is absent.
|
||||
if command -v pipx >/dev/null 2>&1; then
|
||||
echo "Installing pipx CLIs (PyMuPDF -> pymupdf, Markdown -> markdown_py)"
|
||||
@@ -685,7 +691,6 @@ 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
|
||||
|
||||
@@ -43,12 +43,11 @@ set -g set-titles-string '#S :: #W :: #F#P #{pane_current_command}'
|
||||
# Variables: {{{
|
||||
# ---------
|
||||
|
||||
is_vim='tmux show -v "@tmux_vim_#{pane_id}" | grep yes' # check if is vim
|
||||
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
|
||||
# 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)?$"
|
||||
# The pane's foreground command, as tmux sees it. The older variant read a
|
||||
# "@tmux_vim_<pane>" variable that a vim plugin had to set; nothing sets it
|
||||
# here, so C-h/j/k/l never reached vim.
|
||||
# }}}
|
||||
|
||||
resurrect_root_dir="$XDG_CACHE_HOME/tmux/resurect"
|
||||
@@ -114,39 +113,38 @@ unbind-key -T copy-mode-vi MouseDragEnd1Pane # (mouse setting) {{{
|
||||
# }}}
|
||||
|
||||
set -g prefix C-a # bind screen like prefix
|
||||
bind C-a send-prefix # C-a C-a = literal C-a (shell home)
|
||||
|
||||
# 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
|
||||
# Resizing key bindings (same arrow layout as the moves below, with prefix)
|
||||
bind-key -r C-u resize-pane -U 5
|
||||
bind-key -r C-h resize-pane -L 5
|
||||
bind-key -r C-j resize-pane -D 5
|
||||
bind-key -r C-k resize-pane -R 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)
|
||||
# Moving across panes (and vim), no prefix: ctrl + u/h/j/k laid out as arrows
|
||||
# (u up, h left, j down, k right). These keys sit at the same place on AZERTY
|
||||
# and QWERTY US, and need no option key. Each one still reaches vim when vim
|
||||
# runs in the pane. C-l is free, so it clears the shell screen again.
|
||||
# Shell cost: C-u (readline "clear the line") is taken.
|
||||
bind -n C-u if-shell "$is_vim" "send-keys C-u" "select-pane -U"
|
||||
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 -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -R"
|
||||
|
||||
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"
|
||||
# }}}
|
||||
# Clipboard: pbcopy/pbpaste on macOS. Elsewhere tmux's own buffer, which tmux
|
||||
# also hands to the terminal through OSC 52 (set-clipboard), so it reaches the
|
||||
# local clipboard over ssh. xsel/xclip dropped: headless servers have no X.
|
||||
if-shell 'command -v pbcopy >/dev/null' \
|
||||
'bind -Tcopy-mode-vi y send -X copy-pipe-and-cancel pbcopy ; bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"' \
|
||||
'bind -Tcopy-mode-vi y send -X copy-selection-and-cancel ; bind p 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
|
||||
|
||||
@@ -164,6 +162,8 @@ 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-key i "split-window -h -c '#{pane_current_path}'" # i: side by side (vertical bar)
|
||||
bind-key - "split-window -v -c '#{pane_current_path}'" # -: stacked (horizontal bar)
|
||||
|
||||
bind q kill-window # Kill window
|
||||
bind Q kill-session # Kill the session (not server)
|
||||
|
||||
Reference in New Issue
Block a user