Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
669d88b397 | ||
|
|
e432724b26 | ||
|
|
4336b0bf88 | ||
|
|
ff5999d882 | ||
|
|
702f4a224a | ||
|
|
b41848bab1 | ||
|
|
fc1445b49f | ||
|
|
fb7c9bb23e | ||
|
|
e7b5fb0a2e | ||
|
|
35fe5c2842 | ||
|
|
f92b026467 | ||
|
|
7ca5cfba57 | ||
|
|
269db4c1bb | ||
|
|
99ae81c21a | ||
|
|
345ee68b3b | ||
|
|
4dc8e778ff | ||
|
|
5b135a9fc0 | ||
|
|
e6fb4637b7 | ||
|
|
ab47219097 | ||
|
|
9b4d241725 | ||
|
|
f971881962 | ||
|
|
5cd98b3189 | ||
|
|
06dc54974a | ||
|
|
3db51f44ec | ||
|
|
7d76a677a5 | ||
|
|
a0911b05ce | ||
|
|
aeb8736871 | ||
|
|
8d4e698adb | ||
|
|
88389a748b | ||
|
|
e81cc2d4ef | ||
|
|
a12cbab97a | ||
|
|
c9e6ba3013 | ||
|
|
30588892ae | ||
|
|
e4e242d6ea | ||
|
|
91bbe059ec | ||
|
|
2ca06763c0 | ||
|
|
7d62da44b0 | ||
|
|
f825caf094 | ||
|
|
c9d47ce91d | ||
|
|
9d8347f58f | ||
|
|
64f06bbbbc | ||
|
|
e82af805fa | ||
|
|
64f7d92b0b | ||
|
|
5d602696d5 | ||
|
|
deb1449c82 | ||
|
|
f45517fd75 | ||
|
|
ca1ce07fac | ||
|
|
5b6d2f2232 | ||
|
|
4cbc54511e | ||
|
|
563c8f97ee | ||
|
|
6ba4e55e86 | ||
|
|
e7d870905f | ||
|
|
d5a500bb46 | ||
|
|
ead6f96eb0 | ||
|
|
be0e5eda47 | ||
|
|
7067b46f43 | ||
|
|
b5086863de | ||
|
|
a7b3646d15 | ||
|
|
280f592175 | ||
|
|
059a770139 | ||
|
|
ad8b9e55a8 | ||
|
|
40b72f85c4 | ||
|
|
de6fa1659c | ||
|
|
6882aa7c14 | ||
|
|
eb7a75182e | ||
|
|
9eea9782d1 | ||
|
|
d78d76c9ad | ||
|
|
b637601176 | ||
|
|
e4cf81830c | ||
|
|
c2196424b9 | ||
|
|
30b330967f | ||
|
|
252954b803 | ||
|
|
9901ec5da0 | ||
|
|
79554585c8 | ||
|
|
f721a2b809 | ||
|
|
666ce6c3ee | ||
|
|
4414bed2a6 | ||
|
|
cc490f57b3 | ||
|
|
f42e28807b | ||
|
|
2573756e73 | ||
|
|
fab1c8a0de | ||
|
|
6f0f6c1fa3 | ||
|
|
08ad4ddbfe | ||
|
|
ccc220fc69 | ||
|
|
6b634e2c77 | ||
|
|
22452477d5 | ||
|
|
72d38b68df | ||
|
|
31f8400852 | ||
|
|
773e1c5fa6 | ||
|
|
8b6ed6b983 | ||
|
|
dda78bb9bb | ||
|
|
cbdbe58491 | ||
|
|
ec9d0ed934 | ||
|
|
0a34c528ca | ||
|
|
7f63f4b0e2 | ||
|
|
0687f6a4fe | ||
|
|
8f6969001f | ||
|
|
f6a039fc80 | ||
|
|
8b5e9367d4 | ||
|
|
1f5e8990c8 | ||
|
|
51aed0e24d | ||
|
|
8ab681627c | ||
|
|
ef418fea04 | ||
|
|
b73ee086fd | ||
|
|
b900c6d3a3 | ||
|
|
ec9187c70f | ||
|
|
7abef66f50 | ||
|
|
e3be25f94c | ||
|
|
d2821fa462 | ||
|
|
ca8b1c19c9 | ||
|
|
b2244fc7ba | ||
|
|
d639f22e08 | ||
|
|
7adcef4f94 | ||
|
|
825abe842a | ||
|
|
1fbbffcedc | ||
|
|
dda3fabcf7 |
No files matched your search
@@ -1,3 +1,21 @@
|
|||||||
|
---
|
||||||
|
format: 2
|
||||||
|
type: blockers_registry
|
||||||
|
entry_prefix: BLK
|
||||||
|
schema:
|
||||||
|
id: BLK-XXX
|
||||||
|
date: YYYY-MM-DD
|
||||||
|
friction: string (what was blocked)
|
||||||
|
real_cause: string (root cause, not symptom)
|
||||||
|
solution: string (workaround or fix)
|
||||||
|
status: [open | resolved | upstream]
|
||||||
|
rules:
|
||||||
|
- Open a blocker as soon as friction > 15 min wasted. Close it with a real cause, not "moved on".
|
||||||
|
- Link to upstream issue / PR / commit when applicable.
|
||||||
|
- If cause is a bug in a dependency, set status upstream with a pointer to the tracker.
|
||||||
|
- Entries in English, caveman format (BDR-009): drop articles + filler, fragments OK, technical terms exact.
|
||||||
|
---
|
||||||
|
|
||||||
# Blockers
|
# Blockers
|
||||||
|
|
||||||
Friction + root cause + status. Caveman + English.
|
Friction + root cause + status. Caveman + English.
|
||||||
@@ -14,6 +32,7 @@ repo (remote git.bchanot.fr) would leak it. Root cause: key inlined in `write_op
|
|||||||
Fix: repo copy `bin/claude-provider` reads `${OPENROUTER_API_KEY:?...}` from env; key never in
|
Fix: repo copy `bin/claude-provider` reads `${OPENROUTER_API_KEY:?...}` from env; key never in
|
||||||
repo. Verified `git grep sk-or` clean. Status: resolved in repo. ACTION user: revoke old key at
|
repo. Verified `git grep sk-or` clean. Status: resolved in repo. ACTION user: revoke old key at
|
||||||
openrouter.ai (compromised — was in plaintext + exposed in chat).
|
openrouter.ai (compromised — was in plaintext + exposed in chat).
|
||||||
|
- **Status (2026-10-30, upgrade)**: resolved
|
||||||
|
|
||||||
## BLK-003 — xrdp block: `systemctl enable xrdb` typo aborted installer — RESOLVED
|
## BLK-003 — xrdp block: `systemctl enable xrdb` typo aborted installer — RESOLVED
|
||||||
2026-06-23. Uncommitted install.sh xrdp block had `sudo systemctl enable xrdb` (typo: `xrdb` = X
|
2026-06-23. Uncommitted install.sh xrdp block had `sudo systemctl enable xrdb` (typo: `xrdb` = X
|
||||||
@@ -31,6 +50,7 @@ despite: daemon LISTEN *:3389, ufw inactive, TLS cert readable, service active.
|
|||||||
PAM login at GDM. Empty gate creds → RDP nego refused before GDM → 0x904. Fix: set-credentials,
|
PAM login at GDM. Empty gate creds → RDP nego refused before GDM → 0x904. Fix: set-credentials,
|
||||||
connect (gate creds → GDM `bchanot`). Connection CONFIRMED live. Automated in install.sh via
|
connect (gate creds → GDM `bchanot`). Connection CONFIRMED live. Automated in install.sh via
|
||||||
ensure_rdp_credentials (prompt, TTY-guarded, idempotent). Supersedes BLK-003 (xrdp). Status: resolved.
|
ensure_rdp_credentials (prompt, TTY-guarded, idempotent). Supersedes BLK-003 (xrdp). Status: resolved.
|
||||||
|
- **Status (2026-10-30, upgrade)**: resolved
|
||||||
|
|
||||||
## BLK-005 — secrets still on NAS share: /mnt/cloudpex/transfert/root/ — OPEN (user action)
|
## BLK-005 — secrets still on NAS share: /mnt/cloudpex/transfert/root/ — OPEN (user action)
|
||||||
2026-09-22. RECOVERY checklist 06 + doc 04: delete `CloudPex/transfert/root/` (root ssh keys, .smbcredentials,
|
2026-09-22. RECOVERY checklist 06 + doc 04: delete `CloudPex/transfert/root/` (root ssh keys, .smbcredentials,
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
---
|
||||||
|
format: 2
|
||||||
|
type: decisions_registry
|
||||||
|
entry_prefix: BDR
|
||||||
|
schema:
|
||||||
|
id: BDR-XXX
|
||||||
|
date: YYYY-MM-DD
|
||||||
|
title: string (<= 80 chars)
|
||||||
|
decision: string (what was chosen)
|
||||||
|
why: string (motivation, context)
|
||||||
|
alternatives: list of strings (what was rejected + why)
|
||||||
|
status: [proposed | accepted | deprecated | superseded]
|
||||||
|
supersedes: BDR-XXX (optional)
|
||||||
|
rules:
|
||||||
|
- Append-only. Never rewrite past entries - add a new one with status superseded if needed.
|
||||||
|
- One entry per non-trivial choice. Trivial = reversible in under 10 min with no cross-file impact.
|
||||||
|
- Capture why more carefully than what - the what rots, the why lasts.
|
||||||
|
- Entries in English, caveman format (BDR-009): drop articles + filler, fragments OK, technical terms exact.
|
||||||
|
---
|
||||||
|
|
||||||
# Decisions
|
# Decisions
|
||||||
|
|
||||||
Design/architecture choices. Caveman + English.
|
Design/architecture choices. Caveman + English.
|
||||||
@@ -131,3 +151,27 @@ Docker; staying on zsh w/o config. Status: merged develop 7d5dabd.
|
|||||||
lines). deploy_zsh_config: if ~/.zshrc differs from repo copy (cmp -s) → timestamped mv in $HOME; identical → no
|
lines). deploy_zsh_config: if ~/.zshrc differs from repo copy (cmp -s) → timestamped mv in $HOME; identical → no
|
||||||
backup (rerun no dup). Machine-specific lines → ~/.zshrc.local (sourced). Same flaw still on .bashrc/.vim (open,
|
backup (rerun no dup). Machine-specific lines → ~/.zshrc.local (sourced). Same flaw still on .bashrc/.vim (open,
|
||||||
not fixed). Status: done.
|
not fixed). Status: done.
|
||||||
|
|
||||||
|
## BDR-017 — tmux pane moves on ctrl+u/h/j/k, not hjkl nor option+arrows
|
||||||
|
2026-10-06. u/h/j/k laid out as arrows (u up, h left, j down, k right): same key positions on AZERTY and QWERTY US,
|
||||||
|
control exists on every keyboard (option does not, cmd never reaches tmux). Alternatives rejected: ctrl+i/j/k/m
|
||||||
|
(C-i = Tab, C-m = Enter, same bytes, would break completion); option+arrows (needs iTerm2 "Left Option = Esc+",
|
||||||
|
no option key on some keyboards). Cost: shell loses C-u (readline clear-line). Gain: C-l free, clears screen again.
|
||||||
|
Resize mirrors it with prefix. Status: done (tmux.conf).
|
||||||
|
|
||||||
|
## BDR-018 — Linux tmux clipboard = tmux buffer + OSC 52, no xsel/xclip
|
||||||
|
2026-10-06. tmux.conf clipboard via `if-shell 'command -v pbcopy'`: macOS → pbcopy/pbpaste; else `y` =
|
||||||
|
copy-selection-and-cancel, `p` = paste-buffer, tmux hands the buffer to the terminal through OSC 52 (set-clipboard),
|
||||||
|
reaches the local clipboard over ssh from iTerm2. xsel/xclip rejected: headless servers have no X display (xsel
|
||||||
|
errors), xclip keeps STDOUT open and hangs tmux. Status: done.
|
||||||
|
|
||||||
|
## BDR-019 — gitflow.autopush at install: sed read of ~/.gitconfig, exact true/false, bad preset aborts
|
||||||
|
2026-10-07. Need: install asks push mode, renders `[gitflow] autopush` in gitconfig template. Chosen: existing
|
||||||
|
value read with `sed` on `~/.gitconfig` (same shape as rc_export_value), reused only if exactly `true`/`false`;
|
||||||
|
`DOTFILES_GITFLOW_AUTOPUSH` validated first, non-boolean → `return 1` → install aborts before any file touched;
|
||||||
|
prompt re-asks until exact, Enter = true; no tty = true. `render_gitconfig` refuses non-boolean / leaked
|
||||||
|
`@AUTOPUSH@`. Fixed `core.hooksPath = ~/.claude/githooks` in template (git expands `~`, `make link` owns dir).
|
||||||
|
Rejected: `git config --bool` read (that command family denied to Claude session → oracle could not run; also
|
||||||
|
XDG/system scopes not needed, installer writes ~/.gitconfig only); git boolean grammar / fr words (fail-open on
|
||||||
|
"non", user wants strict). Deviation from BDR-012 "never abort": bad preset aborts, user's fail-closed call.
|
||||||
|
Status: merged develop e4cf818.
|
||||||
@@ -1,3 +1,22 @@
|
|||||||
|
---
|
||||||
|
format: 2
|
||||||
|
type: evals_registry
|
||||||
|
entry_prefix: EVAL
|
||||||
|
schema:
|
||||||
|
id: EVAL-XXX
|
||||||
|
date: YYYY-MM-DD
|
||||||
|
output: string (what was produced)
|
||||||
|
method: string (how it was evaluated - manual read, test, benchmark, user feedback)
|
||||||
|
anomalies: list of strings (what was wrong, missing, surprising)
|
||||||
|
action: [keep | correct | deprecate]
|
||||||
|
rules:
|
||||||
|
- Log an eval whenever you validate the quality of something Claude produced (report, audit, plan, generated code).
|
||||||
|
- Action keep - the output is fit for purpose as-is.
|
||||||
|
- Action correct - needs revision; capture what.
|
||||||
|
- Action deprecate - the approach itself is flawed; link to the decision that replaces it.
|
||||||
|
- Entries in English, caveman format (BDR-009): drop articles + filler, fragments OK, technical terms exact.
|
||||||
|
---
|
||||||
|
|
||||||
# Evals
|
# Evals
|
||||||
|
|
||||||
Quality check of Claude output. Caveman + English.
|
Quality check of Claude output. Caveman + English.
|
||||||
|
|||||||
@@ -84,3 +84,82 @@ Local main 15 commits behind develop → worked off develop. install.sh Darwin b
|
|||||||
gaps report), bashrc-osx = bashrc-linux + macOS deltas, dt portable, zsh option (oh-my-zsh + bchanot theme). Tested:
|
gaps report), bashrc-osx = bashrc-linux + macOS deltas, dt portable, zsh option (oh-my-zsh + bchanot theme). Tested:
|
||||||
shellcheck, bash 3.2/5 + zsh -n, bashrc/zshrc/theme live in shells, dt with real dtach session, stub harness both
|
shellcheck, bash 3.2/5 + zsh -n, bashrc/zshrc/theme live in shells, dt with real dtach session, stub harness both
|
||||||
choices. Full install.sh not run on this Mac. BDR-015/016, LRN-014, BLK-007. Merged develop 7d5dabd, not pushed.
|
choices. Full install.sh not run on this Mac. BDR-015/016, LRN-014, BLK-007. Merged develop 7d5dabd, not pushed.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## 2026-10-06 (pm, 2) — tmux keys + Linux
|
||||||
|
Done: tmux.conf fixes (pbcopy, C-a passthrough, is_vim via pane_current_command), pane moves ctrl+u/h/j/k (AZERTY/QWERTY invariant; C-i/C-m = Tab/Enter, rejected), splits prefix i / -, deploy on Linux too (clipboard if-shell: pbcopy else tmux buffer + OSC 52). Verified in Ubuntu 24.04 container. Merged bugfix/tmux-macos-keys → develop (e3be25f).
|
||||||
|
|
||||||
|
## 2026-10-06 (pm, 3) — tmux selection, keep tmux over iTerm2 splits
|
||||||
|
Done: mode-style yellow/black (black bg invisible on dark iTerm2), mouse drag release copies (pbcopy / tmux buffer) without leaving copy-mode. Merged bugfix/tmux-selection → develop (b73ee08). Decided (chat, AskUserQuestion): keep tmux, not iTerm2/Terminator/WezTerm splits — ssh persistence, GNOME Terminal has no splits. BDR offered, not written yet. Wheel issue was a stale iTerm2 session: restart fixed it.
|
||||||
|
|
||||||
|
## 2026-10-06 (pm, 4) — tmux click exit + alt copy/paste
|
||||||
|
Done: plain click leaves copy-mode (MouseUp1Pane cancel; MouseDown cancel was wrong, killed drag after scroll), alt+c = y, alt+v = paste, per OS. Merged bugfix/tmux-click-exit → develop (8b5e936). Open: iTerm2 "Left Option = Esc+" is manual (US Intl PC layout coming); dynamic-profile deploy offered, not asked. GNOME Terminal OSC 52 support unverified.
|
||||||
|
|
||||||
|
## 2026-10-06 (pm, 5) — identity asked at install
|
||||||
|
Done: USER/EMAIL no longer hardcoded in tracked rc files (@USER@/@EMAIL@ placeholders, rendered by install.sh; existing rc export reused, else IDENTITY_* env, else prompt). vimrc reads $USER/$EMAIL. Merged feature/identity-prompt → develop (0687f6a). Open: old values remain in git history (rewrite not done, destructive); deployed ~/.bashrc/.zshrc on this Mac still hold bchanot@gmail.fr.
|
||||||
|
|
||||||
|
## 2026-10-06 — tmux wheel halved, dtach mac/termux checked
|
||||||
|
Done: copy-mode-vi WheelUp/DownPane rebound `-N 2` (stock 5), live reload OK. Merged bugfix/tmux-wheel-half → develop (ec9d0ed). Checked: dtach master on macOS reparents to launchd, survives parent SIGKILL + SIGHUP (sessions outlive shell crash). Termux: dtach 0.9 in official repo, scripts need `pkg install dtach fzf procps`; install.sh NOT Termux-safe (apt-get path); app kill = sessions lost, needs termux-wake-lock. Untested on device.
|
||||||
|
|
||||||
|
## 2026-10-06 (pm, 7) — tmux ctrl+h/j/k/u in copy-mode
|
||||||
|
Done: copy-mode-vi table had stock C-h cursor-left, C-u halfpage-up, C-j copy, so no-prefix pane moves became text nav once scrolled. Four keys rebound select-pane in copy-mode-vi, live reload OK. Merged bugfix/tmux-copy-mode-ctrl-nav → develop (8b6ed6b). Open: deployed ~/.config/tmux/tmux.conf on this Mac predates alt+v/wheel/this fix, `./install.sh` not re-run.
|
||||||
|
|
||||||
|
## 2026-10-06 (pm, 8) — tmux drag "syntax error" in claude panes
|
||||||
|
Done: MouseDrag1Pane binding had `\"` inside '...' (literal since tmux 3.0); branch for mouse-tracking panes (claude fullscreen, vim mouse=a) failed to parse → "syntax error", no selection. Backslashes dropped, pitfall noted in conf. Deployed to ~/.config/tmux/tmux.conf + source-file, live binding verified (`forwarded-to-app`). Merged bugfix/tmux-drag-syntax-error → develop (2245247). Closes the "deployed conf stale" open item.
|
||||||
|
|
||||||
|
## 2026-10-07 — tmux dim inactive panes
|
||||||
|
Done: window-style / window-active-style added. Two traps: colour234 ≈ iTerm2 dark bg (#15191f) → invisible; `window-active-style bg=default` inherits window-style since tmux 3 → active pane dimmed too, terminal colours hardcoded instead (fg #dcdcdc, bg #15191f). Inactive settled at #353d48 / #a6acb6 after 3 live rounds. Light macOS theme would need the inverse. Merged feature/tmux-dim-inactive-panes → develop.
|
||||||
|
|
||||||
|
## 2026-10-07 (pm) — repo-sync: multi-forge repo tree
|
||||||
|
Done: `bin/repo-sync` (gitlab/github/gitea/bitbucket cloud via curl+jq, daily cache, mkdir lock, dedup ns/project) + `repo` fn/completion in 3 rc files + install.sh jq + docs. Port of Alphalink dotfiles `repo`/`repo-reset`. Stub-curl harness caught token shift (IFS tab merges empty field); live GitLab 139 projects in 3s. Decided (chat): name `repo-sync`, tokens in `~/.config/repos/forges.conf` 0600, root `~/repos`, Bitbucket Cloud only. On feature/repo-sync, not finished. BDR/LRN offered, not written.
|
||||||
|
|
||||||
|
## 2026-10-07 (2) — macOS zsh default, remote-install prompts
|
||||||
|
Done: choose_macos_shell default bash → zsh (Enter, no tty, unknown value). Found: `curl | bash` path never asked USER/EMAIL (stdin = pipe → `[ -t 0 ]` false → login name + empty email, bash, no offers); remote-install.sh now runs install.sh `</dev/tty` when openable. Found: BRANCH default `master`, origin has only `main` (raw URL 404) → `main`. Lint OK, chooser tested 4 values. Branch feature/macos-zsh-default, not merged. Other session: feature/repo-sync open (CLAUDE.md layout already lists repo-sync).
|
||||||
|
|
||||||
|
## 2026-10-07 (3) — gitflow.autopush asked at install, hooksPath fixed, identity bug
|
||||||
|
Done: `gitconfig` template `[gitflow] autopush = @AUTOPUSH@` + fixed `core.hooksPath = ~/.claude/githooks`; install.sh `resolve_autopush` (existing ~/.gitconfig value via sed → `DOTFILES_GITFLOW_AUTOPUSH` strict, bad value aborts → prompt re-asks exact true/false, Enter = true → true), `render_gitconfig` fail-closed (non-boolean / leaked placeholder = nothing written). Found by challenge: install.sh:688 passed the repo bashrc TEMPLATE to deploy_gitconfig → every install wrote `name = @USER@`; fixed, identity passed directly. `shopt -u patsub_replacement` (bash ≥ 5.2 `&` in names). Oracle harness `.claude/tasks/contracts/check-autopush-render.sh` (12 cases, scratch HOMEs, zero `git config`: that command family is denied to the session). 3 challengers + 1 confirm, verifier ECARTS(1) → CONFORME, security PASS (MEDIUM noted: newline in IDENTITY_* env injects gitconfig lines, pre-existing for rc too). Code commit 9901ec5 on feature/gitconfig-autopush; merge on user signal.
|
||||||
|
|
||||||
|
## 2026-10-09 — rootless Docker offered at install
|
||||||
|
Done: `offer_docker_rootless()` (uidmap/dbus-user-session/slirp4netns/docker-ce-rootless-extras, `dockerd-rootless-setuptool.sh install` no --force, enable-linger, rootful daemon disabled first as the docs recommend, user asked for it), extras in install_docker list, bashrc-linux exports DOCKER_HOST only when the user socket exists (no PATH line: apt variant puts the tool in /usr/bin, not ~/bin). README step 16. Stub harness 4 cases + snippet with/without socket OK, shellcheck clean. Branch feature/docker-rootless, not merged. Machine state: rootless already set up by hand, rootful daemon still enabled, ~/.bashrc has a hardcoded uid 1000 DOCKER_HOST line (redeploy replaces it).
|
||||||
|
|
||||||
|
## 2026-10-09 (2) — tmux pane moves + hooks fail-closed merged
|
||||||
|
Done: `tmux.conf` J/L join-pane, S swap-pane, ( ) repeatable swap-pane -U/-D (AZERTY-friendly); CHANGELOG Unreleased (Added tmux, Changed hooks). Hooks fail-closed commit turned out identical to the one already on origin/develop via feature/docker-rootless (other machine): merged clean, net diff = tmux.conf + CHANGELOG only. feature/tmux-pane-moves-hooks-failclosed finished into develop on user signal. Manual push mode: develop ahead of origin by 3, user pushes. Note: docker-rootless landed without a CHANGELOG line.
|
||||||
|
|
||||||
|
## 2026-10-09 (3) — tmux status tabs centred + widened
|
||||||
|
Done: `status-justify absolute-centre`, separator ' ', window-status formats ` #I #W ` (current bold on light pill). Applied live via `tmux set`, deployed copy to ~/.config/tmux/tmux.conf (install.sh cp semantics). User picked "pastilles larges" over 2-line bar. feature/tmux-status-tabs finished into develop on user signal; manual push, user pushes.
|
||||||
|
|
||||||
|
## 2026-10-09 (4) — tmux: any bare key leaves copy-mode after a mouse selection
|
||||||
|
Done: `bin/tmux-copy-exit-keys` (wraps 120 copy-mode-vi keys behind `@mouse_sel`, idempotent, bash 3.2), tmux.conf marker on MouseDragEnd1Pane + pane-mode-changed hook + run-shell after tpm, install.sh chmod, README/CLAUDE.md/CHANGELOG. Chosen: mouse-only scope, key swallowed. 6 headless tests pass, full conf reload OK. LRN-017. Session 12 window 0 (zsh) vanished during the run, not targeted by any command, flagged to user. Merged on signal; manual push.
|
||||||
|
|
||||||
|
## 2026-10-09 (5) — tmux Alt+arrow window switch
|
||||||
|
Done: `bind -n M-Left/M-Right previous/next-window` (status on, mirrors C-n/C-p). macOS: iTerm2 Option = Normal sends Esc b/f, so Cmd+arrow must be mapped by hand to `[1;3D`/`[1;3C` (profile Default); shadows iTerm2 tab switch on Cmd+arrow permanently, user informed. Merged on signal; manual push.
|
||||||
|
|
||||||
|
## 2026-10-09 (6) — tmux Ctrl+Alt+arrow panes + README key-mapping table
|
||||||
|
Done: `bind -n C-M-Up/Down/Left/Right select-pane` (root + copy-mode-vi, no vim pass-through). README "Terminal key mappings for tmux": iTerm2 Send Escape Sequence table (Cmd+arrow `[1;3D/C`, Ctrl+Cmd+arrow `[1;7A/B/D/C`), Linux notes (native, GNOME workspace shortcut may grab Ctrl+Alt+arrow, unverified). Merged on signal; manual push.
|
||||||
|
|
||||||
|
## 2026-10-11 — desktop + RDP offered, WSL default no
|
||||||
|
Done: `offer_desktop()` (desktop [Y/n] → RDP [Y/n], WSL → [y/N] + hint), `confirm` default arg, `is_wsl()`. Trigger: WSL install lost DNS mid-run after ubuntu-desktop-minimal (hypothesis: NetworkManager/systemd-resolved rewrote /etc/resolv.conf), fail2ban/whois fetch failed. 8-case stub harness OK, shellcheck clean. Branch feature/desktop-rdp-prompt, commit 5d60269, pushed, not merged.
|
||||||
|
|
||||||
|
## 2026-10-12 — WSL DNS confirmed + sshd hardening abort fixed
|
||||||
|
Done: WSL DNS root cause confirmed (ubuntu-desktop-minimal → systemd-resolved/NetworkManager rewrote resolv.conf); repair runbook (disable both, rm resolv.conf, `wsl --shutdown`) worked. Then install aborted at harden_sshd: `systemctl reload ssh` on inactive unit + `set -e`. Fix 64f06bb on bugfix/sshd-reload-inactive: `is-active` guard + `try-reload-or-restart`, `/run/sshd` created before `sshd -t` (Ubuntu 24.04: privsep dir exists only while ssh.service runs — challenge correctness MAJOR). Stub smoke both branches, shellcheck, semgrep PASS. Not merged.
|
||||||
|
|
||||||
|
## 2026-10-12 (2) — Rust toolchain at install
|
||||||
|
Done: `install_rust()` (rustup official script, user-level, stable + default profile + rust-analyzer/rust-src, `rustup update` on re-run, `--no-modify-path`), `libssl-dev`/`openssl@3`, 3 rc files source `~/.cargo/env` (if form, rc 0 when absent). Trigger: `~/.cargo` existed on this machine, nothing on PATH. Stub harness 2 paths + PATH dedup OK, shellcheck clean. Commit 7d62da4 on feature/rust-toolchain, pushed, not merged. zsh snippet untested (no zsh here), POSIX syntax.
|
||||||
|
|
||||||
|
## 2026-10-15 — SSH login → tmux before dtach menu
|
||||||
|
Done: 3 rc files exec `tmux new-session -A -s main` on interactive SSH (not in tmux, not vscode), before dtach-router; router now opens inside tmux. Stub-tmux harness OK on bash; zsh absent here, zsh block untested. Branch feature/tmux-before-router, not finished (needs signal).
|
||||||
|
|
||||||
|
## 2026-10-15 (2) — tmux-before-router fix not live: ~/.bashrc never redeployed
|
||||||
|
Done: feature merged in develop but ~/.bashrc predated it (only install.sh writes it); diff template vs deployed = tmux block only. User copied rendered template to ~/.bashrc; stub-tmux sim + real SSH login confirmed tmux opens before dtach menu. No repo code change.
|
||||||
|
|
||||||
|
## 2026-10-30
|
||||||
|
- Memory registries → v2 (`memory.sh upgrade`, claude-config BDR-129 phase 4a): `check` green, open blockers unchanged.
|
||||||
|
|
||||||
|
## 2026-11-13
|
||||||
|
- tmux prefix < > move window left/right (f92b026, feature/tmux-move-window). v1 swap-only reverted: focus stayed on slot; v2 adds select-window. CHANGELOG entry.
|
||||||
|
- tmux multi-tab highlight fixed (702f4a2, bugfix/tmux-bell-highlight): bell-action none dropped bells, monitor-bell still flagged bg tabs reverse. Now bell-action any + window-status-bell-style default. Live server patched via tmux set; deployed copy needs install.sh + prefix R.
|
||||||
@@ -1,3 +1,20 @@
|
|||||||
|
---
|
||||||
|
format: 2
|
||||||
|
type: learnings_registry
|
||||||
|
entry_prefix: LRN
|
||||||
|
schema:
|
||||||
|
id: LRN-XXX
|
||||||
|
date: YYYY-MM-DD
|
||||||
|
pattern: string (what was observed, abstracted)
|
||||||
|
context: string (where/when it happened - concrete)
|
||||||
|
future_application: string (when to recall this)
|
||||||
|
rules:
|
||||||
|
- Capture learnings that apply beyond the current task.
|
||||||
|
- Abstract from the incident - the pattern is what is reusable, not the one-shot fact.
|
||||||
|
- Link to source (commit, file, PR) when possible.
|
||||||
|
- Entries in English, caveman format (BDR-009): drop articles + filler, fragments OK, technical terms exact.
|
||||||
|
---
|
||||||
|
|
||||||
# Learnings
|
# Learnings
|
||||||
|
|
||||||
Reusable patterns. Caveman + English.
|
Reusable patterns. Caveman + English.
|
||||||
@@ -108,3 +125,55 @@ locale = comma); no `date -d` → `date -j -f '%a %b %e %T %Y'` with `LC_ALL=C p
|
|||||||
`lsof -a -p PID -d cwd -Fn`. bash 3.2 `${x/#$HOME/\~}` keeps backslash → use var `tilde='~'`. BSD sed no `\?` in BRE
|
`lsof -a -p PID -d cwd -Fn`. bash 3.2 `${x/#$HOME/\~}` keeps backslash → use var `tilde='~'`. BSD sed no `\?` in BRE
|
||||||
→ `sed -E`. Terminal.app = LOGIN shells → read ~/.bash_profile only → must source ~/.bashrc. `ls --color` → `ls -G`.
|
→ `sed -E`. Terminal.app = LOGIN shells → read ~/.bash_profile only → must source ~/.bashrc. `ls --color` → `ls -G`.
|
||||||
zsh: `status` is read-only special var, don't name locals that. Verify installer fns via stub harness (LRN-011).
|
zsh: `status` is read-only special var, don't name locals that. Verify installer fns via stub harness (LRN-011).
|
||||||
|
|
||||||
|
## LRN-015 — tmux pane styles: "default" in window-active-style inherits window-style
|
||||||
|
2026-10-07. tmux ≥ 3: `window-active-style bg=default` = window-style bg, NOT terminal bg → active pane dimmed
|
||||||
|
too. Dim inactive panes → active style must hardcode terminal fg/bg (iTerm2 dark: `fg=#dcdcdc,bg=#15191f`).
|
||||||
|
Pick inactive bg far from terminal bg (colour234 ≈ #15191f → invisible). iTerm2 colours: plist
|
||||||
|
`New Bookmarks[].Background Color (Dark)` when "separate light/dark" on + macOS dark mode, not `Background Color`.
|
||||||
|
Tune live: `tmux set -g window-style ...` then copy to conf. Hardcoded bg = update when iTerm2 theme changes.
|
||||||
|
|
||||||
|
## LRN-016 — template passed where rendered file expected: placeholders pass every "non-empty" guard
|
||||||
|
2026-10-07. install.sh:688 called `deploy_gitconfig "$SCRIPT_DIR/$bashrc"` (repo TEMPLATE) after identity went
|
||||||
|
to `@USER@` placeholders; `rc_export_value` returned `@USER@`, non-empty → guard passed → every install wrote
|
||||||
|
`name = @USER@`. Harness tested the function with hand-made rc, never the call site → green while broken. Found
|
||||||
|
by plan-challenger reading `git log -L` on the call site. Apply: pass resolved values, not file paths, across a
|
||||||
|
render boundary; oracle greps the call site (Case H) and asserts `! grep '@(USER|EMAIL|AUTOPUSH)@'` on output;
|
||||||
|
reject placeholder-shaped values like empty ones. Bonus: `shopt -u patsub_replacement` before `${v//p/$r}` on
|
||||||
|
bash ≥ 5.2 (`&` expands to match).
|
||||||
|
|
||||||
|
## LRN-017 — tmux: conf key names, list-keys, hooks, headless key tests
|
||||||
|
2026-10-09. Found while building `bin/tmux-copy-exit-keys` (tmux 3.7c). (1) Key `~` in a sourced conf must be
|
||||||
|
`\~`: parser tilde-expands bare `~` → key `/Users/x`, "unknown key". Same escape set as list-keys prints:
|
||||||
|
`; { } # $ % " ' \ ~`. (2) `list-keys -T <table> <key>` does not filter in 3.7 (prints nothing, or whole table
|
||||||
|
when key is `;`): dump the table once, grep/awk the key token. (3) Hooks (`pane-mode-changed`) run with the
|
||||||
|
triggering pane as target: `set -pu @opt` needs no `-t`; `#{hook_pane}` quoting inside nested strings broke.
|
||||||
|
(4) `send-keys <key>` to a pane in copy-mode dispatches through the mode key table → key-binding behaviour is
|
||||||
|
testable headless on a scratch pane (`new-window -d -P -F '#{pane_id}'`, assert `#{pane_in_mode}`); address
|
||||||
|
by pane id, window-name plugin renames `-n` names. (5) `\;` inside tmux.conf '...' stays literal, then splits
|
||||||
|
a bind's command list when the string is parsed by if-shell: works, no need to convert to `{ }` blocks.
|
||||||
|
|
||||||
|
## LRN-018 — systemctl under `set -e`: guard reload, create /run/sshd before `sshd -t`
|
||||||
|
2026-10-12. Found fixing install.sh `harden_sshd` on WSL (commit 64f06bb). (1) Bare `systemctl reload <unit>`
|
||||||
|
exits non-zero when unit inactive ("<unit> is not active, cannot reload.") → `set -e` kills installer. Guard:
|
||||||
|
`if systemctl is-active --quiet <unit>; then sudo systemctl try-reload-or-restart <unit>; else echo ...; fi`.
|
||||||
|
`try-reload-or-restart` exits 0 if unit stopped between check and call (no TOCTOU abort); `is-active` needs no
|
||||||
|
sudo, inside `if` never trips `set -e`. `restart` on inactive unit starts it, different semantic. (2) Ubuntu 24.04
|
||||||
|
(systemd 255): `/run/sshd` created only by ssh.service `RuntimeDirectory=sshd`, no tmpfiles rule (systemd ≥ 256
|
||||||
|
adds `20-systemd-ssh-generator.conf`). sshd never started → `sudo sshd -t` fails "Missing privilege separation
|
||||||
|
directory" → looks like config rejection. `sudo install -d -m 0755 /run/sshd` before `sshd -t`, idempotent.
|
||||||
|
(3) WSL: no sshd running by default, unit socket-activated or never started → any installer "validate + reload"
|
||||||
|
path must survive inactive unit. Stub `systemctl`/`sudo`/`sshd` on PATH in scratchpad to smoke both branches.
|
||||||
|
|
||||||
|
## LRN-019 — rc change merged is not live until redeployed
|
||||||
|
Context: tmux-before-router merged in develop, SSH still showed dtach menu first. ~/.bashrc written only by install.sh (rendered template), predated merge.
|
||||||
|
Pattern: after any bash/ or zsh/ edit, redeploy (install.sh, or render template and copy), then diff template vs deployed.
|
||||||
|
Apply: "fix not working" after merge → diff deployed rc vs template first.
|
||||||
|
|
||||||
|
## LRN-020 — tmux swap-window focus stays on slot, not moved window (2026-11-13)
|
||||||
|
2026-11-13, tmux 3.6. `swap-window -t -1` without `-d` keeps focus on current INDEX: window swapped into that slot becomes current, moved window loses focus. Man "new window becomes current" misread as "moved window". Move-window binding needs `swap-window -t -1 \; select-window -t -1` (same for +1). Relative offsets wrap at list ends (first window + `<` swaps with last). Verify headless: scratch socket `-L`, `new-window -t t:` (bare `-t t` → "index 0 in use"), compare `#{window_index} #{window_id} #{window_active}` before/after; names unreliable (plugin renames). See LRN-017 for key tests.
|
||||||
|
|
||||||
|
## LRN-021 — tmux bell-action vs monitor-bell: flag highlights even when bells dropped (2026-11-13)
|
||||||
|
Context: tmux tabs often highlighted several at once + no bell heard since tmux. Cause tmux.conf `bell-action none`.
|
||||||
|
Pattern: `bell-action` only gates forwarding bell to terminal. Tab flag set by `monitor-bell` (default on) regardless, styled by `window-status-bell-style` (default reverse) until window visited. alerts_check_bell() returns early when monitor-bell off → no bell sent at all.
|
||||||
|
Apply: silence + no highlight → `setw -g monitor-bell off`. Sound + no highlight → `bell-action any` + `window-status-bell-style default`, monitor-bell stays on. Unattached sessions never ring. Repo edit not live until deployed copy ~/.config/tmux/tmux.conf refreshed + prefix R (LRN-019).
|
||||||
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
<!-- Generated by /onboard (right-sized). One entry per finding. -->
|
<!-- Generated by /onboard (right-sized). One entry per finding. -->
|
||||||
|
|
||||||
|
## Actionable
|
||||||
|
<!-- next items; the session digest shows the first 3 unchecked (else the first 3 of the file) -->
|
||||||
|
|
||||||
## Done this session
|
## Done this session
|
||||||
- [x] [P0] Fix install.sh broken /tmp/config paths (server+osx silent fail)
|
- [x] [P0] Fix install.sh broken /tmp/config paths (server+osx silent fail)
|
||||||
- [x] [P0] Fix bashism under #!/bin/sh → bash + set -euo pipefail
|
- [x] [P0] Fix bashism under #!/bin/sh → bash + set -euo pipefail
|
||||||
@@ -99,3 +102,92 @@ Same branch. Prompt at start of Darwin block (MACOS_SHELL=bash|zsh env overrides
|
|||||||
- [x] README + CLAUDE.md layout
|
- [x] README + CLAUDE.md layout
|
||||||
- [x] Verify: shellcheck, bash -n, render to temp HOME, `git config --file` reads values
|
- [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)
|
- [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
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
## Feature — identity asked at install, no hardcoded USER/EMAIL in tracked rc files (2026-10-06)
|
||||||
|
Branch: feature/identity-prompt (off develop). Values were visible to anyone reading the repo.
|
||||||
|
- [x] rc templates (bashrc-linux, bashrc-osx, zshrc-osx): `export USER="@USER@"` / `export EMAIL="@EMAIL@"`
|
||||||
|
- [x] install.sh resolve_identity: existing ~/.bashrc / ~/.zshrc export wins silently → IDENTITY_USER/IDENTITY_EMAIL env → prompt (TTY) → default (id -un, empty email)
|
||||||
|
- [x] install.sh: render_identity_template (generic, replaces render_gitconfig); bashrc + zshrc rendered, gitconfig unchanged (reads the rendered bashrc)
|
||||||
|
- [x] vim/vimrc: g:_author / g:_email from $USER / $EMAIL
|
||||||
|
- [x] README, CLAUDE.md (CHANGELOG left to the release step, like the tmux work)
|
||||||
|
- [x] Verify: shellcheck, bash -n, zsh -n; temp-HOME render (env preset, existing rc reuse); vim reads the env
|
||||||
|
|
||||||
|
## Feature — repo-sync: one local tree for every reachable git repo, multi-forge (2026-10-07)
|
||||||
|
Branch: feature/repo-sync (off develop). Design approved in chat: name `repo-sync`, tokens in
|
||||||
|
`~/.config/repos/forges.conf` 0600 (never tracked), root `~/repos`, Bitbucket Cloud only.
|
||||||
|
Port of the Alphalink dotfiles `repo` / `repo-reset` zsh functions, bash + zsh, Linux + macOS.
|
||||||
|
- [x] bin/repo-sync — add / refresh (daily, mkdir lock) / list / tree / path / clone; curl + jq
|
||||||
|
fetchers for gitlab, github (+GHES), gitea/forgejo, bitbucket cloud; dedup namespace/project
|
||||||
|
- [x] bash/bashrc-linux, bash/bashrc-osx, zsh/zshrc-osx — `repo` function (cd), completion, background refresh
|
||||||
|
- [x] install.sh — jq in apt + brew lists, chmod repo-sync
|
||||||
|
- [x] README.md (table + CLI section) + CLAUDE.md layout
|
||||||
|
- [x] shellcheck + bash -n; stub-curl harness per forge (fixtures), live GitLab run
|
||||||
|
- [ ] commit on feature branch; registries. No finish without explicit signal.
|
||||||
|
|
||||||
|
## Feature — gitflow.autopush asked at install, written to ~/.gitconfig (2026-10-07)
|
||||||
|
Branch: feature/gitconfig-autopush (off develop). Plan: .claude/tasks/plans/2026-10-07-gitconfig-autopush-1734.md
|
||||||
|
- [ ] /feat run: gitconfig `[gitflow] autopush = @AUTOPUSH@` + fixed `core.hooksPath`; install.sh `resolve_autopush` (exact true/false: existing ~/.gitconfig value via sed → DOTFILES_GITFLOW_AUTOPUSH (bad value aborts) → prompt re-asks → true), deploy_gitconfig takes name/email/autopush (fixes `name = @USER@` deployed from the template path) + fail-closed leak check; README/CLAUDE.md; oracle harness .claude/tasks/contracts/check-autopush-render.sh
|
||||||
|
|
||||||
|
## Feature — Docker rootless offered at install (2026-10-09)
|
||||||
|
Branch: feature/docker-rootless (off develop). Mirrors the manual setup done on this machine
|
||||||
|
(docs.docker.com/engine/security/rootless, apt variant: setuptool lives in /usr/bin, not ~/bin).
|
||||||
|
- [x] install.sh: `docker-ce-rootless-extras` in the install_docker package list
|
||||||
|
- [x] install.sh: offer_docker_rootless() — uidmap/dbus-user-session/slirp4netns + extras, setuptool install (no --force), enable-linger; rootful daemon disabled first
|
||||||
|
- [x] bash/bashrc-linux: DOCKER_HOST exported only when the rootless socket exists (no PATH line: /usr/bin already on PATH)
|
||||||
|
- [x] README.md: table row, step 2 packages, packages list, new offer step
|
||||||
|
- [x] shellcheck + bash -n; commit on the feature branch. No finish without explicit signal.
|
||||||
|
|
||||||
|
## Feature — tmux: any bare key leaves copy-mode after a mouse selection (2026-10-09)
|
||||||
|
Branch: feature/tmux-copy-exit-keys (off develop). Chosen in chat: only after a mouse drag (keyboard/wheel copy-mode keeps vi keys), key swallowed.
|
||||||
|
- [x] bin/tmux-copy-exit-keys — wraps every unmodified copy-mode-vi key in `if -F '#{@mouse_sel}' {cancel} {orig}`, re-runnable, bash 3.2
|
||||||
|
- [x] tmux.conf — MouseDragEnd1Pane sets `@mouse_sel` (both clipboard branches), pane-mode-changed hook clears it, run-shell after tpm
|
||||||
|
- [x] install.sh chmod list + CLAUDE.md layout + README (bin table, step 8) + CHANGELOG
|
||||||
|
- [x] Live test on the running server: marker → g exits; no marker → k stays, q exits; marker → C-u stays; script idempotent
|
||||||
|
|
||||||
|
## Feature — desktop + RDP offered, not forced; WSL default no (2026-10-11)
|
||||||
|
Branch: feature/desktop-rdp-prompt (off develop). Trigger: WSL install lost DNS mid-run
|
||||||
|
after ubuntu-desktop-minimal (hypothesis: NetworkManager/systemd-resolved rewrote
|
||||||
|
/etc/resolv.conf); desktop + RDP useless on WSL anyway.
|
||||||
|
- [x] install.sh: `is_wsl()` (WSL_DISTRO_NAME or /proc/version)
|
||||||
|
- [x] install.sh: `confirm` optional default `y` ([Y/n], no tty → default)
|
||||||
|
- [x] install.sh: `offer_desktop()` — desktop [Y/n] then RDP [Y/n]; WSL → both default n with hint
|
||||||
|
- [x] README step 11 + table + packages line; CHANGELOG Unreleased
|
||||||
|
- [x] shellcheck + bash -n + stub harness for confirm defaults / WSL branch
|
||||||
|
|
||||||
|
## Feature — Rust toolchain installed at install (2026-10-12)
|
||||||
|
Branch: feature/rust-toolchain (off develop). rustup official script, both OSes, as the user,
|
||||||
|
`--no-modify-path` (the rc files source `~/.cargo/env` themselves); apt rustc too old, brew rust has no rustup.
|
||||||
|
- [x] install.sh: `install_rust()` — rustup install (stable, default profile) or `rustup update` when present; `component add rust-analyzer rust-src`
|
||||||
|
- [x] install.sh: `libssl-dev` (apt) / `openssl@3` (brew) so openssl-sys crates build
|
||||||
|
- [x] bash/bashrc-linux, bash/bashrc-osx, zsh/zshrc-osx: source `~/.cargo/env` when present (PATH, dedup inside)
|
||||||
|
- [x] README (step, packages lines, table), CHANGELOG Unreleased, CLAUDE.md layout line
|
||||||
|
- [x] shellcheck + bash -n + stub harness (fresh HOME: install path, re-run path); commit on the branch, no finish without signal
|
||||||
|
|
||||||
|
## Feature — SSH login enters tmux before dtach-router (2026-10-15)
|
||||||
|
Branch: feature/tmux-before-router (off develop). User always runs tmux now, so the router
|
||||||
|
menu at plain-SSH login had to be quit once, then reopened inside tmux. Approved in chat:
|
||||||
|
shared session `main` (`new-session -A`), VS Code Remote-SSH excluded, all three rc files.
|
||||||
|
- [x] bash/bashrc-linux, bash/bashrc-osx, zsh/zshrc-osx: interactive + SSH + not in tmux + not vscode → `exec tmux new-session -A -s main`, just before the router line
|
||||||
|
- [x] shellcheck + bash -n + guard harness (env combos, tmux stubbed); zsh absent here, zsh block untested
|
||||||
|
|
||||||
|
## Feature — `openrouter` rc function replaces claude-provider (2026-10-28)
|
||||||
|
Branch: feature/openrouter-toggle (off develop). Shell function (bash + zsh): `openrouter` on, `-d`/`-u` off, key from `$OPENROUTER_API_KEY`.
|
||||||
|
- [x] bashrc-linux, bashrc-osx, zshrc-osx: `openrouter()`; snapshot of the 4 vars' prior values in `$_OPENROUTER_SAVED`, replayed on off
|
||||||
|
- [x] log out / log in reminders on on / off
|
||||||
|
- [x] remove bin/claude-provider + install.sh, README, CLAUDE.md refs; CHANGELOG Added/Removed
|
||||||
|
- [x] bash -n + harness (quoted value restore, unset restore, not-active, double on); zsh block untested (zsh absent)
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
# CONTRACT — gitconfig-autopush
|
||||||
|
- date: 2026-10-07 | flow: feat | branch: develop → feature/gitconfig-autopush
|
||||||
|
- status: active
|
||||||
|
|
||||||
|
## REQUEST (verbatim — IMMUTABLE)
|
||||||
|
est-ce qu'on deploi un gitconfig ? Oui peut-on faire en sorte de demander a l'installation si on ajoute git config --global gitflow.autopush false ou git config --global gitflow.autopush true . Au choix a l'installation et mis dnas le gitconfig. d'ailleurs on a bien le user et le mail dnas le gitconfig aui sont bien ceux qu'on configure a l'installation ?
|
||||||
|
|
||||||
|
## CLARIFICATIONS
|
||||||
|
Q: Default when Enter is pressed or no terminal is attached? / A: `true` [gated 2026-10-07] — confirmed by the user's correction after the second message ("non pardon je voulais dire defaut true").
|
||||||
|
Q: Env preset name? / A: `GITFLOW_AUTOPUSH` [gated 2026-10-07] — SUPERSEDED by the user spec: `DOTFILES_GITFLOW_AUTOPUSH`.
|
||||||
|
Q: install.sh:688 passes the repo template to deploy_gitconfig, so ~/.gitconfig gets `name = @USER@`; fix in this run? / A: yes, deploy_gitconfig takes the resolved name/email/autopush [gated 2026-10-07]
|
||||||
|
Q: redeploy drops `core.hooksPath` (set by `make link`)? / A: warn + note [gated 2026-10-07] — SUPERSEDED by the user spec: fixed template line `hooksPath = ~/.claude/githooks` in `[core]`, git expands `~`, the installer neither creates nor checks the directory.
|
||||||
|
Q: how is an existing value read, given `git config … gitflow.*` is denied to this session? / A: sed over ~/.gitconfig, exact true/false reused silently; no git config access in installer or oracle [gated 2026-10-07]
|
||||||
|
USER SPEC (second message, 2026-10-07, verbatim constraints) [gated 2026-10-07]:
|
||||||
|
- Question at install: « Push automatique des commits par les hooks gitflow sur cette machine ? [true/false] » default true (corrected from the spec's "défaut : false" by the user's next message). Rendered in English like the other install prompts; wording open to change at the diff review.
|
||||||
|
- Only the exact values `true` and `false` are accepted; anything else re-asks; empty → `true`.
|
||||||
|
- The render fails explicitly if `@AUTOPUSH@` remains in the final content (grep after render); nothing written.
|
||||||
|
- Non-interactive: `DOTFILES_GITFLOW_AUTOPUSH=true|false`, default true. (Orchestrator choice, flagged for the diff review: any other preset value aborts the install at the identity step, before any file is touched.)
|
||||||
|
- Keep the existing backup `~/.gitconfig.backup-<timestamp>`; no other template section touched.
|
||||||
|
- No test suite / no --dry-run exists: the oracle harness carries the two requested cases (rendered @AUTOPUSH@, leaked placeholder = failure).
|
||||||
|
- The user sees the full diff before anything is committed.
|
||||||
|
|
||||||
|
## ACCEPTANCE CRITERIA
|
||||||
|
1. `gitconfig` template: `[gitflow]` section with `autopush = @AUTOPUSH@`, and `hooksPath = ~/.claude/githooks` inside `[core]`; other sections unchanged except the header comment.
|
||||||
|
CHECK: grep -q '^\[gitflow\]' gitconfig && grep -q '^ autopush = @AUTOPUSH@' gitconfig && grep -q '^ hooksPath = ~/.claude/githooks' gitconfig && echo GITCONFIG_TEMPLATE_OK
|
||||||
|
EXPECT: GITCONFIG_TEMPLATE_OK
|
||||||
|
EVIDENCE: MET exit=0 marker-found :: GITCONFIG_TEMPLATE_OK
|
||||||
|
2. `install.sh` resolves the push mode: an exact `true`/`false` already in ~/.gitconfig wins silently; else `DOTFILES_GITFLOW_AUTOPUSH` (exact true/false; any other value aborts with a message); else a tty prompt accepting only `true`/`false`, re-asking otherwise, Enter = `true`; else `true`.
|
||||||
|
3. Oracle harness: rendered file carries the resolved autopush, name, email, hooksPath and no placeholder; a leaked `@AUTOPUSH@` makes deploy_gitconfig fail without writing; existing value beats the preset; strict preset; prompt loop; empty email skip; idempotent re-run.
|
||||||
|
CHECK: bash .claude/tasks/contracts/check-autopush-render.sh
|
||||||
|
EXPECT: AUTOPUSH_RENDER_OK
|
||||||
|
EVIDENCE: MET exit=0 marker-found :: AUTOPUSH_RENDER_OK
|
||||||
|
4. install.sh stays syntactically valid and shellcheck clean.
|
||||||
|
CHECK: bash -n install.sh && shellcheck install.sh && echo LINT_OK
|
||||||
|
EXPECT: LINT_OK
|
||||||
|
EVIDENCE: MET exit=0 marker-found :: LINT_OK
|
||||||
|
5. README.md (gitconfig row, remote-install question list, install step 6) and CLAUDE.md layout line document the question, the strict values, the env preset, the reuse of an existing value and the fixed hooksPath.
|
||||||
|
6. Call site passes the resolved identity, never the repo template path.
|
||||||
|
CHECK: grep -q 'deploy_gitconfig "\$identity_name" "\$identity_email" "\$autopush"' install.sh && ! grep -q 'deploy_gitconfig "\$SCRIPT_DIR' install.sh && echo CALLSITE_OK
|
||||||
|
EXPECT: CALLSITE_OK
|
||||||
|
EVIDENCE: MET exit=0 marker-found :: CALLSITE_OK
|
||||||
|
7. `.githooks/post-commit` and `.githooks/post-merge` are not part of the change (pre-existing session-hook refresh).
|
||||||
|
CHECK: git diff --cached --name-only | grep -q '^\.githooks/' && exit 1; echo HOOKS_UNTOUCHED
|
||||||
|
EXPECT: HOOKS_UNTOUCHED
|
||||||
|
EVIDENCE: MET exit=0 marker-found :: HOOKS_UNTOUCHED
|
||||||
|
|
||||||
|
## FILE SCOPE
|
||||||
|
gitconfig, install.sh, README.md, CLAUDE.md, .claude/tasks/contracts/check-autopush-render.sh (oracle harness, LRN-011 pattern)
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# CONTRACT — sshd-reload-inactive
|
||||||
|
- date: 2026-10-12 | flow: hotfix | branch: bugfix/sshd-reload-inactive
|
||||||
|
- status: active
|
||||||
|
|
||||||
|
## REQUEST (verbatim — IMMUTABLE)
|
||||||
|
install.sh harden_sshd: `sudo systemctl reload ssh` fails under set -e when ssh.service is not active (WSL, socket-activated or never started) → "ssh.service is not active, cannot reload." aborts the whole install. Fix: reload only if `systemctl is-active --quiet ssh`, otherwise print that the drop-in is in place and applies at the next sshd start. Keep shellcheck clean, tabs.
|
||||||
|
|
||||||
|
User message: "ok ca a fonctionne, par contre maintenant je bloque a Deploying sshd hardening drop-in
|
||||||
|
ssh.service is not active, cannot reload.. je sais pas si c'es tpour installer ssh-server ? Si oui demande aussi pour l'installer, si non il bloque pour quoi ?"
|
||||||
|
|
||||||
|
## CLARIFICATIONS
|
||||||
|
none — request complete (openssh-server is already in the apt list; the block is the unconditional reload)
|
||||||
|
|
||||||
|
## ACCEPTANCE CRITERIA
|
||||||
|
1. Symptom gone: harden_sshd no longer aborts the install when ssh.service is inactive (reload guarded by `systemctl is-active --quiet ssh`, else an informative echo).
|
||||||
|
2. Build/tests green: `bash -n install.sh` and `shellcheck install.sh` pass; indentation stays tabs.
|
||||||
|
|
||||||
|
## FILE SCOPE
|
||||||
|
install.sh (harden_sshd only)
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# CONTRACT — tmux-bell-highlight
|
||||||
|
- date: 2026-11-13 | flow: hotfix | branch: bugfix/tmux-bell-highlight
|
||||||
|
|
||||||
|
## REQUEST (verbatim — IMMUTABLE)
|
||||||
|
il y a un petit probleme dans les onglet tmux, sur le highlight des onlget, il y a souvent plusieurs onglet qui sont highlight plutot que juste l'onglet courant
|
||||||
|
→ "j'ai plus de bells depuis que je suis passe a tmux"
|
||||||
|
|
||||||
|
## CLARIFICATIONS
|
||||||
|
Q: bell behaviour? / A: sound back, no tab highlight ("Son, sans highlight") [gated 2026-11-13]
|
||||||
|
Q: dirty .githooks/pre-commit? / A: leave it, targeted commit of tmux.conf only [gated 2026-11-13]
|
||||||
|
Note: bell-action `any` (tmux default, all windows ring = pre-tmux behaviour) instead of
|
||||||
|
`other` offered in the question: `other` would silence the current tab. Deviation reported to user.
|
||||||
|
|
||||||
|
## ACCEPTANCE CRITERIA
|
||||||
|
1. tmux.conf loads clean; bell-action any; window-status-bell-style default
|
||||||
|
CHECK: bare scratch server (no tpm/continuum restore), only the bell lines applied:
|
||||||
|
tmux -L bellchk -f /dev/null new-session -d -s t; grep -E '^set(w)? .*bell' tmux.conf | sed 's/ *#.*//' | while read -r l; do eval "tmux -L bellchk $l"; done; tmux -L bellchk show -gv bell-action; tmux -L bellchk show -gwv window-status-bell-style; tmux -L bellchk kill-server
|
||||||
|
EXPECT: any / default
|
||||||
|
2. Only tmux.conf changed by this fix (.githooks/pre-commit pre-existing, untouched)
|
||||||
|
|
||||||
|
3. A why-comment above the pair says monitor-bell must stay on
|
||||||
|
|
||||||
|
## FILE SCOPE
|
||||||
|
tmux.conf
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# CONTRACT — tmux-move-window
|
||||||
|
- date: 2026-11-13 | flow: hotfix | branch: feature/tmux-move-window
|
||||||
|
- status: abandoned (smoke 2 failed: focus stays on slot; superseded)
|
||||||
|
|
||||||
|
## REQUEST (verbatim — IMMUTABLE)
|
||||||
|
comment deplacer un onglet de gauche a droite dnas la liste des onglet sur tmux ?
|
||||||
|
→ (after proposal of prefix < / > bindings) "oui ajoute le"
|
||||||
|
|
||||||
|
## CLARIFICATIONS
|
||||||
|
Q: keys? / A: prefix < and > (proposed, accepted) [gated 2026-11-13]
|
||||||
|
Q: focus? / A: focus follows moved window (no -d, no extra select-window) [gated 2026-11-13]
|
||||||
|
|
||||||
|
## ACCEPTANCE CRITERIA
|
||||||
|
1. tmux.conf loads clean and prefix table binds < / > to swap-window -t -1 / +1
|
||||||
|
CHECK: tmux -L tmvchk -f tmux.conf new-session -d -s t && tmux -L tmvchk list-keys -T prefix | grep -E 'prefix +[<>] +swap-window -t [-+]1' | wc -l; tmux -L tmvchk kill-server
|
||||||
|
EXPECT: 2
|
||||||
|
EVIDENCE: pending
|
||||||
|
2. swap-window -t -1 on window 3 of 3 moves it to slot 2 and it stays current
|
||||||
|
CHECK: headless scratch socket, window ids compared before/after
|
||||||
|
EXPECT: moved id at index 2, active
|
||||||
|
EVIDENCE: pending
|
||||||
|
3. shellcheck/bash -n unaffected (tmux.conf not linted); no other file changed
|
||||||
|
|
||||||
|
## FILE SCOPE
|
||||||
|
tmux.conf
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# CONTRACT — tmux-move-window-v2
|
||||||
|
- date: 2026-11-13 | flow: hotfix | branch: feature/tmux-move-window
|
||||||
|
- status: active
|
||||||
|
|
||||||
|
## REQUEST (verbatim — IMMUTABLE)
|
||||||
|
comment deplacer un onglet de gauche a droite dnas la liste des onglet sur tmux ?
|
||||||
|
→ "oui ajoute le" → (after failed v1) "biensur reecris et applique"
|
||||||
|
|
||||||
|
## CLARIFICATIONS
|
||||||
|
Q: keys? / A: prefix < and > [gated 2026-11-13]
|
||||||
|
Q: focus? / A: follows moved window → swap-window then select-window same offset (swap alone keeps focus on slot, tested tmux 3.6) [gated 2026-11-13]
|
||||||
|
|
||||||
|
## ACCEPTANCE CRITERIA
|
||||||
|
1. prefix table binds < / > to swap-window ±1 + select-window ±1
|
||||||
|
CHECK: tmux -L tmvchk -f tmux.conf new-session -d -s t && tmux -L tmvchk list-keys -T prefix | grep -cE 'prefix +[<>] +swap-window -t [-+]1 \; select-window -t [-+]1'; tmux -L tmvchk kill-server
|
||||||
|
EXPECT: 2
|
||||||
|
EVIDENCE: pending
|
||||||
|
2. Window 3 of 3, bound command for <: moved id at index 1 and active
|
||||||
|
3. Only tmux.conf changed
|
||||||
|
|
||||||
|
## FILE SCOPE
|
||||||
|
tmux.conf
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Oracle for the contract: exercises install.sh functions on scratch HOMEs under
|
||||||
|
# mktemp; never reads or writes the real ~/.gitconfig and never calls git config.
|
||||||
|
set -euo pipefail
|
||||||
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
|
SCRIPT_DIR="$PWD"
|
||||||
|
|
||||||
|
fail() { echo "FAIL: $*" >&2; exit 1; }
|
||||||
|
fresh_home() { HOME="$(mktemp -d)"; export HOME; }
|
||||||
|
guard_home() {
|
||||||
|
case "$HOME" in /tmp/*|/private/*|/var/*) ;; *) fail "refusing HOME=$HOME" ;; esac
|
||||||
|
}
|
||||||
|
has() { grep -qF -- "$2" "$1" || fail "$1 lacks: $2"; }
|
||||||
|
|
||||||
|
funcs="$(mktemp)"
|
||||||
|
for fn in ask_autopush resolve_autopush render_identity_template \
|
||||||
|
render_gitconfig deploy_gitconfig; do
|
||||||
|
sed -n "/^$fn() {/,/^}/p" install.sh >> "$funcs"
|
||||||
|
done
|
||||||
|
source "$funcs"
|
||||||
|
shopt -u patsub_replacement 2>/dev/null || true
|
||||||
|
unset DOTFILES_GITFLOW_AUTOPUSH
|
||||||
|
|
||||||
|
# Case A: render
|
||||||
|
fresh_home; guard_home
|
||||||
|
[ "$(DOTFILES_GITFLOW_AUTOPUSH=false resolve_autopush </dev/null)" = false ] \
|
||||||
|
|| fail "A: preset false"
|
||||||
|
deploy_gitconfig x x@y false >/dev/null
|
||||||
|
for l in 'autopush = false' 'name = x' 'email = x@y' 'hooksPath = ~/.claude/githooks'; do
|
||||||
|
has "$HOME/.gitconfig" "$l"
|
||||||
|
done
|
||||||
|
! grep -qE '@(USER|EMAIL|AUTOPUSH)@' "$HOME/.gitconfig" || fail "A: placeholder left"
|
||||||
|
|
||||||
|
# Case I: idempotent re-run in A's HOME
|
||||||
|
out="$(deploy_gitconfig x x@y false)"
|
||||||
|
case "$out" in *"already up to date"*) ;; *) fail "I: not skipped: $out" ;; esac
|
||||||
|
ls "$HOME"/.gitconfig.backup-* >/dev/null 2>&1 && fail "I: backup created"
|
||||||
|
|
||||||
|
# Case A2: ampersand
|
||||||
|
fresh_home; guard_home
|
||||||
|
deploy_gitconfig 'a & b' x@y true >/dev/null
|
||||||
|
has "$HOME/.gitconfig" 'name = a & b'
|
||||||
|
|
||||||
|
# Case B: leaked placeholder
|
||||||
|
fresh_home; guard_home
|
||||||
|
set +e; deploy_gitconfig x x@y '@AUTOPUSH@' 2>"$HOME/err"; rc=$?; set -e
|
||||||
|
[ "$rc" -ne 0 ] || fail "B: rc 0"
|
||||||
|
has "$HOME/err" '@AUTOPUSH@'
|
||||||
|
[ ! -e "$HOME/.gitconfig" ] || fail "B: file written"
|
||||||
|
|
||||||
|
# Case C: existing wins over preset
|
||||||
|
fresh_home; guard_home
|
||||||
|
printf '[gitflow]\n autopush = true\n' > "$HOME/.gitconfig"
|
||||||
|
[ "$(DOTFILES_GITFLOW_AUTOPUSH=false resolve_autopush </dev/null)" = true ] || fail "C"
|
||||||
|
|
||||||
|
# Case D: defaults
|
||||||
|
fresh_home; guard_home
|
||||||
|
[ "$(resolve_autopush </dev/null)" = true ] || fail "D"
|
||||||
|
|
||||||
|
# Case E: strict preset
|
||||||
|
set +e; DOTFILES_GITFLOW_AUTOPUSH=yes resolve_autopush 2>"$HOME/err" </dev/null; rc=$?; set -e
|
||||||
|
[ "$rc" -ne 0 ] || fail "E: rc 0"
|
||||||
|
has "$HOME/err" exactly
|
||||||
|
|
||||||
|
# Case F: prompt loop
|
||||||
|
[ "$(printf 'yes\ntrue\n' | ask_autopush 2>"$HOME/err")" = true ] || fail "F1"
|
||||||
|
has "$HOME/err" exactly
|
||||||
|
[ "$(printf '\n' | ask_autopush)" = true ] || fail "F2"
|
||||||
|
|
||||||
|
# Case G: empty email
|
||||||
|
fresh_home; guard_home
|
||||||
|
deploy_gitconfig x "" true 2>"$HOME/err"
|
||||||
|
[ ! -e "$HOME/.gitconfig" ] || fail "G: file written"
|
||||||
|
has "$HOME/err" "not written"
|
||||||
|
|
||||||
|
# Case H: call site
|
||||||
|
grep -q 'deploy_gitconfig "\$identity_name" "\$identity_email" "\$autopush"' install.sh \
|
||||||
|
|| fail "H: call site"
|
||||||
|
! grep -q 'deploy_gitconfig "\$SCRIPT_DIR' install.sh || fail "H: template path"
|
||||||
|
|
||||||
|
# Case J: non-exact existing value
|
||||||
|
fresh_home; guard_home
|
||||||
|
printf '[gitflow]\n autopush = off\n' > "$HOME/.gitconfig"
|
||||||
|
[ "$(resolve_autopush 2>"$HOME/err" </dev/null)" = true ] || fail "J: value"
|
||||||
|
has "$HOME/err" off
|
||||||
|
|
||||||
|
# Case K: refused value
|
||||||
|
fresh_home; guard_home
|
||||||
|
set +e; deploy_gitconfig x x@y yes 2>"$HOME/err"; rc=$?; set -e
|
||||||
|
[ "$rc" -ne 0 ] || fail "K: rc 0"
|
||||||
|
has "$HOME/err" "not exactly"
|
||||||
|
[ ! -e "$HOME/.gitconfig" ] || fail "K: file written"
|
||||||
|
|
||||||
|
echo AUTOPUSH_RENDER_OK
|
||||||
@@ -0,0 +1,247 @@
|
|||||||
|
# PLAN — gitconfig-autopush (feat) — REVISED v4 (round 1 + user spec + confirmation pass, default true)
|
||||||
|
Contract: .claude/tasks/contracts/2026-10-07-gitconfig-autopush-1734.md
|
||||||
|
Branch: feature/gitconfig-autopush (off develop)
|
||||||
|
|
||||||
|
## Goal (user spec, verbatim constraints in the contract)
|
||||||
|
1. `gitconfig` template, section `[core]`: fixed line `hooksPath = ~/.claude/githooks`
|
||||||
|
(git expands `~` itself for core.hooksPath; no absolute path, no expansion by the
|
||||||
|
script; the installer neither creates nor checks that directory).
|
||||||
|
2. install.sh asks at install: automatic push by the gitflow hooks on this machine?
|
||||||
|
`[true/false]` (default: true — user correction). Answer rendered into a new section
|
||||||
|
`[gitflow]` / `autopush = @AUTOPUSH@`.
|
||||||
|
- Only the exact strings `true` and `false` are accepted. Anything else re-asks;
|
||||||
|
an empty answer gives `true`.
|
||||||
|
- The render FAILS explicitly (grep after render) if `@AUTOPUSH@` is still in the
|
||||||
|
final content. A non-boolean value blocks every push on the machine (fail-closed),
|
||||||
|
so a leaked placeholder would be a silent outage.
|
||||||
|
- Non-interactive install: env `DOTFILES_GITFLOW_AUTOPUSH=true|false`, default true.
|
||||||
|
3. Keep the existing backup (`~/.gitconfig.backup-<timestamp>`). Do not touch the other
|
||||||
|
template sections.
|
||||||
|
4. Human-gated 2026-10-07 (kept from round 1): fix the identity call site so the deployed
|
||||||
|
file carries the resolved name/email, not the literal `@USER@`/`@EMAIL@`.
|
||||||
|
5. The user sees the full diff BEFORE anything is committed (working tree only until then).
|
||||||
|
|
||||||
|
## Context (verified)
|
||||||
|
- `gitconfig` is a template; `render_identity_template` (install.sh:497) replaces
|
||||||
|
@USER@/@EMAIL@ by bash substitution over every line (comments included).
|
||||||
|
- `deploy_gitconfig` (install.sh:532) takes an rc PATH and reads USER/EMAIL from it.
|
||||||
|
BUG: the call site install.sh:688 passes `"$SCRIPT_DIR/$bashrc"` = the repo TEMPLATE
|
||||||
|
whose exports are `export USER="@USER@"` (bash/bashrc-linux:33-34). The placeholders
|
||||||
|
are non-empty, the guard passes, the deployed file reads `name = @USER@`.
|
||||||
|
- Identity resolved at install.sh:584-585 into `identity_name` / `identity_email`, before
|
||||||
|
package installs (prompts first). EMAIL default "" when no tty and no env.
|
||||||
|
- Readers (~/.claude/lib/gitflow.sh gitflow_push_mode, post-commit/post-merge hooks):
|
||||||
|
`git config --bool gitflow.autopush` → false = manual, true/unset = auto, other =
|
||||||
|
invalid → nothing pushed (fail closed). Only exact `true`/`false` are ever written.
|
||||||
|
- `core.hooksPath` is a pathname-typed key: git tilde-expands `~/.claude/githooks`.
|
||||||
|
Today `make link` writes it with `git config --global`; the redeploy dropped it. With
|
||||||
|
the fixed template line the redeploy keeps it and the file matches the render again.
|
||||||
|
- This session's permission layer denies every `git config … gitflow.*` command, so the
|
||||||
|
installer and the oracle must NOT read or write the key through git: an existing value
|
||||||
|
is read from ~/.gitconfig with sed (same shape as rc_export_value). Trade-off: a value
|
||||||
|
set in XDG/system/included config is not seen; ~/.gitconfig is the only file written.
|
||||||
|
- install.sh runs under macOS /bin/bash 3.2 before brew bash exists (LRN-014): plain
|
||||||
|
string compares only, no `${var,,}`.
|
||||||
|
- The repo has no test suite and install.sh has no --dry-run: the oracle harness below is
|
||||||
|
the test, run by the contract gate.
|
||||||
|
|
||||||
|
## Checklist
|
||||||
|
[ ] gitconfig — header comment (lines 1-4) reworded WITHOUT literal placeholder tokens
|
||||||
|
(today it renders as "bchanot and x@y are replaced at install time"): "Template for
|
||||||
|
the user-scope ~/.gitconfig, rendered by install.sh. Git never expands $VARS, so the
|
||||||
|
identity and the gitflow push mode are placeholders filled at install time with the
|
||||||
|
installer's answers. A repo .git/config still overrides these values for that repo."
|
||||||
|
In `[core]`, after `excludesfile`, add the fixed line:
|
||||||
|
hooksPath = ~/.claude/githooks
|
||||||
|
with a one-line comment above it: "# gitflow hooks (created by `make link` in
|
||||||
|
claude-config); git expands ~ itself." After `[user]`, add:
|
||||||
|
[gitflow]
|
||||||
|
# Push mode of the gitflow hooks: false = manual, you run `git push`;
|
||||||
|
# true = every commit and merge is pushed. Exact true/false only (fail-closed).
|
||||||
|
autopush = @AUTOPUSH@
|
||||||
|
4-space indent like the other keys. No other section touched.
|
||||||
|
[ ] install.sh — two new functions right after `resolve_identity` (~line 525), tabs:
|
||||||
|
# Ask the push question on the terminal until the answer is exactly true or false;
|
||||||
|
# Enter (or EOF) = true. Prints the value.
|
||||||
|
ask_autopush() {
|
||||||
|
local answer=""
|
||||||
|
while :; do
|
||||||
|
read -rp "Automatic push of commits by the gitflow hooks on this machine? [true/false] (default: true) " answer || true
|
||||||
|
case "${answer:-true}" in
|
||||||
|
true|false) printf '%s\n' "${answer:-true}"; return 0 ;;
|
||||||
|
*) echo "Answer exactly true or false." >&2 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Push mode of the gitflow hooks (gitflow.autopush), exact true/false only: the
|
||||||
|
# readers fail closed on anything else. Never asked twice: a true/false already in
|
||||||
|
# ~/.gitconfig wins silently (read with sed, like rc_export_value, so a hand-set
|
||||||
|
# value survives the redeploy; a non-exact spelling is named and re-asked), else
|
||||||
|
# DOTFILES_GITFLOW_AUTOPUSH (anything but true/false aborts the install here,
|
||||||
|
# before any file is touched, whatever ~/.gitconfig holds), else the prompt
|
||||||
|
# on a terminal, else true (today's unset = auto). Prints the value.
|
||||||
|
resolve_autopush() {
|
||||||
|
local value="" preset="${DOTFILES_GITFLOW_AUTOPUSH:-}"
|
||||||
|
case "$preset" in
|
||||||
|
true|false|"") ;;
|
||||||
|
*) echo "DOTFILES_GITFLOW_AUTOPUSH='$preset' — must be exactly true or false" >&2; return 1 ;;
|
||||||
|
esac
|
||||||
|
if [ -f "$HOME/.gitconfig" ]; then
|
||||||
|
value="$(sed -n 's/^[[:space:]]*autopush[[:space:]]*=[[:space:]]*//p' "$HOME/.gitconfig" | tail -n 1)"
|
||||||
|
case "$value" in
|
||||||
|
true|false) printf '%s\n' "$value"; return 0 ;;
|
||||||
|
"") ;;
|
||||||
|
*) echo "gitflow.autopush='$value' in ~/.gitconfig is not exactly true/false — asking again" >&2 ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
if [ -n "$preset" ]; then printf '%s\n' "$preset"; return 0; fi
|
||||||
|
if [ -t 0 ]; then ask_autopush; else echo true; fi
|
||||||
|
}
|
||||||
|
Order: preset syntax is validated FIRST (a bad preset always aborts, even on a
|
||||||
|
re-run), then an existing exact value wins, then a valid preset, prompt, default.
|
||||||
|
Each ≤ 25 logic lines. `read … || true` on EOF → empty → true → loop ends.
|
||||||
|
[ ] install.sh — after `set -euo pipefail` (line 4) add, with a one-line comment
|
||||||
|
("bash ≥ 5.2 expands `&` in ${var//pat/rep} replacements: an `&` in a name would
|
||||||
|
corrupt the rendered identity; no-op on bash 3.2"):
|
||||||
|
shopt -u patsub_replacement 2>/dev/null || true
|
||||||
|
[ ] install.sh — main sequence, right after identity_email (line 585):
|
||||||
|
autopush="$(resolve_autopush)"
|
||||||
|
(set -e: a `return 1` from an invalid preset aborts the install right here.)
|
||||||
|
[ ] install.sh — `deploy_gitconfig` becomes `deploy_gitconfig <name> <email> <autopush>`
|
||||||
|
(no rc path, no rc_export_value call):
|
||||||
|
local name="$1" email="$2" autopush="$3" rendered backup
|
||||||
|
if [ -z "$name" ] || [ -z "$email" ]; then
|
||||||
|
echo "Name or email empty — skipping ~/.gitconfig (push mode $autopush not written)" >&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
rendered="$(render_identity_template "$SCRIPT_DIR/gitconfig" "$name" "$email")"
|
||||||
|
case "$autopush" in true|false) ;; *)
|
||||||
|
echo "gitconfig render refused: push mode '$autopush' is not exactly true/false — nothing written" >&2
|
||||||
|
return 1 ;;
|
||||||
|
esac
|
||||||
|
rendered="${rendered//@AUTOPUSH@/$autopush}"
|
||||||
|
case "$rendered" in *@AUTOPUSH@*)
|
||||||
|
echo "gitconfig render failed: @AUTOPUSH@ left in the output — nothing written" >&2
|
||||||
|
return 1 ;;
|
||||||
|
esac
|
||||||
|
(no pipe: `printf | grep -q` under pipefail can read SIGPIPE as "no leak")
|
||||||
|
… cmp/skip, backup, write unchanged …
|
||||||
|
echo "Deploying gitconfig to ~/.gitconfig ($name <$email>, autopush=$autopush)"
|
||||||
|
Header comment rewritten: $1 $2 = the identity rendered into the rc, $3 = push mode;
|
||||||
|
one line on the two fail-closed checks. If > 25 logic lines, extract
|
||||||
|
`render_gitconfig <name> <email> <autopush>` (render + substitution + grep).
|
||||||
|
[ ] install.sh:688 call site → `deploy_gitconfig "$identity_name" "$identity_email" "$autopush"`
|
||||||
|
comment: "User-scope git config, same identity as the rc just rendered."
|
||||||
|
[ ] README.md:31 gitconfig row — "`@USER@`, `@EMAIL@` and `@AUTOPUSH@` (gitflow push
|
||||||
|
mode) are filled at install with the installer's answers; `core.hooksPath` points at
|
||||||
|
the gitflow hooks `make link` creates."
|
||||||
|
[ ] README.md:50 — "(identity, push mode, macOS shell, offers)".
|
||||||
|
[ ] README.md:70 step 6 — replace "with the same `USER` / `EMAIL`" by "with the same name
|
||||||
|
and email", then add: the installer asks once whether the gitflow hooks push every
|
||||||
|
commit and merge (`true`/`false` exactly, Enter = `true`); a `true`/`false` already
|
||||||
|
in `~/.gitconfig` is reused without asking and survives the redeploy;
|
||||||
|
`DOTFILES_GITFLOW_AUTOPUSH=true|false` presets it for a non-interactive install (no
|
||||||
|
terminal and no preset → `true`; any other preset aborts the install); the render
|
||||||
|
refuses to write a file where `@AUTOPUSH@` leaked, since a non-boolean value blocks
|
||||||
|
every push. To switch later: `git config --global gitflow.autopush true|false`.
|
||||||
|
[ ] CLAUDE.md:25 — `gitconfig user-scope ~/.gitconfig template, @USER@/@EMAIL@/@AUTOPUSH@
|
||||||
|
(gitflow push mode, exact true/false) filled at install; core.hooksPath fixed`
|
||||||
|
[ ] .claude/tasks/contracts/check-autopush-render.sh — oracle harness (LRN-011 pattern):
|
||||||
|
`set -euo pipefail`; `cd "$(git rev-parse --show-toplevel)"` (the only git call, no
|
||||||
|
config access); `SCRIPT_DIR="$PWD"`. Extract ask_autopush, resolve_autopush,
|
||||||
|
render_identity_template, deploy_gitconfig (and render_gitconfig if extracted) from
|
||||||
|
install.sh via `sed -n '/^fn() {/,/^}/p'` into `$(mktemp)` and source it.
|
||||||
|
`fresh_home() { HOME="$(mktemp -d)"; export HOME; }` before every case; guard
|
||||||
|
`case "$HOME" in /tmp/*|/private/*|/var/*) ;; *) fail "refusing HOME=$HOME";; esac`
|
||||||
|
before any deploy call. No rm of temp dirs (never rm -rf through a variable).
|
||||||
|
`fail() { echo "FAIL: $*" >&2; exit 1; }`; every assertion goes through it.
|
||||||
|
stderr captures go to `"$HOME/err"` (the scratch HOME), never a relative path in
|
||||||
|
the repo. Header comment: "Oracle for the contract: exercises install.sh functions
|
||||||
|
on scratch HOMEs under mktemp; never reads or writes the real ~/.gitconfig and never
|
||||||
|
calls git config." If the permission layer refuses a step of this harness, the
|
||||||
|
refusal is reported with its rule and the harness is handed to the user to run; it
|
||||||
|
is never reworked to get around the rule.
|
||||||
|
Case A (render): fresh_home; DOTFILES_GITFLOW_AUTOPUSH=false </dev/null →
|
||||||
|
resolve_autopush = false; deploy_gitconfig x x@y false → file has
|
||||||
|
`autopush = false`, `name = x`, `email = x@y`, `hooksPath = ~/.claude/githooks`,
|
||||||
|
and `! grep -qE '@(USER|EMAIL|AUTOPUSH)@'`.
|
||||||
|
Case A2 (ampersand): fresh_home; deploy_gitconfig 'a & b' x@y true → file has
|
||||||
|
`name = a & b` (patsub_replacement off; bash 3.2 passes trivially).
|
||||||
|
Case B (leaked placeholder = failure): fresh_home; `set +e; deploy_gitconfig x x@y
|
||||||
|
'@AUTOPUSH@' 2>err; rc=$?; set -e` → rc != 0, err contains "@AUTOPUSH@", no
|
||||||
|
~/.gitconfig written. (Passing the placeholder as the value is the only way to
|
||||||
|
make the substitution a no-op; it stands in for a broken template.)
|
||||||
|
Case C (existing wins): fresh_home; printf '[gitflow]\n autopush = true\n' >
|
||||||
|
"$HOME/.gitconfig"; DOTFILES_GITFLOW_AUTOPUSH=false </dev/null → true.
|
||||||
|
Case D (defaults): fresh_home; no file, env unset, </dev/null → true.
|
||||||
|
Case E (strict preset): DOTFILES_GITFLOW_AUTOPUSH=yes </dev/null → `set +e;
|
||||||
|
resolve_autopush 2>err; rc=$?; set -e` → rc != 0, err contains "exactly".
|
||||||
|
Case F (prompt loop): `printf 'yes\ntrue\n' | ask_autopush 2>err` → true, err
|
||||||
|
contains "exactly"; `printf '\n' | ask_autopush` → true.
|
||||||
|
Case G (empty email): deploy_gitconfig x "" true 2>err → no file, err has "not written".
|
||||||
|
Case H (call site): `grep -q 'deploy_gitconfig "\$identity_name" "\$identity_email" "\$autopush"' install.sh`
|
||||||
|
and `! grep -q 'deploy_gitconfig "\$SCRIPT_DIR' install.sh`.
|
||||||
|
Case I (idempotent): run right after Case A in Case A's HOME (no fresh_home between
|
||||||
|
them): deploy_gitconfig x x@y false again → stdout contains "already up to date",
|
||||||
|
no `.gitconfig.backup-*` created.
|
||||||
|
Case J (non-exact existing): fresh_home; printf '[gitflow]\n autopush = off\n' >
|
||||||
|
"$HOME/.gitconfig"; env unset, </dev/null → prints true and stderr names "off".
|
||||||
|
Case K (refused value): `set +e; deploy_gitconfig x x@y yes 2>"$HOME/err"; rc=$?; set -e`
|
||||||
|
→ rc != 0, err contains "not exactly", no file.
|
||||||
|
Print AUTOPUSH_RENDER_OK only at the end.
|
||||||
|
|
||||||
|
## Edge cases
|
||||||
|
- Non-exact existing value: `off`/`no`/`0` are VALID false for the readers (`--bool`),
|
||||||
|
`maybe` is invalid (nothing pushed). Neither is reused (strict grammar): the value is
|
||||||
|
named on stderr, then preset/prompt/default decide. With no tty and no preset a
|
||||||
|
hand-set `off` becomes `true`: accepted consequence of the strict grammar + default
|
||||||
|
true, documented in the README sentence on switching the mode.
|
||||||
|
- Re-run: value found in ~/.gitconfig → no prompt → identical render → "already up to
|
||||||
|
date — skipping" (now holds with hooksPath in the template).
|
||||||
|
- No tty (curl | bash without /dev/tty) and no preset → true: same as today's unset = auto.
|
||||||
|
- Invalid preset aborts before Oldconfig/rm or any write (resolution happens at the
|
||||||
|
identity step).
|
||||||
|
- Empty email → file skipped, dropped push mode named in the warning.
|
||||||
|
- `.githooks/post-commit` / `.githooks/post-merge` are dirty from the session hook
|
||||||
|
refresh: do not touch, do not stage.
|
||||||
|
- Known, not handled: a system-scope `/etc/gitconfig` value is shadowed by the written
|
||||||
|
global one (blockers entry at CAPITALIZE).
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
- `bash -n install.sh`, `shellcheck install.sh`.
|
||||||
|
- `bash .claude/tasks/contracts/check-autopush-render.sh` → AUTOPUSH_RENDER_OK.
|
||||||
|
|
||||||
|
## Disposition (memory read-before)
|
||||||
|
- honors BDR-001 (bash) — bash substitutions, `read -rp`.
|
||||||
|
- honors BDR-002 — template read via `$SCRIPT_DIR/gitconfig`.
|
||||||
|
- BDR-012 pattern (installer prompts, re-ask on bad input, keep-existing, no TTY →
|
||||||
|
default) honored on the interactive path; DEVIATION flagged: an invalid
|
||||||
|
DOTFILES_GITFLOW_AUTOPUSH preset aborts the install (user's fail-closed requirement),
|
||||||
|
before any file is touched.
|
||||||
|
- honors LRN-001 idempotency — unchanged ~/.gitconfig skipped; existing value reused.
|
||||||
|
- honors LRN-011 — oracle is a stub harness on extracted functions, no live install, no git config.
|
||||||
|
- honors LRN-014 — bash 3.2 safe.
|
||||||
|
- Non-binding: BDR-016 (backup naming, kept as is).
|
||||||
|
|
||||||
|
## CHALLENGE SUMMARY (round 1 → v2)
|
||||||
|
- BLOCKER (correctness+robustness): template path at the call site → placeholders deployed
|
||||||
|
→ closed: deploy_gitconfig takes name/email/autopush; call site passes the resolved
|
||||||
|
identity; Case A asserts no placeholder; Case H pins the call site. [gated]
|
||||||
|
- BLOCKER (simplicity+robustness): `git config … gitflow.*` denied to this session →
|
||||||
|
closed: sed read of ~/.gitconfig, harness writes files directly, zero config access.
|
||||||
|
- MAJOR: loose boolean grammar / fail-open normaliser → superseded by the user spec:
|
||||||
|
exact true/false only, re-ask, default true (user correction), invalid preset aborts.
|
||||||
|
- MAJOR: empty email drops the answer → closed: named in the skip warning.
|
||||||
|
- MAJOR: hooksPath wiped on redeploy → superseded by the user spec: fixed template line.
|
||||||
|
- MAJOR: shared scratch HOME → closed: fresh_home per case + guard.
|
||||||
|
- MINORs: header comment reworded, `@(USER|EMAIL|AUTOPUSH)@` assertion, README:50, README
|
||||||
|
wording (precedence + how to switch), call-site grep. Deferred: system-scope shadowing.
|
||||||
|
- Added by the user spec: fail-closed grep after render (Case B), DOTFILES_ prefix.
|
||||||
|
|
||||||
|
## CHALLENGE SUMMARY (confirmation pass, v3 → v4): SOLID, 8 MINOR
|
||||||
|
- Accepted: preset validated first; non-exact existing value named; positive true/false
|
||||||
|
guard + no-pipe leak check; patsub_replacement off + Case A2; err files in scratch HOME;
|
||||||
|
Case I in Case A's HOME; harness header + refusal rule; TODO line rewritten.
|
||||||
|
- Edge-case text corrected (off/no/0 are valid false for the readers).
|
||||||
|
- BDR-012 deviation (preset abort) flagged in the Disposition.
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# PLAN — sshd-reload-inactive (hotfix)
|
||||||
|
|
||||||
|
## Root cause
|
||||||
|
`install.sh` runs under `set -euo pipefail`. `harden_sshd()` (lines ~226-236) ends with an
|
||||||
|
unconditional `sudo systemctl reload ssh`. On WSL (and any host where sshd is socket-activated
|
||||||
|
or simply not started) ssh.service is inactive, systemctl prints
|
||||||
|
"ssh.service is not active, cannot reload." and exits non-zero, so `set -e` aborts the whole
|
||||||
|
install at "Deploying sshd hardening drop-in". openssh-server itself IS installed (apt list,
|
||||||
|
line ~730); the drop-in has already been installed and validated with `sshd -t` at that point.
|
||||||
|
|
||||||
|
## Exact edit (install.sh, harden_sshd, tabs) — revised after challenge
|
||||||
|
1. Before `sudo sshd -t`, add one line so the validation also works when ssh.service is
|
||||||
|
inactive (privsep dir normally created by the unit's RuntimeDirectory; absent on Ubuntu
|
||||||
|
24.04 when sshd never ran — challenge correctness MAJOR + robustness MINOR 2):
|
||||||
|
```
|
||||||
|
sudo install -d -m 0755 /run/sshd
|
||||||
|
```
|
||||||
|
2. Replace the unconditional reload
|
||||||
|
```
|
||||||
|
sudo systemctl reload ssh
|
||||||
|
}
|
||||||
|
```
|
||||||
|
with
|
||||||
|
```
|
||||||
|
if systemctl is-active --quiet ssh; then
|
||||||
|
sudo systemctl try-reload-or-restart ssh
|
||||||
|
else
|
||||||
|
echo "ssh.service not running — drop-in in place, applies at the next sshd start"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
```
|
||||||
|
`try-reload-or-restart` exits 0 if the unit stopped between the check and the call
|
||||||
|
(robustness MINOR 1); the `is-active` guard stays for the informative echo.
|
||||||
|
3. Update the function's header comment (one or two lines): /run/sshd is created so `sshd -t`
|
||||||
|
works without a running sshd; the reload happens only when sshd is running.
|
||||||
|
|
||||||
|
## Smoke (robustness MINOR 3 — exercise the else branch for real)
|
||||||
|
In the scratchpad, extract `harden_sshd` from install.sh into a temp script with
|
||||||
|
`SCRIPT_DIR` pointing at the repo, prepend a stub dir to PATH where `systemctl` exits 3 for
|
||||||
|
`is-active` (and 0 otherwise), `sudo` runs its arguments without privilege, `sshd` exits 0;
|
||||||
|
run under `set -euo pipefail` and assert exit 0 + the "drop-in in place" echo. Then flip the
|
||||||
|
stub (`is-active` exits 0) and assert `try-reload-or-restart ssh` is what gets called.
|
||||||
|
Plus `bash -n install.sh` and `shellcheck install.sh`.
|
||||||
|
|
||||||
|
## Constraints
|
||||||
|
- No other change; `offer_ssh_memory_guard` uses `systemctl restart ssh`, which starts an inactive
|
||||||
|
unit and is out of scope.
|
||||||
|
- shellcheck clean, `bash -n` clean, tabs.
|
||||||
|
|
||||||
|
## Challenge summary
|
||||||
|
- correctness MAJOR (/run/sshd missing → sshd -t false reject) → closed by edit 1.
|
||||||
|
- robustness MINOR 1 (check-then-act race) → closed by `try-reload-or-restart`.
|
||||||
|
- robustness MINOR 2 (same /run/sshd risk) → closed by edit 1.
|
||||||
|
- robustness MINOR 3 (gate never runs the else path) → closed by the Smoke section.
|
||||||
|
- simplicity: SOLID, no findings.
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# PLAN — tmux-bell-highlight (hotfix)
|
||||||
|
|
||||||
|
## Root cause
|
||||||
|
tmux.conf:15 `set -g bell-action none`. bell-action only decides whether a bell is
|
||||||
|
forwarded to the client terminal → user hears no bell since tmux. The tab flag is
|
||||||
|
governed by monitor-bell (default on): a bell in a non-current window sets
|
||||||
|
WINLINK_BELL, drawn with window-status-bell-style (default `reverse`) until the
|
||||||
|
window is visited → several tabs highlighted at once.
|
||||||
|
|
||||||
|
## Fix (tmux.conf, line 15 area, 2 lines)
|
||||||
|
- `set -g bell-action none # make it Shut up!` → `set -g bell-action any`
|
||||||
|
(forward bells from every window of the attached session, tmux default;
|
||||||
|
sessions with no attached client stay silent).
|
||||||
|
- add `setw -g window-status-bell-style default` (flag kept, no visual: only the
|
||||||
|
current tab stands out). Status formats use #I #W, not #F, so no `!` either.
|
||||||
|
|
||||||
|
- one why-comment above the pair (bell sent to terminal; tab flag kept but
|
||||||
|
unstyled; monitor-bell must stay on or no bell is sent). [challenge simplicity#1]
|
||||||
|
|
||||||
|
## After merge (not in repo diff) [challenge correctness#1, robustness#1]
|
||||||
|
Live server: main loop runs `tmux set -g bell-action any; tmux set -wg monitor-bell on;
|
||||||
|
tmux set -wg window-status-bell-style default`. Deployed copy ~/.config/tmux/tmux.conf
|
||||||
|
is a cp (install.sh:569): user redeploys (./install.sh or cp) on each host, then prefix R.
|
||||||
|
Rollback: revert, `setw -gu window-status-bell-style`, prefix R. [robustness#2]
|
||||||
|
|
||||||
|
## Not changed
|
||||||
|
monitor-bell stays on (default): alerts_check_bell() returns early when it is off,
|
||||||
|
so no bell would reach the terminal. monitor-activity already off.
|
||||||
@@ -5,8 +5,15 @@ hook=post-commit
|
|||||||
# holds. Never fails the commit: no origin / offline / refused → warning only.
|
# holds. Never fails the commit: no origin / offline / refused → warning only.
|
||||||
# Opt out for one command with GITFLOW_NO_PUSH=1 (throwaway repos, tests).
|
# Opt out for one command with GITFLOW_NO_PUSH=1 (throwaway repos, tests).
|
||||||
[ "${GITFLOW_NO_PUSH:-0}" = 1 ] && exit 0
|
[ "${GITFLOW_NO_PUSH:-0}" = 1 ] && exit 0
|
||||||
# Per-repo opt-out (no push rights on a foreign clone): git config gitflow.autopush false
|
# Manual-push mode (human-set): git config gitflow.autopush false. Fail closed:
|
||||||
[ "$(git config --bool --default true gitflow.autopush)" = false ] && exit 0
|
# an unparseable value or a config read failure also means "no push", named.
|
||||||
|
# Mirrors gitflow_push_mode (lib/gitflow.sh); arms pinned by T18b/T18h/T18q2/T18q4.
|
||||||
|
v=$(git config --bool gitflow.autopush 2>/dev/null); rc=$?
|
||||||
|
case "$rc:$v" in
|
||||||
|
0:true|1:*) ;;
|
||||||
|
0:false) exit 0 ;;
|
||||||
|
*) echo "gitflow $hook: gitflow.autopush unreadable (git rc $rc) — NOT pushed, treated as manual push mode; fix the value by hand" >&2; exit 0 ;;
|
||||||
|
esac
|
||||||
git remote get-url origin >/dev/null 2>&1 || exit 0
|
git remote get-url origin >/dev/null 2>&1 || exit 0
|
||||||
br=$(git symbolic-ref --short -q HEAD 2>/dev/null) || exit 0 # detached HEAD — nothing to track
|
br=$(git symbolic-ref --short -q HEAD 2>/dev/null) || exit 0 # detached HEAD — nothing to track
|
||||||
if command -v timeout >/dev/null 2>&1; then t="timeout ${GITFLOW_PUSH_TIMEOUT:-30}"; else t=""; fi
|
if command -v timeout >/dev/null 2>&1; then t="timeout ${GITFLOW_PUSH_TIMEOUT:-30}"; else t=""; fi
|
||||||
|
|||||||
@@ -5,8 +5,15 @@ hook=post-merge
|
|||||||
# holds. Never fails the commit: no origin / offline / refused → warning only.
|
# holds. Never fails the commit: no origin / offline / refused → warning only.
|
||||||
# Opt out for one command with GITFLOW_NO_PUSH=1 (throwaway repos, tests).
|
# Opt out for one command with GITFLOW_NO_PUSH=1 (throwaway repos, tests).
|
||||||
[ "${GITFLOW_NO_PUSH:-0}" = 1 ] && exit 0
|
[ "${GITFLOW_NO_PUSH:-0}" = 1 ] && exit 0
|
||||||
# Per-repo opt-out (no push rights on a foreign clone): git config gitflow.autopush false
|
# Manual-push mode (human-set): git config gitflow.autopush false. Fail closed:
|
||||||
[ "$(git config --bool --default true gitflow.autopush)" = false ] && exit 0
|
# an unparseable value or a config read failure also means "no push", named.
|
||||||
|
# Mirrors gitflow_push_mode (lib/gitflow.sh); arms pinned by T18b/T18h/T18q2/T18q4.
|
||||||
|
v=$(git config --bool gitflow.autopush 2>/dev/null); rc=$?
|
||||||
|
case "$rc:$v" in
|
||||||
|
0:true|1:*) ;;
|
||||||
|
0:false) exit 0 ;;
|
||||||
|
*) echo "gitflow $hook: gitflow.autopush unreadable (git rc $rc) — NOT pushed, treated as manual push mode; fix the value by hand" >&2; exit 0 ;;
|
||||||
|
esac
|
||||||
git remote get-url origin >/dev/null 2>&1 || exit 0
|
git remote get-url origin >/dev/null 2>&1 || exit 0
|
||||||
br=$(git symbolic-ref --short -q HEAD 2>/dev/null) || exit 0 # detached HEAD — nothing to track
|
br=$(git symbolic-ref --short -q HEAD 2>/dev/null) || exit 0 # detached HEAD — nothing to track
|
||||||
if command -v timeout >/dev/null 2>&1; then t="timeout ${GITFLOW_PUSH_TIMEOUT:-30}"; else t=""; fi
|
if command -v timeout >/dev/null 2>&1; then t="timeout ${GITFLOW_PUSH_TIMEOUT:-30}"; else t=""; fi
|
||||||
|
|||||||
@@ -5,6 +5,30 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versioning: se
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `bashrc-linux`, `bashrc-osx`, `zshrc-osx`: `openrouter` function switches Claude Code to OpenRouter in the current shell (`openrouter` on, `openrouter -d`/`-u` off). Key from `$OPENROUTER_API_KEY`; values the four variables held before are saved and restored on off; a reminder to log out / log in of Claude Code is printed.
|
||||||
|
- `install.sh` installs the Rust toolchain on both OSes with the official `rustup` script (`stable`, default profile + `rust-analyzer` `rust-src`, `rustup update` on a re-run, `--no-modify-path`); the deployed bashrc/zshrc source `~/.cargo/env`. `libssl-dev` (apt) / `openssl@3` (brew) added for `openssl-sys` crates.
|
||||||
|
- `install.sh` asks the gitflow push mode (`gitflow.autopush`, exactly `true` or `false`, Enter = `true`) and writes it to `~/.gitconfig`; an existing value is reused, `DOTFILES_GITFLOW_AUTOPUSH` presets it, any other preset aborts the install.
|
||||||
|
- `gitconfig`: fixed `core.hooksPath = ~/.claude/githooks`.
|
||||||
|
- `tmux.conf`: move panes between windows — `J`/`L` join the marked pane below/beside, `S` swaps it with the current one, `(`/`)` (repeatable) move the pane to the previous/next slot.
|
||||||
|
- `tmux.conf`: window tabs centred in the status bar (`absolute-centre`), with index, padding and a blank between tabs; the current tab bold on a light pill.
|
||||||
|
- `bin/tmux-copy-exit-keys` + `tmux.conf`: after a mouse selection any bare key leaves copy-mode and returns to the prompt (key swallowed); ctrl/alt keys, and copy-mode opened from the keyboard or the wheel, keep their vi role.
|
||||||
|
- `tmux.conf`: Alt+Left/Right switch windows without the prefix (macOS: map Cmd+arrow in iTerm2 to the `[1;3D` / `[1;3C` escape sequences).
|
||||||
|
- `tmux.conf`: Ctrl+Alt+arrow moves between panes without the prefix, in copy-mode too (macOS: map Ctrl+Cmd+arrow in iTerm2 to `[1;7A` `[1;7B` `[1;7D` `[1;7C`).
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- `bin/claude-provider` (wrote a file nothing sourced), replaced by the `openrouter` rc function. A copy already deployed in `~/.local/bin` is not deleted by the installer.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- `install.sh`: the GNOME desktop (`ubuntu-desktop-minimal`) and the RDP remote login are now offered (`[Y/n]` each, RDP only after the desktop) instead of always installed; on WSL both default to no, since Windows owns the display and the desktop's NetworkManager/systemd-resolved rewrite `/etc/resolv.conf` and break DNS mid-install.
|
||||||
|
- `.githooks/post-commit` and `post-merge` fail closed on `gitflow.autopush`: an unreadable or non-boolean value means no push, with a named warning (was: silently treated as `true`).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `~/.gitconfig` was deployed with the literal `@USER@` / `@EMAIL@` placeholders: the installer read the identity from the repo bashrc template instead of the answers.
|
||||||
|
- An `&` in the name no longer corrupts the rendered identity on bash 5.2 and later (`patsub_replacement` turned off).
|
||||||
|
- `install.sh`: the sshd hardening step no longer aborts the install when `ssh.service` is inactive (WSL, sshd never started): `/run/sshd` is created before `sshd -t`, so a valid drop-in is no longer removed as rejected, and the reload (`try-reload-or-restart`) runs only when sshd is active.
|
||||||
|
- `tmux.conf`: bells reach the terminal again (`bell-action any`, was `none`, which dropped every bell), and a background tab that rang is no longer highlighted in reverse (`window-status-bell-style default`; the bell flag is kept, unstyled).
|
||||||
|
|
||||||
## [1.0.0] — 2026-10-06
|
## [1.0.0] — 2026-10-06
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -20,18 +20,24 @@ install.sh one-shot installer (OS auto-detected)
|
|||||||
vim/vimrc vim config (pathogen, molokai, syntastic, NERDTree)
|
vim/vimrc vim config (pathogen, molokai, syntastic, NERDTree)
|
||||||
vim/autoload/ pathogen loader (committed)
|
vim/autoload/ pathogen loader (committed)
|
||||||
vim/colors/ molokai colorscheme (committed)
|
vim/colors/ molokai colorscheme (committed)
|
||||||
bash/bashrc-{linux,osx} OS-detected bashrc (exports USER/EMAIL identity)
|
bash/bashrc-{linux,osx} OS-detected bashrc; USER/EMAIL identity = @USER@/@EMAIL@ placeholders,
|
||||||
gitconfig user-scope ~/.gitconfig template, @USER@/@EMAIL@ filled at install
|
asked at install (reused from an existing rc), never tracked
|
||||||
|
gitconfig user-scope ~/.gitconfig template, @USER@/@EMAIL@/@AUTOPUSH@
|
||||||
|
(gitflow push mode, exact true/false) filled at install; core.hooksPath fixed
|
||||||
|
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
|
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
|
bin/{dt,dtach-router} CLI scripts deployed to ~/.local/bin
|
||||||
|
bin/tmux-copy-exit-keys run by tmux.conf at load: after a mouse selection any bare key leaves copy-mode
|
||||||
|
bin/repo-sync multi-forge repo tree (gitlab/github/gitea/bitbucket cloud) → ~/repos, daily cache;
|
||||||
|
tokens in ~/.config/repos/forges.conf (0600, never tracked); `repo` fn in the rc files
|
||||||
etc/profile.d/disk-usage-warning.sh login-time low-disk warning → /etc/profile.d (Linux only)
|
etc/profile.d/disk-usage-warning.sh login-time low-disk warning → /etc/profile.d (Linux only)
|
||||||
etc/tmpfiles.d/tmp.conf disk-backed /tmp cleanup rules (offer: /tmp on disk)
|
etc/tmpfiles.d/tmp.conf disk-backed /tmp cleanup rules (offer: /tmp on disk)
|
||||||
etc/systemd/ssh.service.d/override.conf sshd OOM-exempt drop-in (offer: SSH memory guard)
|
etc/systemd/ssh.service.d/override.conf sshd OOM-exempt drop-in (offer: SSH memory guard)
|
||||||
etc/default/earlyoom earlyoom args, spare sshd / kill node first (same offer)
|
etc/default/earlyoom earlyoom args, spare sshd / kill node first (same offer)
|
||||||
etc/fail2ban/jail.d/local.conf sshd jail: journal backend, all-ports ban, LAN ignored (always)
|
etc/fail2ban/jail.d/local.conf sshd jail: journal backend, all-ports ban, LAN ignored (offer, no on WSL)
|
||||||
etc/apt/apt.conf.d/20auto-upgrades unattended security upgrades on (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)
|
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)
|
prompted at install → /etc/cloudpex.conf, never in the script (FR docs)
|
||||||
.claude/{tasks,memory,audits}/ Claude working state
|
.claude/{tasks,memory,audits}/ Claude working state
|
||||||
```
|
```
|
||||||
@@ -40,15 +46,18 @@ cloudpex/{cloudpex,install.sh,README.md} on-demand SMB mount helper → /usr/loc
|
|||||||
install.sh offers to mask `tmp.mount`. Swap is not the fix (the cap and ENOSPC stay).
|
install.sh offers to mask `tmp.mount`. Swap is not the fix (the cap and ENOSPC stay).
|
||||||
|
|
||||||
macOS: install.sh swaps apt-get for Homebrew (colima for Docker, brew services for
|
macOS: install.sh swaps apt-get for Homebrew (colima for Docker, brew services for
|
||||||
code-server/mariadb, `~/.bash_profile` → `~/.bashrc`), asks bash or zsh (`MACOS_SHELL`
|
code-server/mariadb, `~/.bash_profile` → `~/.bashrc`), asks zsh or bash (zsh by default,
|
||||||
presets it; zsh = oh-my-zsh + `zsh/` files, bash = brew bash 5) and prints the Linux-only
|
`MACOS_SHELL` presets it; zsh = oh-my-zsh + `zsh/` files, bash = brew bash 5) and prints the Linux-only
|
||||||
items it skipped. Keep `bashrc-osx` = `bashrc-linux` + macOS deltas only, and the zsh
|
items it skipped. Keep `bashrc-osx` = `bashrc-linux` + macOS deltas only, and the zsh
|
||||||
files in step with them (same env, aliases, prompt).
|
files in step with them (same env, aliases, prompt).
|
||||||
|
|
||||||
|
Rust comes from the official rustup script (`install_rust`, user-level, `--no-modify-path`); the
|
||||||
|
rc files source `~/.cargo/env`. Never add `rustc`/`cargo` to the apt or brew lists.
|
||||||
|
|
||||||
`pymupdf`/`markdown_py` are NOT tracked — they are pipx entry-point shims,
|
`pymupdf`/`markdown_py` are NOT tracked — they are pipx entry-point shims,
|
||||||
recreated by `pipx install PyMuPDF Markdown` in install.sh.
|
recreated by `pipx install PyMuPDF Markdown` in install.sh.
|
||||||
`claude-provider` reads `$OPENROUTER_API_KEY` from the env — never hardcode it (the
|
The `openrouter` rc function reads `$OPENROUTER_API_KEY` from the env — never hardcode it (the
|
||||||
original had a live key; it was scrubbed — see decisions/blockers).
|
former `claude-provider` had a live key; it was scrubbed — see decisions/blockers).
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Personal dotfiles — vim + bash configuration and a one-shot installer.
|
|||||||
Install everything (clone + setup) with one command:
|
Install everything (clone + setup) with one command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/master/remote-install.sh | bash
|
curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/main/remote-install.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
(Runs a remote script through `bash` — see the [Install](#install) section for what it does and the manual alternative.)
|
(Runs a remote script through `bash` — see the [Install](#install) section for what it does and the manual alternative.)
|
||||||
@@ -16,25 +16,27 @@ curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/master/remote-instal
|
|||||||
|
|
||||||
| Path | Purpose |
|
| 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. |
|
| `install.sh` | Linux: installs apt packages + Docker + code-server, offers the GNOME desktop + RDP (gnome-remote-desktop; default no on WSL), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools, the Rust toolchain (rustup) and a low-disk login warning; ends by offering four extras (`/tmp` on disk, SSH memory guard, the `cloudpex` NAS mount helper, rootless Docker). macOS: same tooling through Homebrew (see [macOS](#macos)), deploys the tmux config, 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. |
|
| `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/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/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. |
|
| `etc/default/earlyoom` | earlyoom arguments: spare sshd/systemd, kill node/java first. Deployed by the SSH memory guard offer. |
|
||||||
| `etc/fail2ban/jail.d/local.conf` | fail2ban sshd jail: journal backend, all-ports ban, 5 tries / 10 min / 1 h, private LAN never banned. Deployed on every Linux install. |
|
| `etc/fail2ban/jail.d/local.conf` | fail2ban sshd jail: journal backend, all-ports ban, 5 tries / 10 min / 1 h, private LAN never banned. Deployed when fail2ban is accepted (offered on Linux, default yes, no on WSL). |
|
||||||
| `etc/apt/apt.conf.d/20auto-upgrades` | Enables unattended security upgrades (what `dpkg-reconfigure` writes). Deployed on every Linux install. |
|
| `etc/apt/apt.conf.d/20auto-upgrades` | Enables unattended security upgrades (what `dpkg-reconfigure` writes). Deployed on every Linux install. |
|
||||||
| `etc/ssh/sshd_config.d/20-hardening.conf` | sshd limits that cannot lock you out: `PermitRootLogin no`, `MaxAuthTries 3`, `LoginGraceTime 20`. Deployed on every Linux install after `sshd -t`. |
|
| `etc/ssh/sshd_config.d/20-hardening.conf` | sshd limits that cannot lock you out: `PermitRootLogin no`, `MaxAuthTries 3`, `LoginGraceTime 20`. Deployed on every Linux install after `sshd -t`. |
|
||||||
| `vim/vimrc` | Vim config: pathogen, molokai, syntastic (C with `-Wall -Werror -Wextra`), NERDTree, 42-style canonical class generators (`:ClassH`, `:ClassC`). |
|
| `vim/vimrc` | Vim config: pathogen, molokai, syntastic (C with `-Wall -Werror -Wextra`), NERDTree, 42-style canonical class generators (`:ClassH`, `:ClassC`). |
|
||||||
| `vim/autoload/` | `pathogen.vim` plugin loader (committed). |
|
| `vim/autoload/` | `pathogen.vim` plugin loader (committed). |
|
||||||
| `vim/colors/` | `molokai.vim` colorscheme (committed). |
|
| `vim/colors/` | `molokai.vim` colorscheme (committed). |
|
||||||
| `gitconfig` | Template of the user-scope `~/.gitconfig`. `@USER@` and `@EMAIL@` are filled at install with the `USER` and `EMAIL` exported by the bashrc (git never expands `$VARS` itself). |
|
| `gitconfig` | Template of the user-scope `~/.gitconfig`. `@USER@`, `@EMAIL@` and `@AUTOPUSH@` (gitflow push mode) are filled at install with the installer's answers (git never expands `$VARS` itself); `core.hooksPath` points at the gitflow hooks `make link` creates in the claude-config repo. |
|
||||||
| `bash/bashrc-linux` | bashrc for desktop Linux (git-aware prompt + command timer). |
|
| `bash/bashrc-linux` | bashrc for desktop Linux (git-aware prompt + command timer). |
|
||||||
| `bash/bashrc-osx` | bashrc for macOS: `bashrc-linux` adapted (Homebrew on `PATH`, BSD `ls -G`, bash 5 clock for the timer, `cc` without `systemd-run`). |
|
| `bash/bashrc-osx` | bashrc for macOS: `bashrc-linux` adapted (Homebrew on `PATH`, BSD `ls -G`, bash 5 clock for the timer, `cc` without `systemd-run`). |
|
||||||
| `zsh/zshrc-osx` | zshrc for macOS when zsh is chosen: oh-my-zsh + the same env, aliases and dtach menu as `bashrc-osx`. Loads `~/.zshrc.local` for machine-specific lines. |
|
| `zsh/zshrc-osx` | zshrc for macOS when zsh is chosen: oh-my-zsh + the same env, aliases and dtach menu as `bashrc-osx`. Loads `~/.zshrc.local` for machine-specific lines. |
|
||||||
| `zsh/bchanot.zsh-theme` | oh-my-zsh theme reproducing the bash prompt: `✔ (12ms) user [ ~/dir ] [branch -*+] >`. |
|
| `zsh/bchanot.zsh-theme` | oh-my-zsh theme reproducing the bash prompt: `✔ (12ms) user [ ~/dir ] [branch -*+] >`. |
|
||||||
| `bin/dt` | dtach session manager for claude-in-dtach sessions. |
|
| `bin/dt` | dtach session manager for claude-in-dtach sessions. |
|
||||||
| `bin/dtach-router` | Dashboard to resume dtach sessions, shown at the start of every interactive shell (wired into `~/.bashrc` by the installer). |
|
| `bin/dtach-router` | Dashboard to resume dtach sessions, shown at the start of every interactive shell (wired into `~/.bashrc` by the installer). |
|
||||||
| `bin/claude-provider`| Switch Claude Code between Anthropic and OpenRouter. |
|
| `bin/tmux-copy-exit-keys` | Run by `tmux.conf` at load: after a mouse selection, any bare key leaves copy-mode (ctrl/alt keys and keyboard copy-mode keep their vi role). |
|
||||||
|
| `bin/repo-sync` | One local tree (`~/repos`) for every repository reachable on your forges (GitLab, GitHub, Gitea/Forgejo, Bitbucket Cloud), daily cache, `repo <project>` shell function to jump into one. |
|
||||||
| `etc/profile.d/disk-usage-warning.sh` | Login-time warning (bold red) when `/` or `/home` cross 85% usage. Deployed to `/etc/profile.d/` on Linux. |
|
| `etc/profile.d/disk-usage-warning.sh` | Login-time warning (bold red) when `/` or `/home` cross 85% usage. Deployed to `/etc/profile.d/` on Linux. |
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
@@ -42,10 +44,10 @@ curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/master/remote-instal
|
|||||||
### One-liner (clone + install)
|
### One-liner (clone + install)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/master/remote-install.sh | bash
|
curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/main/remote-install.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
`remote-install.sh` ensures `git` is present, clones the repo to `~/config` (or pulls if already there), then runs `install.sh`. Override with env vars: `REPO_URL=... CLONE_DIR=... BRANCH=... curl ... | bash`.
|
`remote-install.sh` ensures `git` is present, clones the repo to `~/config` (or pulls if already there), then runs `install.sh` with the terminal as its stdin, so the questions below (identity, push mode, macOS shell, offers) are asked even though the script arrives through a pipe. Override with env vars: `REPO_URL=... CLONE_DIR=... BRANCH=... curl ... | bash`.
|
||||||
|
|
||||||
> Piping a remote script into `bash` runs unreviewed code over the network. Read [`remote-install.sh`](remote-install.sh) first, or use the manual clone below.
|
> Piping a remote script into `bash` runs unreviewed code over the network. Read [`remote-install.sh`](remote-install.sh) first, or use the manual clone below.
|
||||||
|
|
||||||
@@ -61,35 +63,37 @@ No argument — the OS is auto-detected.
|
|||||||
What it does:
|
What it does:
|
||||||
|
|
||||||
1. On Debian/Ubuntu, installs a set of CLI/dev packages via `apt-get` (see below). On macOS, Homebrew does it instead: see [macOS](#macos).
|
1. On Debian/Ubuntu, installs a set of CLI/dev packages via `apt-get` (see below). On macOS, Homebrew does it instead: see [macOS](#macos).
|
||||||
2. Sets up Docker's official apt repo (Ubuntu) and installs the engine + compose plugin — skipped if `docker` is already present.
|
2. Sets up Docker's official apt repo (Ubuntu) and installs the engine + compose plugin + rootless extras — skipped if `docker` is already present.
|
||||||
3. Moves any existing `~/.vim`, `~/.vimrc`, `~/.bashrc`, `~/.Sublivim` to `~/Oldconfig`.
|
3. Moves any existing `~/.vim`, `~/.vimrc`, `~/.bashrc`, `~/.Sublivim` to `~/Oldconfig`.
|
||||||
4. Clones the `syntastic` and `nerdtree` vim plugins into `~/.vim/bundle/`.
|
4. Clones the `syntastic` and `nerdtree` vim plugins into `~/.vim/bundle/`.
|
||||||
5. Copies the tracked vim files into `~/.vim` and symlinks `~/.vimrc`.
|
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`. Renders it into `~/.bashrc` with the identity asked at the very start: a name and an email for git commits and vim headers. An `export USER=` / `export EMAIL=` already present in `~/.bashrc` or `~/.zshrc` is reused without asking, so a re-run never prompts twice; `IDENTITY_USER` / `IDENTITY_EMAIL` preset them; with no terminal attached it falls back to the login name and an empty email. The values live only in the deployed files, never in the repo. Then renders `gitconfig` into `~/.gitconfig` with the same name and email (skipped, push mode included, when the name or email is empty, e.g. a first install with no terminal and no `IDENTITY_EMAIL`). The installer asks once whether the gitflow hooks push every commit and merge (`true` or `false` exactly, Enter = `true`); a `true`/`false` already in `~/.gitconfig` is reused without asking and survives the redeploy; `DOTFILES_GITFLOW_AUTOPUSH=true|false` presets it for a non-interactive install, an existing `~/.gitconfig` value still winning (no terminal and no preset gives `true`; any other preset aborts the install); the render refuses to write a file where `@AUTOPUSH@` leaked, since a non-boolean value blocks every push. To switch later: `git config --global gitflow.autopush true|false`. 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. `core.hooksPath` is fixed to `~/.claude/githooks`, the gitflow hooks created by `make link` in the claude-config repo; the installer neither creates nor checks that directory. Being global, it makes git ignore each repo's `.git/hooks/` unless that repo sets its own `core.hooksPath`. 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.
|
7. Installs Python CLIs via `pipx` (`PyMuPDF` → `pymupdf`, `Markdown` → `markdown_py`) — skipped if `pipx` is absent. Then installs the **Rust toolchain** on both OSes with the official `rustup` script, as you, never `sudo`: `stable` toolchain, default profile (`rustc cargo rust-std rust-docs rustfmt clippy`) plus `rust-analyzer` and `rust-src` for IDE support. On a re-run an existing `rustup` is updated (`rustup update`) instead of reinstalled. The script runs with `--no-modify-path`: the deployed bashrc/zshrc source `~/.cargo/env` when it exists, which puts `~/.cargo/bin` on `PATH` once. `CARGO_HOME` and `RUSTUP_HOME` keep their defaults (`~/.cargo`, `~/.rustup`). `libssl-dev` (apt) / `openssl@3` (brew) are installed so crates on `openssl-sys` build.
|
||||||
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.
|
8. Copies the `bin/` scripts (`dt`, `dtach-router`, `repo-sync`, `tmux-copy-exit-keys`) 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.
|
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`).
|
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.
|
11. On Linux, **offers** (`[Y/n]`, Enter = yes) to install **`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. If accepted, then **offers** (`[Y/n]`) **RDP remote login** via `gnome-remote-desktop` (Wayland-native); no desktop means no RDP question. On **WSL** (`WSL_DISTRO_NAME` set or `microsoft` in `/proc/version`) both default to **no** (`[y/N]`): Windows owns the display, and the desktop drags in NetworkManager + systemd-resolved, which rewrite `/etc/resolv.conf` and break DNS for the rest of the install. With no terminal attached the default applies. The RDP setup 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.
|
13. On Linux, installs the **security baseline**: **fail2ban** (+ `nftables`, offered: default yes, no on WSL; started only when systemd runs) 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` (`/run/sshd` is created first, so the check also works when sshd is not running) and removed again if sshd rejects it, then reloaded with `systemctl try-reload-or-restart ssh` when `ssh.service` is active; otherwise (WSL, sshd never started) the drop-in stays in place and applies at the next sshd start. 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.
|
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.
|
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.
|
||||||
|
16. On Linux, at the very end, **offers** to set up **rootless Docker**: installs `uidmap dbus-user-session slirp4netns docker-ce-rootless-extras`, runs `dockerd-rootless-setuptool.sh install` as you (the apt package puts it in `/usr/bin`, so no `PATH` line is needed, unlike the `~/bin` install from `get.docker.com/rootless`), then `loginctl enable-linger` so the user daemon starts at boot. The tool creates `~/.config/systemd/user/docker.service` and switches the CLI to the `rootless` context; the deployed bashrc exports `DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock` whenever that socket exists, for tools that ignore contexts. The rootful daemon is disabled first (`systemctl disable --now docker.service docker.socket`, socket removed), as the docs recommend: `docker` then only talks to your user daemon. Needs `/etc/subuid` and `/etc/subgid` entries for the user (Ubuntu adds them at user creation).
|
||||||
|
|
||||||
### Packages installed (apt)
|
### Packages installed (apt)
|
||||||
|
|
||||||
- **Build / VCS / C dev**: `vim git git-lfs git-filter-repo gitleaks gcc make pkg-config dkms valgrind shellcheck gh git-delta` (`git-delta` = `delta`, the pager set in `gitconfig`)
|
- **Build / VCS / C dev**: `vim git git-lfs git-filter-repo gitleaks gcc make pkg-config dkms valgrind shellcheck gh git-delta` (`git-delta` = `delta`, the pager set in `gitconfig`)
|
||||||
- **Net / security / transport**: `curl gnupg ca-certificates apt-transport-https net-tools openssh-server cifs-utils lftp ftp`
|
- **Net / security / transport**: `curl gnupg ca-certificates apt-transport-https libssl-dev net-tools openssh-server cifs-utils lftp ftp` (`libssl-dev`: build dependency of the `openssl-sys` Rust crate)
|
||||||
- **Shell tooling**: `unzip tree tmux fzf dtach`
|
- **Shell tooling**: `unzip tree tmux fzf dtach`
|
||||||
- **Runtimes**: `nodejs python3-pip pipx php-cli`
|
- **Runtimes**: `nodejs python3-pip pipx php-cli`
|
||||||
- **Web stack (local WordPress/LAMP)**: `mariadb-server imagemagick php-mysql php-gd php-imagick php-mbstring php-xml php-intl php-curl` (unversioned `php-*` metapackages, so they follow the distro's PHP)
|
- **Web stack (local WordPress/LAMP)**: `mariadb-server imagemagick php-mysql php-gd php-imagick php-mbstring php-xml php-intl php-curl` (unversioned `php-*` metapackages, so they follow the distro's PHP)
|
||||||
- **Media / doc CLI**: `ffmpeg weasyprint poppler-utils qpdf webp libavif-bin`
|
- **Media / doc CLI**: `ffmpeg weasyprint poppler-utils qpdf webp libavif-bin`
|
||||||
- **Docker**: `docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin` (via Docker's repo)
|
- **Docker**: `docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras` (via Docker's repo)
|
||||||
- **Desktop / GPU**: `ubuntu-desktop-minimal` (always, Linux) + the distro-recommended NVIDIA driver via `ubuntu-drivers install` (only when an NVIDIA GPU is detected)
|
- **Desktop / GPU**: `ubuntu-desktop-minimal` (offered, Linux; default yes, no on WSL) + the distro-recommended NVIDIA driver via `ubuntu-drivers install` (only when an NVIDIA GPU is detected)
|
||||||
- **Remote access**: `gnome-remote-desktop openssl` (apt) + `code-server` (via its vendor install script, not apt) — RDP remote login + browser VS Code
|
- **Remote access**: `gnome-remote-desktop openssl` (apt, offered after the desktop) + `code-server` (via its vendor install script, not apt) — RDP remote login + browser VS Code
|
||||||
- **pipx**: `PyMuPDF` (`pymupdf`), `Markdown` (`markdown_py`)
|
- **pipx**: `PyMuPDF` (`pymupdf`), `Markdown` (`markdown_py`)
|
||||||
- **Security baseline (Linux, always)**: `fail2ban nftables unattended-upgrades`
|
- **Rust (rustup, not apt)**: `stable` toolchain, default profile + `rust-analyzer rust-src`
|
||||||
- **Optional (end-of-install offer, Linux)**: `earlyoom`
|
- **Security baseline (Linux)**: `unattended-upgrades` always; `fail2ban nftables` offered (default yes, no on WSL)
|
||||||
|
- **Optional (end-of-install offer, Linux)**: `earlyoom`; `uidmap dbus-user-session slirp4netns` (rootless Docker)
|
||||||
|
|
||||||
The script is re-runnable: each run re-backs up to `~/Oldconfig` (overwriting the previous backup), re-clones plugins, skips Docker if already installed, and re-deploys the `bin/` scripts.
|
The script is re-runnable: each run re-backs up to `~/Oldconfig` (overwriting the previous backup), re-clones plugins, skips Docker if already installed, and re-deploys the `bin/` scripts.
|
||||||
|
|
||||||
@@ -97,16 +101,32 @@ The script is re-runnable: each run re-backs up to `~/Oldconfig` (overwriting th
|
|||||||
|
|
||||||
### macOS
|
### macOS
|
||||||
|
|
||||||
The same `./install.sh` detects macOS and replaces `apt-get` with Homebrew. It first asks which login shell you want, **bash** or **zsh** (`[bash]` by default; answer in advance with `MACOS_SHELL=zsh ./install.sh`, and with no terminal attached it picks bash):
|
The same `./install.sh` detects macOS and replaces `apt-get` with Homebrew. After the identity and push-mode questions, it asks which login shell you want, **zsh** or **bash** (`[zsh]` by default; answer in advance with `MACOS_SHELL=bash ./install.sh`, and with no terminal attached it picks zsh):
|
||||||
|
|
||||||
1. Installs Homebrew with its official script when `brew` is missing (this also pulls the Xcode Command Line Tools: clang, make, git), then `brew update` + `brew upgrade`.
|
1. Installs Homebrew with its official script when `brew` is missing (this also pulls the Xcode Command Line Tools: clang, make, git), then `brew update` + `brew upgrade`.
|
||||||
2. Installs the apt list mapped to formulae: `vim git git-lfs git-filter-repo gitleaks pkgconf shellcheck gh git-delta curl gnupg lftp inetutils unzip tree tmux fzf dtach node python pipx php mariadb imagemagick ffmpeg weasyprint poppler qpdf webp libavif bash`. Brew's `php` already ships gd, mbstring, xml, intl, curl and mysql.
|
2. Installs the apt list mapped to formulae: `vim git git-lfs git-filter-repo gitleaks pkgconf shellcheck gh git-delta curl gnupg lftp inetutils openssl@3 unzip tree tmux fzf dtach node python pipx php mariadb imagemagick ffmpeg weasyprint poppler qpdf webp libavif bash`. Brew's `php` already ships gd, mbstring, xml, intl, curl and mysql.
|
||||||
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).
|
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.
|
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.
|
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` (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`.
|
||||||
**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. **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.
|
||||||
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.
|
**zsh** chosen: installs oh-my-zsh with its official script (unattended, skipped if `~/.oh-my-zsh` exists), renders `zsh/zshrc-osx` into `~/.zshrc` (same identity as the bashrc) and deploys 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.
|
||||||
|
|
||||||
|
### Terminal key mappings for tmux (by hand)
|
||||||
|
|
||||||
|
`tmux.conf` binds Alt+arrow (switch window) and Ctrl+Alt+arrow (switch pane) without the prefix. Cmd is not a modifier a terminal forwards, so on macOS iTerm2 must send the xterm Alt sequences itself: Settings → Profiles → *Default* → Keys → Key Mappings → `+`, action **Send Escape Sequence** (iTerm2 adds the leading `Esc`). This shadows iTerm2's own Cmd+arrow tab switching in that profile; `⌘⇧[` / `⌘⇧]` and `⌘1`…`⌘9` still switch its tabs.
|
||||||
|
|
||||||
|
| Shortcut | Sequence | tmux key | Action |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `⌘←` | `[1;3D` | `M-Left` | previous window |
|
||||||
|
| `⌘→` | `[1;3C` | `M-Right` | next window |
|
||||||
|
| `⌃⌘↑` | `[1;7A` | `C-M-Up` | pane above |
|
||||||
|
| `⌃⌘↓` | `[1;7B` | `C-M-Down` | pane below |
|
||||||
|
| `⌃⌘←` | `[1;7D` | `C-M-Left` | pane left |
|
||||||
|
| `⌃⌘→` | `[1;7C` | `C-M-Right` | pane right |
|
||||||
|
|
||||||
|
Linux / PC keyboard: Alt+arrow and Ctrl+Alt+arrow send those sequences natively (GNOME Terminal, xterm, kitty, alacritty), nothing to map. Two things can still swallow them before tmux: the desktop (GNOME binds Ctrl+Alt+arrow to workspace switching: Settings → Keyboard → Shortcuts → Navigation, clear or change *Switch to workspace left/right*), and an SSH session from a Mac, where the keys are whatever the local iTerm2 mapping sends. Not verified on Linux yet.
|
||||||
|
|
||||||
### CLI scripts (`bin/`)
|
### CLI scripts (`bin/`)
|
||||||
|
|
||||||
@@ -114,11 +134,12 @@ Deployed to `~/.local/bin` (the deployed bashrc adds this dir to `PATH`):
|
|||||||
|
|
||||||
- **`dt`** — manage claude-in-dtach sessions (`dt ls|at|kill`). Needs `dtach` + `fzf`.
|
- **`dt`** — manage claude-in-dtach sessions (`dt ls|at|kill`). Needs `dtach` + `fzf`.
|
||||||
- **`dtach-router`** — session dashboard shown at shell startup. It ships in the deployed bashrc and is **sourced** (not executed) in every interactive shell, so it also fires in VS Code Remote-SSH terminals (non-login shells that skip `~/.profile`). Silent no-op when no session exists. Create a session with `cc [name]`, re-open the menu anytime with `d` (both aliases from the bashrc). Needs `dt`, `dtach`, `fzf`.
|
- **`dtach-router`** — session dashboard shown at shell startup. It ships in the deployed bashrc and is **sourced** (not executed) in every interactive shell, so it also fires in VS Code Remote-SSH terminals (non-login shells that skip `~/.profile`). Silent no-op when no session exists. Create a session with `cc [name]`, re-open the menu anytime with `d` (both aliases from the bashrc). Needs `dt`, `dtach`, `fzf`.
|
||||||
- **`claude-provider`** — switch Claude Code between Anthropic and OpenRouter.
|
- **`repo-sync`** — one local tree for every git repository you can reach on your forges, same layout as the Alphalink `repo` zsh function: `~/repos/<namespace with / as @>/<project>` (`REPOS_DIR` overrides). Needs `jq`, `curl`, `git`.
|
||||||
OpenRouter mode reads the key from **`$OPENROUTER_API_KEY`** (never hardcoded). Export it from a private, untracked file, e.g. `~/.bashrc.local`:
|
- `repo-sync add` registers a forge (type `gitlab|github|gitea|bitbucket`, host, token asked on the terminal) in **`~/.config/repos/forges.conf`** (mode 0600, parsed line by line, never tracked). Run it once per access you have. GitHub Enterprise and self-hosted GitLab/Gitea work by host; Bitbucket is Cloud only (Atlassian email + API token).
|
||||||
```sh
|
- `repo-sync refresh` rebuilds the project list in `~/.cache/repos/list` when it is older than a day (`--force` to redo it now). The deployed rc files run it in the background at shell start, so the list is fresh at most once per day without a cron.
|
||||||
export OPENROUTER_API_KEY="<your-openrouter-key>"
|
- `repo-sync list|tree` shows the projects; `repo-sync clone [--filter REGEX] [--pull] [--dry-run] [--https]` clones everything missing.
|
||||||
```
|
- `repo <project> [namespace]` (shell function, bash and zsh, with completion) clones on demand and `cd`s into it. The token only lists projects; clones use ssh unless `--https`.
|
||||||
|
- The same `namespace/project` on two forges is kept once, from the first section of `forges.conf`. Archived projects and mirrors are skipped.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
|||||||
+106
-4
@@ -7,12 +7,27 @@ alias grep='grep --color=auto'
|
|||||||
# colored GCC warnings and errors
|
# colored GCC warnings and errors
|
||||||
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
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/)
|
# Ensure ~/.local/bin is on PATH (pipx CLIs + personal scripts from bin/)
|
||||||
case ":$PATH:" in
|
case ":$PATH:" in
|
||||||
*":$HOME/.local/bin:"*) ;;
|
*":$HOME/.local/bin:"*) ;;
|
||||||
*) export PATH="$HOME/.local/bin:$PATH" ;;
|
*) export PATH="$HOME/.local/bin:$PATH" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Rust toolchain (install.sh, rustup): puts ~/.cargo/bin on PATH, dedup done by the env file.
|
||||||
|
if [ -f "$HOME/.cargo/env" ]; then
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
. "$HOME/.cargo/env"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Rootless Docker (install.sh offer): tools that ignore the CLI context (docker-py,
|
||||||
|
# testcontainers...) need DOCKER_HOST; only set when the user daemon's socket exists.
|
||||||
|
if [ -S "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/docker.sock" ]; then
|
||||||
|
export DOCKER_HOST="unix://${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/docker.sock"
|
||||||
|
fi
|
||||||
|
|
||||||
# Set history size to unlimited
|
# Set history size to unlimited
|
||||||
if [[ $EUID == 0 ]] ; then
|
if [[ $EUID == 0 ]] ; then
|
||||||
export HISTSIZE=0
|
export HISTSIZE=0
|
||||||
@@ -25,9 +40,10 @@ fi
|
|||||||
#export LANG=en_US.UTF-8
|
#export LANG=en_US.UTF-8
|
||||||
|
|
||||||
|
|
||||||
# Identity for the vim header; install.sh also writes it into ~/.gitconfig
|
# Identity for git commits and vim headers. Filled by install.sh (asked once,
|
||||||
export USER=bchanot
|
# reused from an existing ~/.bashrc / ~/.zshrc on re-runs), never stored here.
|
||||||
export EMAIL=bchanot@gmail.fr
|
export USER="@USER@"
|
||||||
|
export EMAIL="@EMAIL@"
|
||||||
|
|
||||||
## Activate and custom bash completion
|
## Activate and custom bash completion
|
||||||
#bind 'TAB:menu-complete'
|
#bind 'TAB:menu-complete'
|
||||||
@@ -113,19 +129,105 @@ PROMPT_COMMAND='set_prompt'
|
|||||||
## Lancement des commandes au demarrages
|
## Lancement des commandes au demarrages
|
||||||
|
|
||||||
# claude-dans-dtach : creer une session (claude tournant dans dtach, detache via Ctrl-\).
|
# claude-dans-dtach : creer une session (claude tournant dans dtach, detache via Ctrl-\).
|
||||||
|
# Reprend la derniere conversation du dossier (--continue), sinon session neuve.
|
||||||
# Usage : cd ~/projets/seo && cc seo -> session nommee "seo".
|
# Usage : cd ~/projets/seo && cc seo -> session nommee "seo".
|
||||||
dtach_claude() {
|
dtach_claude() {
|
||||||
local name="${1:-claude-$(date +%H%M%S)}"
|
local name="${1:-claude-$(date +%H%M%S)}"
|
||||||
systemd-run --user --quiet --collect --scope --slice=dev.slice \
|
systemd-run --user --quiet --collect --scope --slice=dev.slice \
|
||||||
--unit="cc-${name}" \
|
--unit="cc-${name}" \
|
||||||
dtach -c "$HOME/.dtach/${name}" -e '^\' \
|
dtach -c "$HOME/.dtach/${name}" -e '^\' \
|
||||||
bash -c 'set -a; [ -f "$HOME/.claude/.env" ] && . "$HOME/.claude/.env"; set +a; exec claude'
|
bash -c 'set -a; [ -f "$HOME/.claude/.env" ] && . "$HOME/.claude/.env"; set +a; claude --continue || exec claude'
|
||||||
}
|
}
|
||||||
alias cc='dtach_claude'
|
alias cc='dtach_claude'
|
||||||
|
|
||||||
# Rappeler a la demande le menu de reprise.
|
# Rappeler a la demande le menu de reprise.
|
||||||
alias d='source ~/.local/bin/dtach-router'
|
alias d='source ~/.local/bin/dtach-router'
|
||||||
|
|
||||||
|
# openrouter : bascule Claude Code sur OpenRouter dans le shell courant (fonction, pas
|
||||||
|
# script : un script ne peut pas modifier l'environnement de son parent). `openrouter`
|
||||||
|
# active, `openrouter -d` (ou -u) desactive. La cle vient de $OPENROUTER_API_KEY, a
|
||||||
|
# exporter depuis un fichier prive non versionne (~/.bashrc.local, ~/.zshrc.local).
|
||||||
|
# Les valeurs qu'avaient deja ces variables sont gardees dans $_OPENROUTER_SAVED
|
||||||
|
# (commandes export/unset) et rejouees a la desactivation.
|
||||||
|
openrouter() {
|
||||||
|
local v saved=""
|
||||||
|
case "${1:-}" in
|
||||||
|
-d | -u)
|
||||||
|
if [ -n "${_OPENROUTER_SAVED+x}" ]; then
|
||||||
|
saved="$_OPENROUTER_SAVED"
|
||||||
|
elif [ "${ANTHROPIC_BASE_URL:-}" != "https://openrouter.ai/api" ]; then
|
||||||
|
echo "openrouter: not active"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
|
||||||
|
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY
|
||||||
|
eval "$saved"
|
||||||
|
unset _OPENROUTER_SAVED
|
||||||
|
echo "openrouter: off"
|
||||||
|
echo "Pensez a vous log in de Claude Code"
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
[ -n "${OPENROUTER_API_KEY:-}" ] || {
|
||||||
|
echo "openrouter: OPENROUTER_API_KEY is not set" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if [ -z "${_OPENROUTER_SAVED+x}" ]; then
|
||||||
|
for v in ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
|
||||||
|
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY; do
|
||||||
|
if printenv "$v" >/dev/null; then
|
||||||
|
saved="$saved export $v=$(printf %q "$(printenv "$v")");"
|
||||||
|
else
|
||||||
|
saved="$saved unset $v;"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
_OPENROUTER_SAVED="$saved"
|
||||||
|
fi
|
||||||
|
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
|
||||||
|
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
|
||||||
|
export ANTHROPIC_API_KEY="" # doit etre explicitement vide
|
||||||
|
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
|
||||||
|
echo "openrouter: on"
|
||||||
|
echo "Pensez a vous logout de Claude Code"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "usage: openrouter [-d|-u]" >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# repo-sync : un arbre local (~/repos) pour tous les depots des forges declarees
|
||||||
|
# dans ~/.config/repos/forges.conf. `repo <projet> [namespace]` clone si besoin
|
||||||
|
# puis s'y place ; la liste se rafraichit en arriere-plan, au plus 1 fois par jour.
|
||||||
|
repo() {
|
||||||
|
local dir
|
||||||
|
dir="$(repo-sync path "$@")" && cd "$dir" || return
|
||||||
|
}
|
||||||
|
_repo_complete() {
|
||||||
|
local cache="${REPOS_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/repos/list}" words
|
||||||
|
[ -f "$cache" ] || return 0
|
||||||
|
if [ "$COMP_CWORD" -eq 1 ]; then
|
||||||
|
words="$(cut -f1 "$cache" | sort -u)"
|
||||||
|
else
|
||||||
|
words="$(awk -F'\t' -v p="${COMP_WORDS[1]}" '$1 == p { print $2 }' "$cache")"
|
||||||
|
fi
|
||||||
|
# shellcheck disable=SC2207
|
||||||
|
COMPREPLY=($(compgen -W "$words" -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||||
|
}
|
||||||
|
complete -F _repo_complete repo
|
||||||
|
case $- in *i*) command -v repo-sync >/dev/null && (repo-sync refresh --quiet >/dev/null 2>&1 &) ;; esac
|
||||||
|
|
||||||
|
# SSH interactif hors tmux (et hors terminal VS Code Remote-SSH) : entrer dans tmux,
|
||||||
|
# session partagee "main" (rattachee si elle existe). Le shell lance dans tmux relit ce
|
||||||
|
# fichier et ouvre le menu dtach ci-dessous ; quitter tmux ferme la connexion (exec).
|
||||||
|
case $- in *i*)
|
||||||
|
if [ -n "${SSH_CONNECTION:-}" ] && [ -z "${TMUX:-}" ] \
|
||||||
|
&& [ "${TERM_PROGRAM:-}" != vscode ] && command -v tmux >/dev/null; then
|
||||||
|
exec tmux new-session -A -s main
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Au demarrage d'un shell interactif, proposer de reprendre une session dtach existante
|
# Au demarrage d'un shell interactif, proposer de reprendre une session dtach existante
|
||||||
# (silencieux si aucune). Place ici plutot que dans ~/.profile car les terminaux VS Code
|
# (silencieux si aucune). Place ici plutot que dans ~/.profile car les terminaux VS Code
|
||||||
# Remote-SSH sont non-login et ne lisent pas ~/.profile ; ~/.bashrc, lui, est toujours lu.
|
# Remote-SSH sont non-login et ne lisent pas ~/.profile ; ~/.bashrc, lui, est toujours lu.
|
||||||
|
|||||||
+100
-4
@@ -17,12 +17,21 @@ alias grep='grep --color=auto'
|
|||||||
# colored GCC warnings and errors
|
# colored GCC warnings and errors
|
||||||
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
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/)
|
# Ensure ~/.local/bin is on PATH (pipx CLIs + personal scripts from bin/)
|
||||||
case ":$PATH:" in
|
case ":$PATH:" in
|
||||||
*":$HOME/.local/bin:"*) ;;
|
*":$HOME/.local/bin:"*) ;;
|
||||||
*) export PATH="$HOME/.local/bin:$PATH" ;;
|
*) export PATH="$HOME/.local/bin:$PATH" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Rust toolchain (install.sh, rustup): puts ~/.cargo/bin on PATH, dedup done by the env file.
|
||||||
|
if [ -f "$HOME/.cargo/env" ]; then
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
. "$HOME/.cargo/env"
|
||||||
|
fi
|
||||||
|
|
||||||
# Set history size to unlimited
|
# Set history size to unlimited
|
||||||
if [[ $EUID == 0 ]] ; then
|
if [[ $EUID == 0 ]] ; then
|
||||||
export HISTSIZE=0
|
export HISTSIZE=0
|
||||||
@@ -35,9 +44,10 @@ fi
|
|||||||
#export LANG=en_US.UTF-8
|
#export LANG=en_US.UTF-8
|
||||||
|
|
||||||
|
|
||||||
# Identity for the vim header; install.sh also writes it into ~/.gitconfig
|
# Identity for git commits and vim headers. Filled by install.sh (asked once,
|
||||||
export USER=bchanot
|
# reused from an existing ~/.bashrc / ~/.zshrc on re-runs), never stored here.
|
||||||
export EMAIL=bchanot@gmail.fr
|
export USER="@USER@"
|
||||||
|
export EMAIL="@EMAIL@"
|
||||||
|
|
||||||
## Activate and custom bash completion
|
## Activate and custom bash completion
|
||||||
#bind 'TAB:menu-complete'
|
#bind 'TAB:menu-complete'
|
||||||
@@ -129,19 +139,105 @@ PROMPT_COMMAND='set_prompt'
|
|||||||
## Lancement des commandes au demarrages
|
## Lancement des commandes au demarrages
|
||||||
|
|
||||||
# claude-dans-dtach : creer une session (claude tournant dans dtach, detache via Ctrl-\).
|
# claude-dans-dtach : creer une session (claude tournant dans dtach, detache via Ctrl-\).
|
||||||
|
# Reprend la derniere conversation du dossier (--continue), sinon session neuve.
|
||||||
# Usage : cd ~/projets/seo && cc seo -> session nommee "seo".
|
# Usage : cd ~/projets/seo && cc seo -> session nommee "seo".
|
||||||
# Pas de systemd sur macOS : dtach est lance directement (pas de slice cgroup).
|
# Pas de systemd sur macOS : dtach est lance directement (pas de slice cgroup).
|
||||||
dtach_claude() {
|
dtach_claude() {
|
||||||
local name="${1:-claude-$(date +%H%M%S)}"
|
local name="${1:-claude-$(date +%H%M%S)}"
|
||||||
mkdir -p "$HOME/.dtach"
|
mkdir -p "$HOME/.dtach"
|
||||||
dtach -c "$HOME/.dtach/${name}" -e '^\' \
|
dtach -c "$HOME/.dtach/${name}" -e '^\' \
|
||||||
bash -c 'set -a; [ -f "$HOME/.claude/.env" ] && . "$HOME/.claude/.env"; set +a; exec claude'
|
bash -c 'set -a; [ -f "$HOME/.claude/.env" ] && . "$HOME/.claude/.env"; set +a; claude --continue || exec claude'
|
||||||
}
|
}
|
||||||
alias cc='dtach_claude'
|
alias cc='dtach_claude'
|
||||||
|
|
||||||
# Rappeler a la demande le menu de reprise.
|
# Rappeler a la demande le menu de reprise.
|
||||||
alias d='source ~/.local/bin/dtach-router'
|
alias d='source ~/.local/bin/dtach-router'
|
||||||
|
|
||||||
|
# openrouter : bascule Claude Code sur OpenRouter dans le shell courant (fonction, pas
|
||||||
|
# script : un script ne peut pas modifier l'environnement de son parent). `openrouter`
|
||||||
|
# active, `openrouter -d` (ou -u) desactive. La cle vient de $OPENROUTER_API_KEY, a
|
||||||
|
# exporter depuis un fichier prive non versionne (~/.bashrc.local, ~/.zshrc.local).
|
||||||
|
# Les valeurs qu'avaient deja ces variables sont gardees dans $_OPENROUTER_SAVED
|
||||||
|
# (commandes export/unset) et rejouees a la desactivation.
|
||||||
|
openrouter() {
|
||||||
|
local v saved=""
|
||||||
|
case "${1:-}" in
|
||||||
|
-d | -u)
|
||||||
|
if [ -n "${_OPENROUTER_SAVED+x}" ]; then
|
||||||
|
saved="$_OPENROUTER_SAVED"
|
||||||
|
elif [ "${ANTHROPIC_BASE_URL:-}" != "https://openrouter.ai/api" ]; then
|
||||||
|
echo "openrouter: not active"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
|
||||||
|
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY
|
||||||
|
eval "$saved"
|
||||||
|
unset _OPENROUTER_SAVED
|
||||||
|
echo "openrouter: off"
|
||||||
|
echo "Pensez a vous log in de Claude Code"
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
[ -n "${OPENROUTER_API_KEY:-}" ] || {
|
||||||
|
echo "openrouter: OPENROUTER_API_KEY is not set" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if [ -z "${_OPENROUTER_SAVED+x}" ]; then
|
||||||
|
for v in ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
|
||||||
|
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY; do
|
||||||
|
if printenv "$v" >/dev/null; then
|
||||||
|
saved="$saved export $v=$(printf %q "$(printenv "$v")");"
|
||||||
|
else
|
||||||
|
saved="$saved unset $v;"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
_OPENROUTER_SAVED="$saved"
|
||||||
|
fi
|
||||||
|
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
|
||||||
|
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
|
||||||
|
export ANTHROPIC_API_KEY="" # doit etre explicitement vide
|
||||||
|
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
|
||||||
|
echo "openrouter: on"
|
||||||
|
echo "Pensez a vous logout de Claude Code"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "usage: openrouter [-d|-u]" >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# repo-sync : un arbre local (~/repos) pour tous les depots des forges declarees
|
||||||
|
# dans ~/.config/repos/forges.conf. `repo <projet> [namespace]` clone si besoin
|
||||||
|
# puis s'y place ; la liste se rafraichit en arriere-plan, au plus 1 fois par jour.
|
||||||
|
repo() {
|
||||||
|
local dir
|
||||||
|
dir="$(repo-sync path "$@")" && cd "$dir" || return
|
||||||
|
}
|
||||||
|
_repo_complete() {
|
||||||
|
local cache="${REPOS_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/repos/list}" words
|
||||||
|
[ -f "$cache" ] || return 0
|
||||||
|
if [ "$COMP_CWORD" -eq 1 ]; then
|
||||||
|
words="$(cut -f1 "$cache" | sort -u)"
|
||||||
|
else
|
||||||
|
words="$(awk -F'\t' -v p="${COMP_WORDS[1]}" '$1 == p { print $2 }' "$cache")"
|
||||||
|
fi
|
||||||
|
# shellcheck disable=SC2207
|
||||||
|
COMPREPLY=($(compgen -W "$words" -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||||
|
}
|
||||||
|
complete -F _repo_complete repo
|
||||||
|
case $- in *i*) command -v repo-sync >/dev/null && (repo-sync refresh --quiet >/dev/null 2>&1 &) ;; esac
|
||||||
|
|
||||||
|
# SSH interactif hors tmux (et hors terminal VS Code Remote-SSH) : entrer dans tmux,
|
||||||
|
# session partagee "main" (rattachee si elle existe). Le shell lance dans tmux relit ce
|
||||||
|
# fichier et ouvre le menu dtach ci-dessous ; quitter tmux ferme la connexion (exec).
|
||||||
|
case $- in *i*)
|
||||||
|
if [ -n "${SSH_CONNECTION:-}" ] && [ -z "${TMUX:-}" ] \
|
||||||
|
&& [ "${TERM_PROGRAM:-}" != vscode ] && command -v tmux >/dev/null; then
|
||||||
|
exec tmux new-session -A -s main
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Au demarrage d'un shell interactif, proposer de reprendre une session dtach existante
|
# Au demarrage d'un shell interactif, proposer de reprendre une session dtach existante
|
||||||
# (silencieux si aucune). Place ici plutot que dans ~/.profile car les terminaux VS Code
|
# (silencieux si aucune). Place ici plutot que dans ~/.profile car les terminaux VS Code
|
||||||
# Remote-SSH sont non-login et ne lisent pas ~/.profile ; ~/.bashrc, lui, est toujours lu.
|
# Remote-SSH sont non-login et ne lisent pas ~/.profile ; ~/.bashrc, lui, est toujours lu.
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Switch Claude Code between Anthropic (default) and OpenRouter.
|
|
||||||
# Usage: claude-provider [anthropic|openrouter|status]
|
|
||||||
# After switching, re-source your shell or run: cpsource
|
|
||||||
#
|
|
||||||
# OpenRouter mode reads the API key from $OPENROUTER_API_KEY at source time —
|
|
||||||
# the key is NOT stored in this script or in the repo. Export it from a private,
|
|
||||||
# untracked location (e.g. ~/.bashrc.local):
|
|
||||||
# export OPENROUTER_API_KEY="<your-openrouter-key>"
|
|
||||||
|
|
||||||
PROVIDER_FILE="$HOME/.claude-provider-env"
|
|
||||||
|
|
||||||
write_anthropic() {
|
|
||||||
cat > "$PROVIDER_FILE" << 'EOF'
|
|
||||||
# Claude provider: Anthropic (default)
|
|
||||||
unset ANTHROPIC_BASE_URL
|
|
||||||
unset ANTHROPIC_API_KEY
|
|
||||||
unset ANTHROPIC_DEFAULT_SONNET_MODEL
|
|
||||||
export CLAUDE_PROVIDER="anthropic"
|
|
||||||
EOF
|
|
||||||
echo "Switched to Anthropic (default)."
|
|
||||||
echo "Run: cpsource (or restart your shell)"
|
|
||||||
}
|
|
||||||
|
|
||||||
write_openrouter() {
|
|
||||||
cat > "$PROVIDER_FILE" << 'EOF'
|
|
||||||
# Claude provider: OpenRouter
|
|
||||||
# Key comes from $OPENROUTER_API_KEY in your environment (never hardcoded here).
|
|
||||||
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
|
|
||||||
export ANTHROPIC_API_KEY="${OPENROUTER_API_KEY:?Set OPENROUTER_API_KEY in your environment to use OpenRouter}"
|
|
||||||
export CLAUDE_PROVIDER="openrouter"
|
|
||||||
export ANTHROPIC_DEFAULT_SONNET_MODEL="google/gemma-4-31b-it:free"
|
|
||||||
EOF
|
|
||||||
echo "Switched to OpenRouter."
|
|
||||||
echo "Run: cpsource (or restart your shell)"
|
|
||||||
}
|
|
||||||
|
|
||||||
show_status() {
|
|
||||||
local provider="${CLAUDE_PROVIDER:-anthropic}"
|
|
||||||
echo "Current provider: $provider"
|
|
||||||
if [ -f "$PROVIDER_FILE" ]; then
|
|
||||||
echo "Config file: $PROVIDER_FILE"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
case "${1:-status}" in
|
|
||||||
openrouter|or)
|
|
||||||
write_openrouter
|
|
||||||
;;
|
|
||||||
anthropic|an)
|
|
||||||
write_anthropic
|
|
||||||
;;
|
|
||||||
status|st)
|
|
||||||
show_status
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: claude-provider [anthropic|openrouter|status]"
|
|
||||||
echo " anthropic (an) — Use Anthropic directly (default)"
|
|
||||||
echo " openrouter (or) — Use OpenRouter proxy"
|
|
||||||
echo " status (st) — Show current provider"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
Executable
+358
@@ -0,0 +1,358 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# repo-sync — one local tree for every git repository you can reach on your
|
||||||
|
# forges (GitLab, GitHub, Gitea/Forgejo, Bitbucket Cloud), with a daily cache.
|
||||||
|
#
|
||||||
|
# repo-sync add register a forge (type, host, token)
|
||||||
|
# repo-sync refresh [--force] [--quiet] rebuild the cache if older than a day
|
||||||
|
# repo-sync list the cache: project, namespace, host
|
||||||
|
# repo-sync tree namespaces as a tree, project counts
|
||||||
|
# repo-sync path <project> [namespace] clone if missing, print the local path
|
||||||
|
# repo-sync clone [--filter RE] [--pull] [--dry-run] [--https] clone all
|
||||||
|
#
|
||||||
|
# Layout: $REPOS_DIR/<namespace with / as @>/<project> (default ~/repos)
|
||||||
|
# Forges: $REPOS_CONF, 0600, never tracked (default ~/.config/repos/forges.conf)
|
||||||
|
# [work]
|
||||||
|
# type = gitlab gitlab | github | gitea | bitbucket
|
||||||
|
# host = gitlab.example.com
|
||||||
|
# token = glpat-... bitbucket: user = <atlassian email>, token = api token
|
||||||
|
# The token only lists projects; clones use ssh unless --https.
|
||||||
|
# Same namespace/project on two forges: the first section wins. Archived
|
||||||
|
# projects and mirrors are skipped.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
REPOS_DIR="${REPOS_DIR:-$HOME/repos}"
|
||||||
|
REPOS_CONF="${REPOS_CONF:-$HOME/.config/repos/forges.conf}"
|
||||||
|
REPOS_CACHE="${REPOS_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/repos/list}"
|
||||||
|
REPOS_CACHE_MINUTES="${REPOS_CACHE_MINUTES:-1440}"
|
||||||
|
REPOS_CURL="${REPOS_CURL:-curl}"
|
||||||
|
|
||||||
|
die() { echo "repo-sync: $*" >&2; exit 1; }
|
||||||
|
usage() { sed -n '2,20p' "$0"; exit "${1:-0}"; }
|
||||||
|
|
||||||
|
# ── forges.conf ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
# Parse the INI line by line (never sourced). One TSV line per section:
|
||||||
|
# name type host user token (an empty user is "-": tab-separated read
|
||||||
|
# would otherwise merge two consecutive tabs and shift the token)
|
||||||
|
forges() {
|
||||||
|
[ -f "$REPOS_CONF" ] || return 0
|
||||||
|
awk '
|
||||||
|
function flush() {
|
||||||
|
if (!name) return
|
||||||
|
if (user == "") user = "-"
|
||||||
|
printf "%s\t%s\t%s\t%s\t%s\n", name, type, host, user, token
|
||||||
|
}
|
||||||
|
/^[ \t]*\[/ {
|
||||||
|
flush()
|
||||||
|
name = $0; gsub(/^[ \t]*\[|\][ \t]*$/, "", name)
|
||||||
|
type = host = user = token = ""
|
||||||
|
next
|
||||||
|
}
|
||||||
|
/^[ \t]*(#|$)/ { next }
|
||||||
|
{
|
||||||
|
key = $0; sub(/[ \t]*=.*/, "", key); gsub(/[ \t]/, "", key)
|
||||||
|
val = $0; sub(/^[^=]*=[ \t]*/, "", val); sub(/[ \t]+$/, "", val)
|
||||||
|
if (key == "type") type = val
|
||||||
|
else if (key == "host") host = val
|
||||||
|
else if (key == "user") user = val
|
||||||
|
else if (key == "token") token = val
|
||||||
|
}
|
||||||
|
END { flush() }
|
||||||
|
' "$REPOS_CONF"
|
||||||
|
}
|
||||||
|
|
||||||
|
ask() {
|
||||||
|
local label="$1" default="${2:-}" value
|
||||||
|
if [ -n "$default" ]; then
|
||||||
|
read -r -p "$label [$default]: " value
|
||||||
|
else
|
||||||
|
read -r -p "$label: " value
|
||||||
|
fi
|
||||||
|
echo "${value:-$default}"
|
||||||
|
}
|
||||||
|
|
||||||
|
ask_secret() {
|
||||||
|
local value
|
||||||
|
read -r -s -p "$1: " value
|
||||||
|
echo >&2
|
||||||
|
[ -n "$value" ] || die "a token is required"
|
||||||
|
echo "$value"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_add() {
|
||||||
|
[ -t 0 ] || die "add needs a terminal"
|
||||||
|
local name type host user="" token
|
||||||
|
name="$(ask "Name for this forge (e.g. work, home)")"
|
||||||
|
[[ "$name" =~ ^[A-Za-z0-9_-]+$ ]] || die "name: letters, digits, - and _ only"
|
||||||
|
type="$(ask "Type (gitlab|github|gitea|bitbucket)" gitlab)"
|
||||||
|
case "$type" in
|
||||||
|
gitlab|github|gitea|bitbucket) ;;
|
||||||
|
*) die "unknown type: $type" ;;
|
||||||
|
esac
|
||||||
|
case "$type" in
|
||||||
|
github) host="$(ask "Host" github.com)" ;;
|
||||||
|
bitbucket) host="bitbucket.org"; user="$(ask "Atlassian account email")" ;;
|
||||||
|
*) host="$(ask "Host (e.g. git.example.com)")" ;;
|
||||||
|
esac
|
||||||
|
[[ "$host" =~ ^[A-Za-z0-9.-]+$ ]] || die "host: hostname only, no scheme"
|
||||||
|
token="$(ask_secret "Token (read scope on repositories)")"
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$REPOS_CONF")"
|
||||||
|
( umask 077; touch "$REPOS_CONF" )
|
||||||
|
chmod 600 "$REPOS_CONF"
|
||||||
|
{
|
||||||
|
printf '\n[%s]\ntype = %s\nhost = %s\n' "$name" "$type" "$host"
|
||||||
|
[ -n "$user" ] && printf 'user = %s\n' "$user"
|
||||||
|
printf 'token = %s\n' "$token"
|
||||||
|
} >> "$REPOS_CONF"
|
||||||
|
echo "Saved to $REPOS_CONF"
|
||||||
|
cmd_refresh --force
|
||||||
|
}
|
||||||
|
|
||||||
|
# ── forge fetchers: each prints TSV "project namespace ssh_url https_url" ─
|
||||||
|
|
||||||
|
api() {
|
||||||
|
"$REPOS_CURL" -fsS --max-time 60 "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Page through a JSON-array endpoint: $1 = url without page, $2.. = curl auth.
|
||||||
|
paged_array() {
|
||||||
|
local url="$1" page=1 body
|
||||||
|
shift
|
||||||
|
while :; do
|
||||||
|
body="$(api "$@" "$url&page=$page")" || return 1
|
||||||
|
[ "$(printf '%s' "$body" | jq 'length')" -gt 0 ] || break
|
||||||
|
printf '%s\n' "$body"
|
||||||
|
page=$((page + 1))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch_gitlab() {
|
||||||
|
local host="$1" token="$2"
|
||||||
|
local url="https://$host/api/v4/projects"
|
||||||
|
url+="?membership=true&archived=false&per_page=100"
|
||||||
|
paged_array "$url" -H "PRIVATE-TOKEN: $token" |
|
||||||
|
jq -r '.[] | select(.mirror != true) |
|
||||||
|
[.path, .namespace.full_path, .ssh_url_to_repo, .http_url_to_repo] | @tsv'
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch_github() {
|
||||||
|
local host="$1" token="$2" base="https://api.github.com"
|
||||||
|
[ "$host" = "github.com" ] || base="https://$host/api/v3"
|
||||||
|
local url="$base/user/repos?per_page=100"
|
||||||
|
url+="&affiliation=owner,collaborator,organization_member"
|
||||||
|
paged_array "$url" -H "Authorization: Bearer $token" \
|
||||||
|
-H "Accept: application/vnd.github+json" |
|
||||||
|
jq -r '.[] | select(.archived != true) |
|
||||||
|
[.name, .owner.login, .ssh_url, .clone_url] | @tsv'
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch_gitea() {
|
||||||
|
local host="$1" token="$2"
|
||||||
|
paged_array "https://$host/api/v1/user/repos?limit=50" \
|
||||||
|
-H "Authorization: token $token" |
|
||||||
|
jq -r '.[] | select(.archived != true and .mirror != true) |
|
||||||
|
[.name, .owner.username, .ssh_url, .clone_url] | @tsv'
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch_bitbucket() {
|
||||||
|
local user="$1" token="$2" body
|
||||||
|
local url="https://api.bitbucket.org/2.0/repositories?role=member&pagelen=100"
|
||||||
|
while [ -n "$url" ] && [ "$url" != "null" ]; do
|
||||||
|
body="$(api -u "$user:$token" "$url")" || return 1
|
||||||
|
printf '%s' "$body" | jq -r '.values[] |
|
||||||
|
[.slug, .workspace.slug,
|
||||||
|
(.links.clone[] | select(.name == "ssh") | .href),
|
||||||
|
(.links.clone[] | select(.name == "https") | .href)] | @tsv'
|
||||||
|
url="$(printf '%s' "$body" | jq -r '.next')"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch_forge() {
|
||||||
|
local name="$1" type="$2" host="$3" user="$4" token="$5"
|
||||||
|
case "$type" in
|
||||||
|
gitlab) fetch_gitlab "$host" "$token" ;;
|
||||||
|
github) fetch_github "$host" "$token" ;;
|
||||||
|
gitea) fetch_gitea "$host" "$token" ;;
|
||||||
|
bitbucket) fetch_bitbucket "$user" "$token" ;;
|
||||||
|
*) echo "repo-sync: [$name] unknown type '$type', skipped" >&2; return 0 ;;
|
||||||
|
esac | awk -F'\t' -v host="$host" -v OFS='\t' '{ print $1, $2, host, $3, $4 }'
|
||||||
|
}
|
||||||
|
|
||||||
|
# ── cache ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
# Cache line: project namespace host ssh_url https_url
|
||||||
|
# Dedup key = namespace/project, case-insensitive; first forge in the conf wins.
|
||||||
|
fetch_all() {
|
||||||
|
local line name type host user token
|
||||||
|
while IFS=$'\t' read -r name type host user token; do
|
||||||
|
[ -n "$name" ] || continue
|
||||||
|
[ "$user" = "-" ] && user=""
|
||||||
|
fetch_forge "$name" "$type" "$host" "$user" "$token" ||
|
||||||
|
echo "repo-sync: [$name] $type on $host failed, skipped" >&2
|
||||||
|
done < <(forges) |
|
||||||
|
awk -F'\t' '{ key = tolower($2 "/" $1) } !seen[key]++' |
|
||||||
|
sort -t $'\t' -f -k2,2 -k1,1
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_is_fresh() {
|
||||||
|
[ -f "$REPOS_CACHE" ] &&
|
||||||
|
[ -z "$(find "$REPOS_CACHE" -mmin "+$REPOS_CACHE_MINUTES" 2>/dev/null)" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
# mkdir is atomic on every platform (flock is not on macOS); a lock older than
|
||||||
|
# ten minutes is a crashed run.
|
||||||
|
lock_cache() {
|
||||||
|
local lock="$REPOS_CACHE.lock"
|
||||||
|
[ -d "$lock" ] &&
|
||||||
|
find "$lock" -maxdepth 0 -mmin +10 -exec rmdir {} \; 2>/dev/null
|
||||||
|
mkdir "$lock" 2>/dev/null || return 1
|
||||||
|
# shellcheck disable=SC2064
|
||||||
|
trap "rmdir '$lock' 2>/dev/null" EXIT
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_refresh() {
|
||||||
|
local force=0 quiet=0 count
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--force) force=1 ;;
|
||||||
|
--quiet) quiet=1 ;;
|
||||||
|
*) die "refresh: unknown option $arg" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
if [ ! -f "$REPOS_CONF" ]; then
|
||||||
|
[ "$quiet" = 1 ] && exit 0
|
||||||
|
die "no forge yet: run repo-sync add"
|
||||||
|
fi
|
||||||
|
[ "$force" = 1 ] || ! cache_is_fresh || exit 0
|
||||||
|
mkdir -p "$(dirname "$REPOS_CACHE")"
|
||||||
|
lock_cache || exit 0
|
||||||
|
fetch_all > "$REPOS_CACHE.tmp"
|
||||||
|
mv "$REPOS_CACHE.tmp" "$REPOS_CACHE"
|
||||||
|
count="$(wc -l < "$REPOS_CACHE" | tr -d ' ')"
|
||||||
|
[ "$quiet" = 1 ] || echo "$count projects in $REPOS_CACHE"
|
||||||
|
}
|
||||||
|
|
||||||
|
need_cache() {
|
||||||
|
[ -f "$REPOS_CACHE" ] || cmd_refresh --force >&2
|
||||||
|
[ -s "$REPOS_CACHE" ] || die "empty cache: check $REPOS_CONF"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_list() {
|
||||||
|
need_cache
|
||||||
|
awk -F'\t' -v OFS='\t' '{ print $1, $2, $3 }' "$REPOS_CACHE" |
|
||||||
|
column -t -s $'\t'
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_tree() {
|
||||||
|
need_cache
|
||||||
|
awk -F'\t' '
|
||||||
|
{
|
||||||
|
n = split($2, parts, "/"); cur = ""
|
||||||
|
for (i = 1; i <= n; i++) {
|
||||||
|
parent = cur; cur = (cur ? cur "/" parts[i] : parts[i])
|
||||||
|
if (cur in seen) continue
|
||||||
|
seen[cur] = 1; kids[parent] = kids[parent] SUBSEP cur; name[cur] = parts[i]
|
||||||
|
}
|
||||||
|
leaf = cur "/" $1
|
||||||
|
kids[cur] = kids[cur] SUBSEP leaf; name[leaf] = $1; count[cur]++
|
||||||
|
}
|
||||||
|
function walk(node, prefix, last, items, n, i, k, label) {
|
||||||
|
if (node != "") {
|
||||||
|
label = name[node]; if (count[node]) label = label " (" count[node] ")"
|
||||||
|
printf "%s%s%s\n", prefix, (last ? "└── " : "├── "), label
|
||||||
|
prefix = prefix (last ? " " : "│ ")
|
||||||
|
}
|
||||||
|
n = split(kids[node], items, SUBSEP); k = 0
|
||||||
|
for (i = 1; i <= n; i++) if (items[i] != "") k++
|
||||||
|
for (i = 1; i <= n; i++) if (items[i] != "") walk(items[i], prefix, --k == 0)
|
||||||
|
}
|
||||||
|
END { walk("", "", 1) }
|
||||||
|
' "$REPOS_CACHE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ── clone ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
local_path() { echo "$REPOS_DIR/${2//\//@}/$1"; }
|
||||||
|
|
||||||
|
# Clone one cache line into its local path; pull it instead when --pull is set.
|
||||||
|
sync_one() {
|
||||||
|
local project="$1" namespace="$2" url="$3" pull="$4" dry="$5" dest
|
||||||
|
dest="$(local_path "$project" "$namespace")"
|
||||||
|
if [ -d "$dest/.git" ]; then
|
||||||
|
[ "$pull" = 1 ] || return 0
|
||||||
|
echo "pull $dest"
|
||||||
|
[ "$dry" = 1 ] || git -C "$dest" pull --ff-only --quiet ||
|
||||||
|
echo " pull failed: $dest" >&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
echo "clone $url -> $dest"
|
||||||
|
[ "$dry" = 1 ] && return 0
|
||||||
|
mkdir -p "$(dirname "$dest")"
|
||||||
|
git clone --quiet "$url" "$dest" || echo " clone failed: $url" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_clone() {
|
||||||
|
local filter=. pull=0 dry=0 col=4 lines
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--filter) filter="$2"; shift ;;
|
||||||
|
--pull) pull=1 ;;
|
||||||
|
--dry-run) dry=1 ;;
|
||||||
|
--https) col=5 ;;
|
||||||
|
*) die "clone: unknown option $1" ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
need_cache
|
||||||
|
lines="$(awk -F'\t' -v re="$filter" -v c="$col" -v OFS='\t' \
|
||||||
|
'$2 ~ re { print $1, $2, $c }' "$REPOS_CACHE")"
|
||||||
|
[ -n "$lines" ] || die "no project matches '$filter'"
|
||||||
|
echo "$(printf '%s\n' "$lines" | wc -l | tr -d ' ') projects, into $REPOS_DIR"
|
||||||
|
while IFS=$'\t' read -r project namespace url; do
|
||||||
|
sync_one "$project" "$namespace" "$url" "$pull" "$dry"
|
||||||
|
done <<< "$lines"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pick the cache line for a project: the given namespace, else the first one
|
||||||
|
# without a dot (groups before personal namespaces like j.doe).
|
||||||
|
resolve() {
|
||||||
|
local project="$1" namespace="${2:-}"
|
||||||
|
awk -F'\t' -v p="$project" -v ns="$namespace" '
|
||||||
|
$1 == p && (ns == "" || $2 == ns) {
|
||||||
|
if (!best || ($2 !~ /\./ && best ~ /\./)) { best = $2; line = $0 }
|
||||||
|
}
|
||||||
|
END { print line }
|
||||||
|
' "$REPOS_CACHE"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_path() {
|
||||||
|
[ $# -ge 1 ] || usage 2
|
||||||
|
need_cache
|
||||||
|
local line project namespace ssh dest
|
||||||
|
line="$(resolve "$1" "${2:-}")"
|
||||||
|
[ -n "$line" ] || die "unknown project: $1${2:+ in $2}"
|
||||||
|
IFS=$'\t' read -r project namespace _ ssh _ <<< "$line"
|
||||||
|
dest="$(local_path "$project" "$namespace")"
|
||||||
|
if [ ! -d "$dest/.git" ]; then
|
||||||
|
echo "clone $ssh -> $dest" >&2
|
||||||
|
mkdir -p "$(dirname "$dest")"
|
||||||
|
git clone --quiet "$ssh" "$dest" >&2 ||
|
||||||
|
{ rmdir "$dest" 2>/dev/null; die "clone failed: $ssh"; }
|
||||||
|
fi
|
||||||
|
echo "$dest"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ── dispatch ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
command -v jq >/dev/null || die "jq is required"
|
||||||
|
case "${1:-}" in
|
||||||
|
add) shift; cmd_add "$@" ;;
|
||||||
|
refresh) shift; cmd_refresh "$@" ;;
|
||||||
|
list) cmd_list ;;
|
||||||
|
tree) cmd_tree ;;
|
||||||
|
path) shift; cmd_path "$@" ;;
|
||||||
|
clone) shift; cmd_clone "$@" ;;
|
||||||
|
-h|--help|help) usage ;;
|
||||||
|
*) usage 2 ;;
|
||||||
|
esac
|
||||||
Executable
+77
@@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# tmux-copy-exit-keys: after a mouse selection, any unmodified key leaves
|
||||||
|
# copy-mode (back to the prompt; the key itself is swallowed).
|
||||||
|
#
|
||||||
|
# tmux.conf sets the pane option @mouse_sel when a mouse drag ends in
|
||||||
|
# copy-mode and clears it when the pane leaves copy-mode (pane-mode-changed
|
||||||
|
# hook). This script wraps every unmodified copy-mode-vi key: marker set, the
|
||||||
|
# key cancels copy-mode; marker unset (copy-mode opened from the keyboard or
|
||||||
|
# the wheel), the key keeps its vi role. Keys with ctrl/alt are untouched.
|
||||||
|
# tmux.conf runs it (run-shell) after the copy-mode bindings and the plugins:
|
||||||
|
# it wraps the bindings as they stand, so it must come last. Re-runnable:
|
||||||
|
# a key already wrapped is left alone. Needs bash 3.2 (macOS /bin/bash).
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
TABLE=copy-mode-vi
|
||||||
|
GUARD='if-shell -F "#{@mouse_sel}"' # the wrapper as list-keys prints it
|
||||||
|
|
||||||
|
# Every key a bare keypress can produce: letters, digits, ASCII punctuation,
|
||||||
|
# the French AZERTY extras, named editing and navigation keys.
|
||||||
|
plain_keys() {
|
||||||
|
printf '%s\n' {a..z} {A..Z} {0..9} \
|
||||||
|
'`' '~' '!' '@' '#' '$' '%' '^' '&' '*' '(' ')' '-' '_' '=' '+' \
|
||||||
|
'[' ']' '{' '}' "\\" '|' ';' ':' "'" '"' ',' '.' '<' '>' '/' '?' \
|
||||||
|
é è à ç ù § ° ² µ £ \
|
||||||
|
Space Enter Tab BSpace Escape Home End PPage NPage \
|
||||||
|
Up Down Left Right IC DC
|
||||||
|
}
|
||||||
|
|
||||||
|
# A key as the tmux config parser wants it (the form list-keys prints);
|
||||||
|
# ~ included, else the parser expands it to $HOME.
|
||||||
|
conf_key() {
|
||||||
|
case "$1" in
|
||||||
|
';' | '{' | '}' | '#' | '$' | '%' | '"' | "'" | "\\" | '~') printf '\\%s\n' "$1" ;;
|
||||||
|
*) printf '%s\n' "$1" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Current bindings of TABLE as "key<TAB>command" lines, keys in conf form.
|
||||||
|
# A -r (repeat) flag is dropped: no copy-mode key uses it.
|
||||||
|
current_bindings() {
|
||||||
|
tmux list-keys -T "$TABLE" \
|
||||||
|
| sed -E "s/^bind-key +(-r +)?-T $TABLE +([^ ]+) +(.*)\$/\\2$(printf '\t')\\3/"
|
||||||
|
}
|
||||||
|
|
||||||
|
# The command bound to conf key $1 in the dump $2, empty when unbound.
|
||||||
|
bound_command() {
|
||||||
|
awk -F '\t' -v k="$1" '$1 == k { print $2; exit }' "$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
# One bind-key line per plain key: marker set, cancel; else the current role.
|
||||||
|
emit_bindings() {
|
||||||
|
local dump="$1" key ck cmd
|
||||||
|
while IFS= read -r key; do
|
||||||
|
ck=$(conf_key "$key")
|
||||||
|
cmd=$(bound_command "$ck" "$dump")
|
||||||
|
case "$cmd" in "$GUARD"*) continue ;; esac
|
||||||
|
if [ -n "$cmd" ]; then
|
||||||
|
printf 'bind-key -T %s %s %s { send-keys -X cancel } { %s }\n' \
|
||||||
|
"$TABLE" "$ck" "$GUARD" "$cmd"
|
||||||
|
else
|
||||||
|
printf 'bind-key -T %s %s %s { send-keys -X cancel }\n' \
|
||||||
|
"$TABLE" "$ck" "$GUARD"
|
||||||
|
fi
|
||||||
|
done < <(plain_keys)
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local dump fragment
|
||||||
|
dump=$(mktemp) && fragment=$(mktemp)
|
||||||
|
# shellcheck disable=SC2064 # expand now: the locals are gone at EXIT
|
||||||
|
trap "rm -f '$dump' '$fragment'" EXIT
|
||||||
|
current_bindings > "$dump"
|
||||||
|
emit_bindings "$dump" > "$fragment"
|
||||||
|
tmux source-file "$fragment"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
# Template for the user-scope ~/.gitconfig, rendered by install.sh.
|
# Template for the user-scope ~/.gitconfig, rendered by install.sh. Git never
|
||||||
# Git never expands $VARS: @USER@ and @EMAIL@ are replaced at install
|
# expands $VARS, so the identity and the gitflow push mode are placeholders
|
||||||
# time with the USER and EMAIL exported by the deployed bashrc.
|
# filled at install time with the installer's answers. A repo .git/config
|
||||||
# A repo .git/config still overrides these values for that repo.
|
# still overrides these values for that repo.
|
||||||
[user]
|
[user]
|
||||||
name = @USER@
|
name = @USER@
|
||||||
email = @EMAIL@
|
email = @EMAIL@
|
||||||
|
[gitflow]
|
||||||
|
# Push mode of the gitflow hooks: false = manual, you run `git push`;
|
||||||
|
# true = every commit and merge is pushed. Exact true/false only (fail-closed).
|
||||||
|
autopush = @AUTOPUSH@
|
||||||
[push]
|
[push]
|
||||||
default = current
|
default = current
|
||||||
[color]
|
[color]
|
||||||
@@ -15,6 +19,8 @@
|
|||||||
editor = vim
|
editor = vim
|
||||||
pager = delta
|
pager = delta
|
||||||
excludesfile = ~/.gitignore
|
excludesfile = ~/.gitignore
|
||||||
|
# gitflow hooks (created by `make link` in claude-config); git expands ~ itself.
|
||||||
|
hooksPath = ~/.claude/githooks
|
||||||
[advice]
|
[advice]
|
||||||
detachedHead = false
|
detachedHead = false
|
||||||
[merge]
|
[merge]
|
||||||
|
|||||||
+345
-70
@@ -2,10 +2,16 @@
|
|||||||
# install.sh — deploy the vim + bash dotfiles. OS is auto-detected.
|
# install.sh — deploy the vim + bash dotfiles. OS is auto-detected.
|
||||||
# Usage: ./install.sh
|
# Usage: ./install.sh
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
# bash >= 5.2 expands `&` in ${var//pat/rep} replacements: an `&` in a name would
|
||||||
|
# corrupt the rendered identity. No-op on bash 3.2.
|
||||||
|
shopt -u patsub_replacement 2>/dev/null || true
|
||||||
|
|
||||||
# Resolve the repo root so the script works from any working directory.
|
# Resolve the repo root so the script works from any working directory.
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
|
||||||
|
# Helpers are defined below; the identity itself is resolved right before the
|
||||||
|
# OS-specific steps, so every prompt comes before the long package installs.
|
||||||
|
|
||||||
# Set up Docker's official Ubuntu apt repo, then install the engine + compose plugin.
|
# Set up Docker's official Ubuntu apt repo, then install the engine + compose plugin.
|
||||||
# Idempotent: skips entirely if docker is already on PATH. Ubuntu-only (uses the ubuntu repo).
|
# Idempotent: skips entirely if docker is already on PATH. Ubuntu-only (uses the ubuntu repo).
|
||||||
install_docker() {
|
install_docker() {
|
||||||
@@ -24,7 +30,8 @@ install_docker() {
|
|||||||
echo "deb [arch=${arch} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu ${codename} stable" |
|
echo "deb [arch=${arch} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu ${codename} stable" |
|
||||||
sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin \
|
||||||
|
docker-compose-plugin docker-ce-rootless-extras
|
||||||
}
|
}
|
||||||
|
|
||||||
# NVIDIA driver: only when an NVIDIA GPU is on the PCI bus (vendor id 10de), so the
|
# NVIDIA driver: only when an NVIDIA GPU is on the PCI bus (vendor id 10de), so the
|
||||||
@@ -152,14 +159,49 @@ unwire_dtach_profile() {
|
|||||||
' "$profile" > "$profile.tmp" && mv "$profile.tmp" "$profile"
|
' "$profile" > "$profile.tmp" && mv "$profile.tmp" "$profile"
|
||||||
}
|
}
|
||||||
|
|
||||||
# NAS helper: deploys the on-demand CloudPex SMB mount command to /usr/local/bin
|
# NAS helper, on request: deploys the on-demand CloudPex SMB mount command to
|
||||||
# (see cloudpex/README.md). Nothing is mounted and no credential is stored.
|
# /usr/local/bin (see cloudpex/README.md). Nothing is mounted and no credential is
|
||||||
# Linux-only (cifs-utils); the helper's own installer is idempotent.
|
# stored. Linux-only (cifs-utils); the helper's own installer is idempotent.
|
||||||
install_cloudpex() {
|
offer_cloudpex() {
|
||||||
echo "Installing the cloudpex mount helper"
|
confirm "Install the cloudpex NAS mount helper (on-demand SMB mount)?" || return 0
|
||||||
bash "$SCRIPT_DIR/cloudpex/install.sh"
|
bash "$SCRIPT_DIR/cloudpex/install.sh"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Rootless Docker, on request: a second daemon running as the login user (no root,
|
||||||
|
# no docker group), the docs' apt variant. docker-ce-rootless-extras ships
|
||||||
|
# dockerd-rootless-setuptool.sh in /usr/bin, so the PATH export the docs mention is
|
||||||
|
# not needed (that line is for the ~/bin install from get.docker.com/rootless). The
|
||||||
|
# setup tool writes ~/.config/systemd/user/docker.service, starts it and switches the
|
||||||
|
# CLI to the "rootless" context; linger keeps the daemon up without a login session.
|
||||||
|
# The rootful daemon is disabled first, as the docs recommend: one daemon, and the
|
||||||
|
# tool refuses to run while /var/run/docker.sock is writable by the user anyway.
|
||||||
|
# Idempotent: apt and the tool both skip what exists. Ubuntu-only (Docker apt repo).
|
||||||
|
offer_docker_rootless() {
|
||||||
|
confirm "Set up rootless Docker for $(id -un) (daemon runs as your user)?" || return 0
|
||||||
|
if ! sudo apt-get install -y uidmap dbus-user-session slirp4netns docker-ce-rootless-extras; then
|
||||||
|
echo "docker-ce-rootless-extras not installable (Docker apt repo missing?) — skipping" >&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if systemctl cat docker.service >/dev/null 2>&1; then
|
||||||
|
echo "Disabling the rootful Docker daemon (docker.service, docker.socket)"
|
||||||
|
sudo systemctl disable --now docker.service docker.socket
|
||||||
|
sudo rm -f /var/run/docker.sock
|
||||||
|
fi
|
||||||
|
if ! dockerd-rootless-setuptool.sh install; then
|
||||||
|
echo "rootless Docker setup failed — see the tool's output above (rootful daemon is disabled)" >&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sudo loginctl enable-linger "$(id -un)"
|
||||||
|
echo "Rootless Docker ready: CLI context 'rootless' selected; the bashrc exports DOCKER_HOST when its socket exists."
|
||||||
|
}
|
||||||
|
|
||||||
|
# True when systemd is PID 1. WSL distros without systemd=true in /wsl.conf (and
|
||||||
|
# containers) have none: apt still installs the packages, but every systemctl call
|
||||||
|
# fails and set -e would abort the install.
|
||||||
|
systemd_running() {
|
||||||
|
[ -d /run/systemd/system ]
|
||||||
|
}
|
||||||
|
|
||||||
# fail2ban: bans an IP on every port after repeated SSH failures. The sshd jail
|
# fail2ban: bans an IP on every port after repeated SSH failures. The sshd jail
|
||||||
# reads the journal (works with or without /var/log/auth.log) and bans all ports,
|
# reads the journal (works with or without /var/log/auth.log) and bans all ports,
|
||||||
# so the port sshd listens on does not matter — the previous server's jail only
|
# so the port sshd listens on does not matter — the previous server's jail only
|
||||||
@@ -170,8 +212,12 @@ install_fail2ban() {
|
|||||||
sudo apt-get install -y fail2ban nftables
|
sudo apt-get install -y fail2ban nftables
|
||||||
sudo install -D -m 0644 "$SCRIPT_DIR/etc/fail2ban/jail.d/local.conf" \
|
sudo install -D -m 0644 "$SCRIPT_DIR/etc/fail2ban/jail.d/local.conf" \
|
||||||
/etc/fail2ban/jail.d/local.conf
|
/etc/fail2ban/jail.d/local.conf
|
||||||
sudo systemctl enable fail2ban
|
if systemd_running; then
|
||||||
sudo systemctl restart fail2ban
|
sudo systemctl enable fail2ban
|
||||||
|
sudo systemctl restart fail2ban
|
||||||
|
else
|
||||||
|
echo "systemd not running (WSL?) — fail2ban installed, not started. Enable systemd=true in /wsl.conf, then: sudo systemctl enable --now fail2ban" >&2
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Automatic security updates: the file dpkg-reconfigure would write, deployed
|
# Automatic security updates: the file dpkg-reconfigure would write, deployed
|
||||||
@@ -185,38 +231,97 @@ install_unattended_upgrades() {
|
|||||||
|
|
||||||
# sshd hardening drop-in (PermitRootLogin, MaxAuthTries, LoginGraceTime): only
|
# sshd hardening drop-in (PermitRootLogin, MaxAuthTries, LoginGraceTime): only
|
||||||
# settings that cannot lock anyone out; authentication methods stay untouched.
|
# settings that cannot lock anyone out; authentication methods stay untouched.
|
||||||
# Validated with sshd -t before the reload. A rejected file is removed rather than
|
# Validated with sshd -t (/run/sshd is created first so the check works without a
|
||||||
# left in place, so sshd keeps starting on the next boot; the install goes on and
|
# running sshd); the reload happens only when sshd is running. A rejected file is
|
||||||
# the warning tells you.
|
# removed rather than left in place, so sshd keeps starting on the next boot; the
|
||||||
|
# install goes on and the warning tells you.
|
||||||
harden_sshd() {
|
harden_sshd() {
|
||||||
echo "Deploying sshd hardening drop-in"
|
echo "Deploying sshd hardening drop-in"
|
||||||
sudo install -D -m 0644 "$SCRIPT_DIR/etc/ssh/sshd_config.d/20-hardening.conf" \
|
sudo install -D -m 0644 "$SCRIPT_DIR/etc/ssh/sshd_config.d/20-hardening.conf" \
|
||||||
/etc/ssh/sshd_config.d/20-hardening.conf
|
/etc/ssh/sshd_config.d/20-hardening.conf
|
||||||
|
sudo install -d -m 0755 /run/sshd
|
||||||
if ! sudo sshd -t; then
|
if ! sudo sshd -t; then
|
||||||
sudo rm -f /etc/ssh/sshd_config.d/20-hardening.conf
|
sudo rm -f /etc/ssh/sshd_config.d/20-hardening.conf
|
||||||
echo "sshd rejected 20-hardening.conf — removed, sshd config unchanged" >&2
|
echo "sshd rejected 20-hardening.conf — removed, sshd config unchanged" >&2
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
sudo systemctl reload ssh
|
if systemctl is-active --quiet ssh; then
|
||||||
|
sudo systemctl try-reload-or-restart ssh
|
||||||
|
else
|
||||||
|
echo "ssh.service not running — drop-in in place, applies at the next sshd start"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Yes/no prompt for the optional system changes offered at the end of the install.
|
# Yes/no prompt for the optional system changes. $2 is the default taken on Enter:
|
||||||
# Declines (returns 1) when no terminal is attached (curl | bash), so an offer is
|
# "n" (the default, offers shown [y/N]) or "y" (shown [Y/n]). With no terminal attached
|
||||||
# skipped with a hint instead of blocking; re-run ./install.sh from a terminal to
|
# (curl | bash) the default is applied without blocking: a declined offer is skipped
|
||||||
# get it offered again.
|
# with a hint, re-run ./install.sh from a terminal to get it offered again.
|
||||||
confirm() {
|
confirm() {
|
||||||
local answer=""
|
local answer="" default="${2:-n}"
|
||||||
if [ ! -t 0 ]; then
|
if [ ! -t 0 ]; then
|
||||||
|
if [ "$default" = y ]; then
|
||||||
|
echo "No terminal attached, default yes: $1" >&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
echo "Skipped (no terminal attached): $1" >&2
|
echo "Skipped (no terminal attached): $1" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
read -rp "$1 [y/N] " answer || true
|
if [ "$default" = y ]; then
|
||||||
|
read -rp "$1 [Y/n] " answer || true
|
||||||
|
else
|
||||||
|
read -rp "$1 [y/N] " answer || true
|
||||||
|
fi
|
||||||
case "$answer" in
|
case "$answer" in
|
||||||
[yY]|[yY][eE][sS]) return 0 ;;
|
[yY]|[yY][eE][sS]) return 0 ;;
|
||||||
|
[nN]|[nN][oO]) return 1 ;;
|
||||||
|
"") [ "$default" = y ] ;;
|
||||||
*) return 1 ;;
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# fail2ban offer, yes by default ([Y/n]); on WSL the default flips to no: sshd is
|
||||||
|
# rarely exposed there and, without systemd, the service cannot run anyway.
|
||||||
|
offer_fail2ban() {
|
||||||
|
local default=y
|
||||||
|
is_wsl && default=n
|
||||||
|
if ! confirm "Install fail2ban (bans SSH brute-force IPs on every port)?" "$default"; then
|
||||||
|
echo "fail2ban skipped."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
install_fail2ban
|
||||||
|
}
|
||||||
|
|
||||||
|
# WSL (Windows Subsystem for Linux): no GDM, no GNOME session, no RDP target — the
|
||||||
|
# Windows side owns the display. Detected from the env var WSL sets, else the kernel
|
||||||
|
# string.
|
||||||
|
is_wsl() {
|
||||||
|
[ -n "${WSL_DISTRO_NAME:-}" ] || grep -qi microsoft /proc/version 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
# GNOME desktop (GDM + Shell, ubuntu-desktop-minimal, ~1.5 GB) and, on top of it, the
|
||||||
|
# RDP remote login (gnome-remote-desktop, see setup_remote_desktop). Both asked, yes by
|
||||||
|
# default: a headless server or a local workstation wants them, WSL does not — there
|
||||||
|
# the default flips to no. The desktop pulls NetworkManager + systemd-resolved, which
|
||||||
|
# on WSL rewrite /etc/resolv.conf and kill DNS mid-install, so declining is also what
|
||||||
|
# keeps the rest of the install working. RDP needs a GNOME session: no desktop, no RDP.
|
||||||
|
offer_desktop() {
|
||||||
|
local default=y
|
||||||
|
if is_wsl; then
|
||||||
|
echo "WSL detected: a GNOME desktop and RDP remote login are not useful here (Windows owns the display)."
|
||||||
|
default=n
|
||||||
|
fi
|
||||||
|
if ! confirm "Install the GNOME desktop (ubuntu-desktop-minimal, ~1.5 GB)?" "$default"; then
|
||||||
|
echo "GNOME desktop and RDP remote login skipped."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sudo apt-get install -y ubuntu-desktop-minimal
|
||||||
|
if confirm "Set up RDP remote login (gnome-remote-desktop, port 3389)?" "$default"; then
|
||||||
|
setup_remote_desktop
|
||||||
|
else
|
||||||
|
echo "RDP remote login skipped."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# /tmp on disk instead of the tmpfs Ubuntu mounts by default (RAM-backed, capped at
|
# /tmp on disk instead of the tmpfs Ubuntu mounts by default (RAM-backed, capped at
|
||||||
# 50% of RAM). Agent runs fill it: that eats half the RAM and, once the cap is hit,
|
# 50% of RAM). Agent runs fill it: that eats half the RAM and, once the cap is hit,
|
||||||
# every temp-file creation fails with ENOSPC — which is what breaks shells. Masking
|
# every temp-file creation fails with ENOSPC — which is what breaks shells. Masking
|
||||||
@@ -259,6 +364,10 @@ offer_ssh_memory_guard() {
|
|||||||
echo "SSH memory guard already in place — skipping"
|
echo "SSH memory guard already in place — skipping"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
if ! systemd_running; then
|
||||||
|
echo "systemd not running (WSL?) — SSH memory guard skipped" >&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
confirm "Protect SSH under memory pressure (sshd OOM-exempt + earlyoom)?" || return 0
|
confirm "Protect SSH under memory pressure (sshd OOM-exempt + earlyoom)?" || return 0
|
||||||
if [ "$ssh_done" = 0 ]; then
|
if [ "$ssh_done" = 0 ]; then
|
||||||
sudo install -D -m 0644 "$SCRIPT_DIR/etc/systemd/ssh.service.d/override.conf" "$dropin"
|
sudo install -D -m 0644 "$SCRIPT_DIR/etc/systemd/ssh.service.d/override.conf" "$dropin"
|
||||||
@@ -304,7 +413,7 @@ install_brew_packages() {
|
|||||||
brew upgrade
|
brew upgrade
|
||||||
brew install \
|
brew install \
|
||||||
vim git git-lfs git-filter-repo gitleaks pkgconf shellcheck gh git-delta \
|
vim git git-lfs git-filter-repo gitleaks pkgconf shellcheck gh git-delta \
|
||||||
curl gnupg lftp inetutils \
|
curl gnupg lftp inetutils jq openssl@3 \
|
||||||
unzip tree tmux fzf dtach \
|
unzip tree tmux fzf dtach \
|
||||||
node python pipx php \
|
node python pipx php \
|
||||||
mariadb imagemagick \
|
mariadb imagemagick \
|
||||||
@@ -312,6 +421,24 @@ install_brew_packages() {
|
|||||||
bash
|
bash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Rust toolchain via rustup, as the user (never sudo), on both OSes: the apt rustc lags
|
||||||
|
# stable by months and brew's rust ships no rustup. --no-modify-path: the rc files this
|
||||||
|
# repo deploys source ~/.cargo/env themselves. Idempotent: an existing rustup is updated
|
||||||
|
# instead of reinstalled; a component already present is a no-op.
|
||||||
|
install_rust() {
|
||||||
|
local cargo_bin="$HOME/.cargo/bin"
|
||||||
|
if [ -x "$cargo_bin/rustup" ]; then
|
||||||
|
echo "Updating Rust toolchain (rustup update)"
|
||||||
|
"$cargo_bin/rustup" update
|
||||||
|
else
|
||||||
|
echo "Installing Rust toolchain (rustup, stable, default profile)"
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
||||||
|
| sh -s -- -y --no-modify-path --default-toolchain stable --profile default
|
||||||
|
fi
|
||||||
|
# default profile = rustc cargo rust-std rust-docs rustfmt clippy; add the IDE pair.
|
||||||
|
"$cargo_bin/rustup" component add rust-analyzer rust-src
|
||||||
|
}
|
||||||
|
|
||||||
# Start a Homebrew service at login, like systemctl enable --now. Skipped when
|
# Start a Homebrew service at login, like systemctl enable --now. Skipped when
|
||||||
# already started, so a re-run never restarts a running database or VM.
|
# already started, so a re-run never restarts a running database or VM.
|
||||||
start_brew_service() {
|
start_brew_service() {
|
||||||
@@ -342,18 +469,19 @@ install_colima_docker() {
|
|||||||
start_brew_service colima
|
start_brew_service colima
|
||||||
}
|
}
|
||||||
|
|
||||||
# macOS login shell: bash (brew's bash 5 + bashrc-osx) or zsh (oh-my-zsh +
|
# macOS login shell: zsh (oh-my-zsh + zshrc-osx, the macOS default) or bash
|
||||||
# zshrc-osx). MACOS_SHELL=bash|zsh answers in advance; with no terminal attached
|
# (brew's bash 5 + bashrc-osx). MACOS_SHELL=bash|zsh answers in advance; with no
|
||||||
# and no answer, bash. Prints the choice on stdout (the question goes to stderr).
|
# terminal attached and no answer, zsh. Prints the choice on stdout (the question
|
||||||
|
# goes to stderr).
|
||||||
choose_macos_shell() {
|
choose_macos_shell() {
|
||||||
local answer="${MACOS_SHELL:-}"
|
local answer="${MACOS_SHELL:-}"
|
||||||
if [ -z "$answer" ] && [ -t 0 ]; then
|
if [ -z "$answer" ] && [ -t 0 ]; then
|
||||||
read -rp "Login shell on macOS: bash or zsh (oh-my-zsh)? [bash] " answer || true
|
read -rp "Login shell on macOS: zsh (oh-my-zsh) or bash? [zsh] " answer || true
|
||||||
fi
|
fi
|
||||||
case "$answer" in
|
case "$answer" in
|
||||||
zsh) echo zsh ;;
|
zsh|"") echo zsh ;;
|
||||||
bash|"") echo bash ;;
|
bash) echo bash ;;
|
||||||
*) echo "Unknown shell '$answer' — using bash" >&2; echo bash ;;
|
*) echo "Unknown shell '$answer' — using zsh" >&2; echo zsh ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,32 +520,84 @@ install_oh_my_zsh() {
|
|||||||
# ~/.zshrc.backup-<date>, not in ~/Oldconfig: that dir is wiped on every run, so
|
# ~/.zshrc.backup-<date>, not in ~/Oldconfig: that dir is wiped on every run, so
|
||||||
# a second run would destroy the original (and its nvm/bun lines).
|
# a second run would destroy the original (and its nvm/bun lines).
|
||||||
deploy_zsh_config() {
|
deploy_zsh_config() {
|
||||||
|
local name="$1" email="$2" rendered backup
|
||||||
local themes="$HOME/.oh-my-zsh/custom/themes"
|
local themes="$HOME/.oh-my-zsh/custom/themes"
|
||||||
local backup
|
|
||||||
backup="$HOME/.zshrc.backup-$(date +%Y%m%d-%H%M%S)"
|
backup="$HOME/.zshrc.backup-$(date +%Y%m%d-%H%M%S)"
|
||||||
if [ -e "$HOME/.zshrc" ] && ! cmp -s "$HOME/.zshrc" "$SCRIPT_DIR/zsh/zshrc-osx"; then
|
rendered="$(render_identity_template "$SCRIPT_DIR/zsh/zshrc-osx" "$name" "$email")"
|
||||||
|
if [ -e "$HOME/.zshrc" ] && ! printf '%s\n' "$rendered" | cmp -s - "$HOME/.zshrc"; then
|
||||||
echo "Saving the current ~/.zshrc to $backup"
|
echo "Saving the current ~/.zshrc to $backup"
|
||||||
mv "$HOME/.zshrc" "$backup"
|
mv "$HOME/.zshrc" "$backup"
|
||||||
fi
|
fi
|
||||||
echo "Deploying zsh/zshrc-osx + bchanot theme"
|
echo "Deploying zsh/zshrc-osx + bchanot theme ($name <$email>)"
|
||||||
cp "$SCRIPT_DIR/zsh/zshrc-osx" "$HOME/.zshrc"
|
printf '%s\n' "$rendered" > "$HOME/.zshrc"
|
||||||
mkdir -p "$themes"
|
mkdir -p "$themes"
|
||||||
cp "$SCRIPT_DIR/zsh/bchanot.zsh-theme" "$themes/"
|
cp "$SCRIPT_DIR/zsh/bchanot.zsh-theme" "$themes/"
|
||||||
}
|
}
|
||||||
|
|
||||||
# The chosen macOS shell: zsh gets oh-my-zsh + its config; bash needs brew's
|
# The chosen macOS shell ($1): zsh gets oh-my-zsh + its config rendered with the
|
||||||
# bash 5 (macOS ships 3.2, too old for the bashrc). Either way it becomes the
|
# identity ($2 name, $3 email); bash needs brew's bash 5 (macOS ships 3.2, too
|
||||||
# login shell, so new terminals load the matching config.
|
# old for the bashrc). Either way it becomes the login shell, so new terminals
|
||||||
|
# load the matching config.
|
||||||
setup_macos_shell() {
|
setup_macos_shell() {
|
||||||
if [ "$1" = zsh ]; then
|
if [ "$1" = zsh ]; then
|
||||||
install_oh_my_zsh
|
install_oh_my_zsh
|
||||||
deploy_zsh_config
|
deploy_zsh_config "$2" "$3"
|
||||||
set_login_shell /bin/zsh
|
set_login_shell /bin/zsh
|
||||||
else
|
else
|
||||||
set_login_shell "$(brew --prefix)/bin/bash"
|
set_login_shell "$(brew --prefix)/bin/bash"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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)"
|
||||||
|
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 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)"
|
||||||
|
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.
|
# macOS terminals open LOGIN shells, which read ~/.bash_profile and never ~/.bashrc.
|
||||||
# Appends one line sourcing ~/.bashrc. Idempotent: skipped when already present.
|
# Appends one line sourcing ~/.bashrc. Idempotent: skipped when already present.
|
||||||
wire_bash_profile() {
|
wire_bash_profile() {
|
||||||
@@ -436,31 +616,111 @@ rc_export_value() {
|
|||||||
sed -n "s/^export $1=//p" "$2" | tail -n 1 | tr -d "\"'"
|
sed -n "s/^export $1=//p" "$2" | tail -n 1 | tr -d "\"'"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print the repo gitconfig template with @USER@ and @EMAIL@ replaced by $1 and
|
# Print the template $1 with @USER@ and @EMAIL@ replaced by $2 and $3. Bash
|
||||||
# $2. Bash substitution, so the values need no sed escaping.
|
# substitution, so the values need no sed escaping.
|
||||||
render_gitconfig() {
|
render_identity_template() {
|
||||||
local name="$1" email="$2" line
|
local file="$1" name="$2" email="$3" line
|
||||||
while IFS= read -r line || [ -n "$line" ]; do
|
while IFS= read -r line || [ -n "$line" ]; do
|
||||||
line="${line//@USER@/$name}"
|
line="${line//@USER@/$name}"
|
||||||
line="${line//@EMAIL@/$email}"
|
line="${line//@EMAIL@/$email}"
|
||||||
printf '%s\n' "$line"
|
printf '%s\n' "$line"
|
||||||
done < "$SCRIPT_DIR/gitconfig"
|
done < "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# One identity value (USER or EMAIL, $1) for git commits, vim headers and the rc
|
||||||
|
# exports. Never stored in the repo. An export already in the rc of the running
|
||||||
|
# shell ($SHELL, else the other rc) wins silently (a re-run never asks twice;
|
||||||
|
# the env is not read: a fresh machine's $USER is the login name, which would
|
||||||
|
# skip the prompt), else IDENTITY_<VAR> from the
|
||||||
|
# environment, else a prompt ($2 label, $3 default) when a terminal is attached,
|
||||||
|
# else the default. Prints the value.
|
||||||
|
resolve_identity() {
|
||||||
|
local var="$1" label="$2" default="$3" value="" rc envvar="IDENTITY_$1"
|
||||||
|
local rcs=("$HOME/.bashrc" "$HOME/.zshrc")
|
||||||
|
[ "$(basename "${SHELL:-}")" = zsh ] && rcs=("$HOME/.zshrc" "$HOME/.bashrc")
|
||||||
|
for rc in "${rcs[@]}"; do
|
||||||
|
[ -f "$rc" ] && value="$(rc_export_value "$var" "$rc")"
|
||||||
|
if [ -n "$value" ] && [ "$value" != "@$var@" ]; then
|
||||||
|
printf '%s\n' "$value"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
value="${!envvar:-}"
|
||||||
|
if [ -z "$value" ] && [ -t 0 ]; then
|
||||||
|
read -rp "$label [$default]: " value || true
|
||||||
|
fi
|
||||||
|
printf '%s\n' "${value:-$default}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ask the push question on the terminal until the answer is exactly true or false;
|
||||||
|
# Enter (or EOF) = true. Prints the value.
|
||||||
|
ask_autopush() {
|
||||||
|
local answer=""
|
||||||
|
while :; do
|
||||||
|
read -rp "Automatic push of commits by the gitflow hooks on this machine? [true/false] (default: true) " answer || true
|
||||||
|
case "${answer:-true}" in
|
||||||
|
true|false) printf '%s\n' "${answer:-true}"; return 0 ;;
|
||||||
|
*) echo "Answer exactly true or false." >&2 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Push mode of the gitflow hooks (gitflow.autopush), exact true/false only: the
|
||||||
|
# readers fail closed on anything else. Never asked twice: a true/false already in
|
||||||
|
# ~/.gitconfig wins silently (read with sed, like rc_export_value, so a hand-set
|
||||||
|
# value survives the redeploy; a non-exact spelling is named and re-asked), else
|
||||||
|
# DOTFILES_GITFLOW_AUTOPUSH (anything but true/false aborts the install here,
|
||||||
|
# before any file is touched, whatever ~/.gitconfig holds), else the prompt
|
||||||
|
# on a terminal, else true (today's unset = auto). Prints the value.
|
||||||
|
resolve_autopush() {
|
||||||
|
local value="" preset="${DOTFILES_GITFLOW_AUTOPUSH:-}"
|
||||||
|
case "$preset" in
|
||||||
|
true|false|"") ;;
|
||||||
|
*) echo "DOTFILES_GITFLOW_AUTOPUSH='$preset' — must be exactly true or false" >&2; return 1 ;;
|
||||||
|
esac
|
||||||
|
if [ -f "$HOME/.gitconfig" ]; then
|
||||||
|
value="$(sed -n 's/^[[:space:]]*autopush[[:space:]]*=[[:space:]]*//p' "$HOME/.gitconfig" | tail -n 1)"
|
||||||
|
case "$value" in
|
||||||
|
true|false) printf '%s\n' "$value"; return 0 ;;
|
||||||
|
"") ;;
|
||||||
|
*) echo "gitflow.autopush='$value' in ~/.gitconfig is not exactly true/false — asking again" >&2 ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
if [ -n "$preset" ]; then printf '%s\n' "$preset"; return 0; fi
|
||||||
|
if [ -t 0 ]; then ask_autopush; else echo true; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Print the gitconfig template with the identity ($1 name, $2 email) and the push
|
||||||
|
# mode ($3) filled in. Fails, printing nothing, when the mode is not exactly
|
||||||
|
# true/false or when @AUTOPUSH@ survives the render: a non-boolean
|
||||||
|
# gitflow.autopush blocks every push, so a leaked placeholder is an outage.
|
||||||
|
render_gitconfig() {
|
||||||
|
local name="$1" email="$2" autopush="$3" rendered
|
||||||
|
case "$autopush" in
|
||||||
|
true|false) ;;
|
||||||
|
*) echo "gitconfig render refused: push mode '$autopush' is not exactly true/false — nothing written" >&2; return 1 ;;
|
||||||
|
esac
|
||||||
|
rendered="$(render_identity_template "$SCRIPT_DIR/gitconfig" "$name" "$email")"
|
||||||
|
rendered="${rendered//@AUTOPUSH@/$autopush}"
|
||||||
|
case "$rendered" in
|
||||||
|
*@AUTOPUSH@*) echo "gitconfig render failed: @AUTOPUSH@ left in the output — nothing written" >&2; return 1 ;;
|
||||||
|
esac
|
||||||
|
printf '%s\n' "$rendered"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install the user-scope ~/.gitconfig (a repo's own .git/config still wins).
|
# Install the user-scope ~/.gitconfig (a repo's own .git/config still wins).
|
||||||
# The identity is read from the USER/EMAIL exports of the deployed rc ($1), so
|
# $1 $2 = the identity rendered into the rc, so git and the shell agree; $3 = the
|
||||||
# git and the shell agree. A ~/.gitconfig that differs is kept as
|
# gitflow push mode (true/false). A ~/.gitconfig that differs is kept as
|
||||||
# ~/.gitconfig.backup-<date>, outside ~/Oldconfig which every run wipes.
|
# ~/.gitconfig.backup-<date>, outside ~/Oldconfig which every run wipes.
|
||||||
# Idempotent: an identical ~/.gitconfig is left alone.
|
# Idempotent: an identical ~/.gitconfig is left alone. Two fail-closed checks
|
||||||
|
# live in render_gitconfig: exact push mode, no leaked placeholder.
|
||||||
deploy_gitconfig() {
|
deploy_gitconfig() {
|
||||||
local rc="$1" name email rendered backup
|
local name="$1" email="$2" autopush="$3" rendered backup
|
||||||
name="$(rc_export_value USER "$rc")"
|
|
||||||
email="$(rc_export_value EMAIL "$rc")"
|
|
||||||
if [ -z "$name" ] || [ -z "$email" ]; then
|
if [ -z "$name" ] || [ -z "$email" ]; then
|
||||||
echo "USER/EMAIL not exported by $rc — skipping ~/.gitconfig" >&2
|
echo "Name or email empty — skipping ~/.gitconfig (push mode $autopush not written)" >&2
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
rendered="$(render_gitconfig "$name" "$email")"
|
rendered="$(render_gitconfig "$name" "$email" "$autopush")" || return 1
|
||||||
if printf '%s\n' "$rendered" | cmp -s - "$HOME/.gitconfig"; then
|
if printf '%s\n' "$rendered" | cmp -s - "$HOME/.gitconfig"; then
|
||||||
echo "$HOME/.gitconfig already up to date — skipping"
|
echo "$HOME/.gitconfig already up to date — skipping"
|
||||||
return 0
|
return 0
|
||||||
@@ -470,7 +730,7 @@ deploy_gitconfig() {
|
|||||||
echo "Saving the current ~/.gitconfig to $backup"
|
echo "Saving the current ~/.gitconfig to $backup"
|
||||||
mv "$HOME/.gitconfig" "$backup"
|
mv "$HOME/.gitconfig" "$backup"
|
||||||
fi
|
fi
|
||||||
echo "Deploying gitconfig to ~/.gitconfig ($name <$email>)"
|
echo "Deploying gitconfig to ~/.gitconfig ($name <$email>, autopush=$autopush)"
|
||||||
printf '%s\n' "$rendered" > "$HOME/.gitconfig"
|
printf '%s\n' "$rendered" > "$HOME/.gitconfig"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,6 +763,12 @@ as brew services instead of systemd units.
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Identity for git, vim and the rc exports: reused from an existing rc, else asked.
|
||||||
|
identity_name="$(resolve_identity USER "Name for git commits and vim headers" "$(id -un)")"
|
||||||
|
identity_email="$(resolve_identity EMAIL "Email for git commits and vim headers" "")"
|
||||||
|
echo "Identity: $identity_name <${identity_email:-no email}>"
|
||||||
|
autopush="$(resolve_autopush)"
|
||||||
|
|
||||||
# System packages: apt-get on Debian/Ubuntu, Homebrew on macOS.
|
# System packages: apt-get on Debian/Ubuntu, Homebrew on macOS.
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
@@ -514,7 +780,7 @@ if command -v apt-get >/dev/null 2>&1; then
|
|||||||
# follow the distro's PHP version instead of pinning php8.x-*.
|
# follow the distro's PHP version instead of pinning php8.x-*.
|
||||||
sudo apt-get install -y \
|
sudo apt-get install -y \
|
||||||
vim git git-lfs git-filter-repo gitleaks gcc make pkg-config dkms valgrind shellcheck git-delta \
|
vim git git-lfs git-filter-repo gitleaks gcc make pkg-config dkms valgrind shellcheck git-delta \
|
||||||
curl gnupg ca-certificates apt-transport-https \
|
curl gnupg ca-certificates apt-transport-https jq libssl-dev \
|
||||||
unzip tree tmux fzf dtach net-tools \
|
unzip tree tmux fzf dtach net-tools \
|
||||||
openssh-server cifs-utils lftp ftp \
|
openssh-server cifs-utils lftp ftp \
|
||||||
nodejs python3-pip pipx php-cli \
|
nodejs python3-pip pipx php-cli \
|
||||||
@@ -530,14 +796,14 @@ if command -v apt-get >/dev/null 2>&1; then
|
|||||||
curl -fsSL https://code-server.dev/install.sh | sh
|
curl -fsSL https://code-server.dev/install.sh | sh
|
||||||
fi
|
fi
|
||||||
# id -un, not $USER: the deployed bashrc sets USER to the git/vim identity.
|
# id -un, not $USER: the deployed bashrc sets USER to the git/vim identity.
|
||||||
sudo systemctl enable --now "code-server@$(id -un)"
|
if systemd_running; then
|
||||||
|
sudo systemctl enable --now "code-server@$(id -un)"
|
||||||
|
else
|
||||||
|
echo "systemd not running (WSL?) — code-server installed, not started" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
# GNOME desktop (GDM + Shell): the RDP remote login below needs a GNOME session
|
# GNOME desktop + RDP remote login, both offered ([Y/n]; [y/N] on WSL).
|
||||||
# to hand out; a bare server install has none. Ubuntu-only metapackage.
|
offer_desktop
|
||||||
sudo apt-get install -y ubuntu-desktop-minimal
|
|
||||||
|
|
||||||
# Remote desktop (gnome-remote-desktop — see the function header for why not xrdp).
|
|
||||||
setup_remote_desktop
|
|
||||||
|
|
||||||
# NVIDIA driver, only when an NVIDIA GPU is present.
|
# NVIDIA driver, only when an NVIDIA GPU is present.
|
||||||
install_nvidia_driver
|
install_nvidia_driver
|
||||||
@@ -545,11 +811,8 @@ if command -v apt-get >/dev/null 2>&1; then
|
|||||||
# Low-disk login warning (system-wide profile.d snippet).
|
# Low-disk login warning (system-wide profile.d snippet).
|
||||||
install_disk_warning
|
install_disk_warning
|
||||||
|
|
||||||
# On-demand NAS mount helper (cloudpex/).
|
# Security baseline: brute-force bans (offered), security updates, sshd limits.
|
||||||
install_cloudpex
|
offer_fail2ban
|
||||||
|
|
||||||
# Security baseline: brute-force bans, automatic security updates, sshd limits.
|
|
||||||
install_fail2ban
|
|
||||||
install_unattended_upgrades
|
install_unattended_upgrades
|
||||||
harden_sshd
|
harden_sshd
|
||||||
elif [ "$(uname -s)" = "Darwin" ]; then
|
elif [ "$(uname -s)" = "Darwin" ]; then
|
||||||
@@ -602,11 +865,16 @@ if [ "$(uname -s)" = "Darwin" ] && [ -f "$SCRIPT_DIR/bash/bashrc-osx" ]; then
|
|||||||
else
|
else
|
||||||
bashrc="bash/bashrc-linux"
|
bashrc="bash/bashrc-linux"
|
||||||
fi
|
fi
|
||||||
echo "Deploying $bashrc"
|
echo "Deploying $bashrc ($identity_name <$identity_email>)"
|
||||||
cp "$SCRIPT_DIR/$bashrc" "$HOME/.bashrc"
|
render_identity_template "$SCRIPT_DIR/$bashrc" "$identity_name" "$identity_email" > "$HOME/.bashrc"
|
||||||
|
|
||||||
# User-scope git config, identity taken from the bashrc just deployed.
|
# User-scope git config, same identity as the rc just rendered.
|
||||||
deploy_gitconfig "$SCRIPT_DIR/$bashrc"
|
deploy_gitconfig "$identity_name" "$identity_email" "$autopush"
|
||||||
|
|
||||||
|
# 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.
|
# Python CLIs via pipx (run as the user, never sudo). Skipped if pipx is absent.
|
||||||
if command -v pipx >/dev/null 2>&1; then
|
if command -v pipx >/dev/null 2>&1; then
|
||||||
@@ -616,21 +884,28 @@ if command -v pipx >/dev/null 2>&1; then
|
|||||||
pipx ensurepath >/dev/null
|
pipx ensurepath >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Deploy personal CLI scripts to ~/.local/bin (dt, dtach-router, claude-provider).
|
# Rust toolchain (rustup, user-level, both OSes).
|
||||||
|
install_rust
|
||||||
|
|
||||||
|
# Deploy personal CLI scripts to ~/.local/bin (dt, dtach-router, repo-sync,
|
||||||
|
# tmux-copy-exit-keys).
|
||||||
echo "Deploying CLI scripts to ~/.local/bin"
|
echo "Deploying CLI scripts to ~/.local/bin"
|
||||||
mkdir -p "$HOME/.local/bin"
|
mkdir -p "$HOME/.local/bin"
|
||||||
cp "$SCRIPT_DIR"/bin/* "$HOME/.local/bin/"
|
cp "$SCRIPT_DIR"/bin/* "$HOME/.local/bin/"
|
||||||
chmod +x "$HOME"/.local/bin/dt "$HOME"/.local/bin/dtach-router "$HOME"/.local/bin/claude-provider
|
chmod +x "$HOME"/.local/bin/dt "$HOME"/.local/bin/dtach-router \
|
||||||
|
"$HOME"/.local/bin/repo-sync "$HOME"/.local/bin/tmux-copy-exit-keys
|
||||||
|
|
||||||
|
|
||||||
# Remove any stale dtach wiring from ~/.profile (the menu now ships in ~/.bashrc; see above).
|
# Remove any stale dtach wiring from ~/.profile (the menu now ships in ~/.bashrc; see above).
|
||||||
unwire_dtach_profile
|
unwire_dtach_profile
|
||||||
|
|
||||||
# Optional system changes, offered last so the base install is complete even when
|
# Optional pieces, offered last so the base install is complete even when
|
||||||
# declined. Linux/systemd only. Each prompts [y/N] on a terminal, is skipped otherwise.
|
# declined. Linux only. Each prompts [y/N] on a terminal, is skipped otherwise.
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
offer_tmp_on_disk
|
offer_tmp_on_disk
|
||||||
offer_ssh_memory_guard
|
offer_ssh_memory_guard
|
||||||
|
offer_cloudpex
|
||||||
|
offer_docker_rootless
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# macOS: login shells skip ~/.bashrc unless ~/.bash_profile sources it (kept even
|
# macOS: login shells skip ~/.bashrc unless ~/.bash_profile sources it (kept even
|
||||||
@@ -638,7 +913,7 @@ fi
|
|||||||
# Linux install has that this one does not.
|
# Linux install has that this one does not.
|
||||||
if [ "$(uname -s)" = "Darwin" ]; then
|
if [ "$(uname -s)" = "Darwin" ]; then
|
||||||
wire_bash_profile
|
wire_bash_profile
|
||||||
setup_macos_shell "${macos_shell:-bash}"
|
setup_macos_shell "${macos_shell:-bash}" "$identity_name" "$identity_email"
|
||||||
print_macos_gaps
|
print_macos_gaps
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
+10
-4
@@ -1,14 +1,14 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# remote-install.sh — one-liner bootstrap: clone this repo, then run install.sh.
|
# remote-install.sh — one-liner bootstrap: clone this repo, then run install.sh.
|
||||||
# Usage:
|
# Usage:
|
||||||
# curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/master/remote-install.sh | bash
|
# curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/main/remote-install.sh | bash
|
||||||
# Override defaults with env vars:
|
# Override defaults with env vars:
|
||||||
# REPO_URL=... CLONE_DIR=... BRANCH=... curl ... | bash
|
# REPO_URL=... CLONE_DIR=... BRANCH=... curl ... | bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_URL="${REPO_URL:-https://git.bchanot.fr/bchanot/config.git}"
|
REPO_URL="${REPO_URL:-https://git.bchanot.fr/bchanot/config.git}"
|
||||||
CLONE_DIR="${CLONE_DIR:-$HOME/config}"
|
CLONE_DIR="${CLONE_DIR:-$HOME/config}"
|
||||||
BRANCH="${BRANCH:-master}"
|
BRANCH="${BRANCH:-main}"
|
||||||
|
|
||||||
# git is required to fetch the repo. Install it on Debian/Ubuntu, else bail with a hint.
|
# git is required to fetch the repo. Install it on Debian/Ubuntu, else bail with a hint.
|
||||||
if ! command -v git >/dev/null 2>&1; then
|
if ! command -v git >/dev/null 2>&1; then
|
||||||
@@ -36,6 +36,12 @@ else
|
|||||||
git clone --quiet --branch "$BRANCH" "$REPO_URL" "$CLONE_DIR"
|
git clone --quiet --branch "$BRANCH" "$REPO_URL" "$CLONE_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Hand off to the OS-detecting installer.
|
# Hand off to the OS-detecting installer. Piped into bash, stdin is the script
|
||||||
|
# itself, so install.sh would see no terminal and skip every question (identity,
|
||||||
|
# macOS shell, offers). Give it the terminal back when there is one.
|
||||||
echo "Running install.sh"
|
echo "Running install.sh"
|
||||||
bash "$CLONE_DIR/install.sh"
|
if ( : </dev/tty ) 2>/dev/null; then
|
||||||
|
bash "$CLONE_DIR/install.sh" </dev/tty
|
||||||
|
else
|
||||||
|
bash "$CLONE_DIR/install.sh"
|
||||||
|
fi
|
||||||
@@ -0,0 +1,350 @@
|
|||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# #
|
||||||
|
# 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: {{{
|
||||||
|
# --------------
|
||||||
|
# Bells reach the terminal; the tab flag stays but is unstyled (no highlight).
|
||||||
|
# monitor-bell must stay on, or no bell is sent.
|
||||||
|
set -g bell-action any
|
||||||
|
setw -g window-status-bell-style default
|
||||||
|
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 (?)
|
||||||
|
# Clipboard over ssh: force OSC 52 (tmux buffer -> local clipboard) whatever
|
||||||
|
# TERM the client announces. Auto-detection misses some terminals (Windows
|
||||||
|
# Terminal under WSL, TERM mismatch), so copy worked only sometimes.
|
||||||
|
# terminal-features needs tmux >= 3.2 (-q: ignored on 3.1), Ms covers older.
|
||||||
|
set -g set-clipboard on
|
||||||
|
set -aq terminal-features ',*:clipboard'
|
||||||
|
set -ga terminal-overrides ',*:Ms=\E]52;%p1%s;%p2%s\007'
|
||||||
|
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='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
|
||||||
|
# is_vim Note: {{{
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
# 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 -n MouseDrag1Border # no pane resize by dragging a border
|
||||||
|
unbind-key -T copy-mode-vi MouseDragEnd1Pane # (mouse setting) {{{
|
||||||
|
# stock binding = "release the drag: copy AND leave copy-mode", which loses
|
||||||
|
# the selection on screen. Rebound below (clipboard section) as copy without
|
||||||
|
# leaving, so a drag is enough and y stays available.
|
||||||
|
# ref: https://github.com/tmux/tmux/issues/140
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
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 (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
|
||||||
|
# Alt+arrow too (no prefix): native on Linux/PC. On macOS iTerm2 sends Esc b/f
|
||||||
|
# for Option+arrow, so map Cmd+arrow there to the xterm Alt+arrow sequences
|
||||||
|
# (Send Escape Sequence `[1;3D` / `[1;3C`); it then shadows iTerm2's own
|
||||||
|
# Cmd+arrow tab switching in that profile (Cmd+Shift+[ ] still work).
|
||||||
|
bind-key -n M-Left previous-window \; set status on
|
||||||
|
bind-key -n M-Right next-window \; set status on
|
||||||
|
|
||||||
|
# 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 -R"
|
||||||
|
# Copy-mode has its own key table, where stock tmux turns these keys into text
|
||||||
|
# navigation (C-h cursor-left, C-u halfpage-up, C-j copy). Arrows do that job;
|
||||||
|
# the four keys keep switching panes there too.
|
||||||
|
bind -T copy-mode-vi C-u select-pane -U
|
||||||
|
bind -T copy-mode-vi C-h select-pane -L
|
||||||
|
bind -T copy-mode-vi C-j select-pane -D
|
||||||
|
bind -T copy-mode-vi C-k select-pane -R
|
||||||
|
# Ctrl+Alt+arrow too (no prefix), straight to the pane, no vim pass-through.
|
||||||
|
# Native on Linux/PC; on macOS map Ctrl+Cmd+arrow in iTerm2 to the xterm
|
||||||
|
# Ctrl+Alt+arrow sequences (Send Escape Sequence `[1;7A` `[1;7B` `[1;7D` `[1;7C`).
|
||||||
|
bind -n C-M-Up select-pane -U
|
||||||
|
bind -n C-M-Down select-pane -D
|
||||||
|
bind -n C-M-Left select-pane -L
|
||||||
|
bind -n C-M-Right select-pane -R
|
||||||
|
bind -T copy-mode-vi C-M-Up select-pane -U
|
||||||
|
bind -T copy-mode-vi C-M-Down select-pane -D
|
||||||
|
bind -T copy-mode-vi C-M-Left select-pane -L
|
||||||
|
bind -T copy-mode-vi C-M-Right 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
|
||||||
|
# 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.
|
||||||
|
# Releasing a mouse drag copies too (selection kept on screen, copy-mode stays).
|
||||||
|
# alt+c (in a selection) = y, alt+v (anywhere, no prefix) = prefix p: cmd-less
|
||||||
|
# keyboards. GNOME Terminal: keep "Enable mnemonics" off or alt+v opens View.
|
||||||
|
# A finished drag also marks the pane (@mouse_sel): from then on any bare key
|
||||||
|
# leaves copy-mode, see the hook below and the run-shell at the end of file.
|
||||||
|
if-shell 'command -v pbcopy >/dev/null' \
|
||||||
|
'bind -Tcopy-mode-vi y send -X copy-pipe-and-cancel pbcopy ; bind -Tcopy-mode-vi M-c send -X copy-pipe-and-cancel pbcopy ; bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear pbcopy \; set -p @mouse_sel 1 ; bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer" ; bind -n M-v run "pbpaste | tmux load-buffer - ; tmux paste-buffer"' \
|
||||||
|
'bind -Tcopy-mode-vi y send -X copy-selection-and-cancel ; bind -Tcopy-mode-vi M-c send -X copy-selection-and-cancel ; bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-no-clear \; set -p @mouse_sel 1 ; bind p paste-buffer ; bind -n M-v 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
|
||||||
|
|
||||||
|
# Wheel: stock tmux scrolls 5 lines per tick, too fast on a trackpad (one flick =
|
||||||
|
# dozens of ticks). Halved to 2; applies to history scrolling (copy-mode) only.
|
||||||
|
bind -T copy-mode-vi WheelUpPane select-pane \; send-keys -X -N 2 scroll-up
|
||||||
|
bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 2 scroll-down
|
||||||
|
bind-key -T copy-mode-vi MouseDown1Pane select-pane -t = \; send-keys -X clear-selection
|
||||||
|
bind-key -T copy-mode-vi MouseUp1Pane select-pane -t = \; send-keys -X cancel
|
||||||
|
bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= "#{pane_in_mode}" "copy-mode -eM" "send-keys -M"' 'copy-mode -eM'
|
||||||
|
# (note) {{{
|
||||||
|
# A plain click (MouseDown then MouseUp, no drag) leaves copy-mode: back to
|
||||||
|
# the prompt, selection dropped. A drag sends MouseDrag/MouseDragEnd instead
|
||||||
|
# of MouseUp, so it keeps the scroll position and selects as usual. A click
|
||||||
|
# on another pane still switches to it.
|
||||||
|
# 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
|
||||||
|
# Inner quotes stay plain: `\"` is literal inside '...' since tmux 3.0, and the
|
||||||
|
# mouse-app branch (claude, vim) then dies with "syntax error" on every drag.
|
||||||
|
# }}}
|
||||||
|
# @mouse_sel (set by MouseDragEnd1Pane above) must not outlive the copy-mode
|
||||||
|
# it was set in, whatever way that mode ends: cleared when the pane leaves it.
|
||||||
|
set-hook -g pane-mode-changed 'if -F "#{!:#{pane_in_mode}}" "set -pu @mouse_sel"'
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
# Move panes between windows and around. Source = the marked pane (prefix m,
|
||||||
|
# toggles) when one is set, else the current pane. Prefix ! (stock break-pane)
|
||||||
|
# does the reverse: current pane out to a new window.
|
||||||
|
bind-key J join-pane -v # marked pane joins this window, below (mirrors j)
|
||||||
|
bind-key L join-pane -h # marked pane joins this window, beside (mirrors l)
|
||||||
|
bind-key S swap-pane # swap marked pane with the current one
|
||||||
|
# Stock { } (swap-pane -U/-D) sit behind alt+( alt+) on a Mac AZERTY keyboard.
|
||||||
|
# ( ) are unshifted there, and repeatable; they replace switch-client -p/-n,
|
||||||
|
# which prefix s (choose-tree) still covers.
|
||||||
|
bind-key -r ( swap-pane -U # move pane up / left (previous slot)
|
||||||
|
bind-key -r ) swap-pane -D # move pane down / right (next slot)
|
||||||
|
|
||||||
|
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=yellow,fg=black # selection: same accent as the status bar
|
||||||
|
set-window-option -g window-status-separator ' ' # one blank between tabs
|
||||||
|
set -g status-position bottom
|
||||||
|
set -g status-left-length 42
|
||||||
|
set -g status-right-length 80
|
||||||
|
# Tabs sit in the true middle of the screen, whatever status-left/right take.
|
||||||
|
set -g status-justify absolute-centre
|
||||||
|
#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} '
|
||||||
|
# Tabs: index + name, padded; the current one is bold on a light pill.
|
||||||
|
setw -g window-status-format '#{sep_e} #I #W #{sep_f}'
|
||||||
|
setw -g window-status-current-format '#{sep_h} #I #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
|
||||||
|
|
||||||
|
# Dim inactive panes: only cells in "default" colour change (coloured text and
|
||||||
|
# vim's own background stay as they are). The active style must repeat the
|
||||||
|
# terminal colours: since tmux 3, "default" there inherits window-style, so
|
||||||
|
# the active pane would be dimmed too. Values = iTerm2 Default profile, dark
|
||||||
|
# mode (fg #dcdcdc, bg #15191f); a light theme needs the opposite.
|
||||||
|
set -g window-style fg=#a6acb6,bg=#353d48
|
||||||
|
set -g window-active-style fg=#dcdcdc,bg=#15191f
|
||||||
|
|
||||||
|
# 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'
|
||||||
|
|
||||||
|
# After a mouse selection any bare key leaves copy-mode (keyboard/wheel
|
||||||
|
# copy-mode keeps its vi keys). Wraps the bindings as they stand, so it runs
|
||||||
|
# last, after the plugins. Script deployed by install.sh with the other bins.
|
||||||
|
run-shell '~/.local/bin/tmux-copy-exit-keys'
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
" Uset compatibility with Vii
|
" Uset compatibility with Vii
|
||||||
set nocompatible
|
set nocompatible
|
||||||
|
|
||||||
" add user info variable
|
" user info from the shell identity (USER / EMAIL exported by the deployed rc)
|
||||||
let g:_author = "Bastien Chanot"
|
let g:_author = $USER
|
||||||
let g:_email = "chanot.bastien@gmail.com"
|
let g:_email = exists('$EMAIL') ? $EMAIL : ''
|
||||||
|
|
||||||
" Enable pathogen for plugins
|
" Enable pathogen for plugins
|
||||||
execute pathogen#infect()
|
execute pathogen#infect()
|
||||||
|
|||||||
+101
-4
@@ -26,12 +26,21 @@ alias grep='grep --color=auto'
|
|||||||
# colored GCC warnings and errors
|
# colored GCC warnings and errors
|
||||||
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
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/)
|
# Ensure ~/.local/bin is on PATH (pipx CLIs + personal scripts from bin/)
|
||||||
case ":$PATH:" in
|
case ":$PATH:" in
|
||||||
*":$HOME/.local/bin:"*) ;;
|
*":$HOME/.local/bin:"*) ;;
|
||||||
*) export PATH="$HOME/.local/bin:$PATH" ;;
|
*) export PATH="$HOME/.local/bin:$PATH" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Rust toolchain (install.sh, rustup): puts ~/.cargo/bin on PATH, dedup done by the env file.
|
||||||
|
if [ -f "$HOME/.cargo/env" ]; then
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
. "$HOME/.cargo/env"
|
||||||
|
fi
|
||||||
|
|
||||||
# History: none for root, near-unlimited otherwise (zsh has no -1 = unlimited).
|
# History: none for root, near-unlimited otherwise (zsh has no -1 = unlimited).
|
||||||
if [[ $EUID == 0 ]] ; then
|
if [[ $EUID == 0 ]] ; then
|
||||||
HISTSIZE=0
|
HISTSIZE=0
|
||||||
@@ -41,27 +50,115 @@ else
|
|||||||
SAVEHIST=10000000
|
SAVEHIST=10000000
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Identity for the vim header; install.sh also writes it into ~/.gitconfig
|
# Identity for git commits and vim headers. Filled by install.sh (asked once,
|
||||||
export USER=bchanot
|
# reused from an existing ~/.bashrc / ~/.zshrc on re-runs), never stored here.
|
||||||
export EMAIL=bchanot@gmail.fr
|
export USER="@USER@"
|
||||||
|
export EMAIL="@EMAIL@"
|
||||||
|
|
||||||
# claude-dans-dtach : creer une session (claude tournant dans dtach, detache via Ctrl-\).
|
# claude-dans-dtach : creer une session (claude tournant dans dtach, detache via Ctrl-\).
|
||||||
|
# Reprend la derniere conversation du dossier (--continue), sinon session neuve.
|
||||||
# Usage : cd ~/projets/seo && cc seo -> session nommee "seo".
|
# Usage : cd ~/projets/seo && cc seo -> session nommee "seo".
|
||||||
# Pas de systemd sur macOS : dtach est lance directement (pas de slice cgroup).
|
# Pas de systemd sur macOS : dtach est lance directement (pas de slice cgroup).
|
||||||
dtach_claude() {
|
dtach_claude() {
|
||||||
local name="${1:-claude-$(date +%H%M%S)}"
|
local name="${1:-claude-$(date +%H%M%S)}"
|
||||||
mkdir -p "$HOME/.dtach"
|
mkdir -p "$HOME/.dtach"
|
||||||
dtach -c "$HOME/.dtach/${name}" -e '^\' \
|
dtach -c "$HOME/.dtach/${name}" -e '^\' \
|
||||||
bash -c 'set -a; [ -f "$HOME/.claude/.env" ] && . "$HOME/.claude/.env"; set +a; exec claude'
|
bash -c 'set -a; [ -f "$HOME/.claude/.env" ] && . "$HOME/.claude/.env"; set +a; claude --continue || exec claude'
|
||||||
}
|
}
|
||||||
alias cc='dtach_claude'
|
alias cc='dtach_claude'
|
||||||
|
|
||||||
# Rappeler a la demande le menu de reprise.
|
# Rappeler a la demande le menu de reprise.
|
||||||
alias d='source ~/.local/bin/dtach-router'
|
alias d='source ~/.local/bin/dtach-router'
|
||||||
|
|
||||||
|
# openrouter : bascule Claude Code sur OpenRouter dans le shell courant (fonction, pas
|
||||||
|
# script : un script ne peut pas modifier l'environnement de son parent). `openrouter`
|
||||||
|
# active, `openrouter -d` (ou -u) desactive. La cle vient de $OPENROUTER_API_KEY, a
|
||||||
|
# exporter depuis un fichier prive non versionne (~/.bashrc.local, ~/.zshrc.local).
|
||||||
|
# Les valeurs qu'avaient deja ces variables sont gardees dans $_OPENROUTER_SAVED
|
||||||
|
# (commandes export/unset) et rejouees a la desactivation.
|
||||||
|
openrouter() {
|
||||||
|
local v saved=""
|
||||||
|
case "${1:-}" in
|
||||||
|
-d | -u)
|
||||||
|
if [ -n "${_OPENROUTER_SAVED+x}" ]; then
|
||||||
|
saved="$_OPENROUTER_SAVED"
|
||||||
|
elif [ "${ANTHROPIC_BASE_URL:-}" != "https://openrouter.ai/api" ]; then
|
||||||
|
echo "openrouter: not active"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
|
||||||
|
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY
|
||||||
|
eval "$saved"
|
||||||
|
unset _OPENROUTER_SAVED
|
||||||
|
echo "openrouter: off"
|
||||||
|
echo "Pensez a vous log in de Claude Code"
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
[ -n "${OPENROUTER_API_KEY:-}" ] || {
|
||||||
|
echo "openrouter: OPENROUTER_API_KEY is not set" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if [ -z "${_OPENROUTER_SAVED+x}" ]; then
|
||||||
|
for v in ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
|
||||||
|
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY; do
|
||||||
|
if printenv "$v" >/dev/null; then
|
||||||
|
saved="$saved export $v=$(printf %q "$(printenv "$v")");"
|
||||||
|
else
|
||||||
|
saved="$saved unset $v;"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
_OPENROUTER_SAVED="$saved"
|
||||||
|
fi
|
||||||
|
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
|
||||||
|
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
|
||||||
|
export ANTHROPIC_API_KEY="" # doit etre explicitement vide
|
||||||
|
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
|
||||||
|
echo "openrouter: on"
|
||||||
|
echo "Pensez a vous logout de Claude Code"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "usage: openrouter [-d|-u]" >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# repo-sync : un arbre local (~/repos) pour tous les depots des forges declarees
|
||||||
|
# dans ~/.config/repos/forges.conf. `repo <projet> [namespace]` clone si besoin
|
||||||
|
# puis s'y place ; la liste se rafraichit en arriere-plan, au plus 1 fois par jour.
|
||||||
|
repo() {
|
||||||
|
local dir
|
||||||
|
dir="$(repo-sync path "$@")" && cd "$dir" || return
|
||||||
|
}
|
||||||
|
_repo() {
|
||||||
|
local cache="${REPOS_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/repos/list}"
|
||||||
|
local -a items
|
||||||
|
[[ -f "$cache" ]] || return 0
|
||||||
|
if (( CURRENT == 2 )); then
|
||||||
|
items=(${(f)"$(cut -f1 "$cache" | sort -u)"})
|
||||||
|
_describe 'project' items
|
||||||
|
elif (( CURRENT == 3 )); then
|
||||||
|
items=(${(f)"$(awk -F'\t' -v p="$words[2]" '$1 == p { print $2 }' "$cache")"})
|
||||||
|
_describe 'namespace' items
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
compdef _repo repo
|
||||||
|
[[ -o interactive ]] && command -v repo-sync >/dev/null && (repo-sync refresh --quiet >/dev/null 2>&1 &)
|
||||||
|
|
||||||
# Reglages propres a cette machine (non versionnes).
|
# Reglages propres a cette machine (non versionnes).
|
||||||
[ -f "$HOME/.zshrc.local" ] && source "$HOME/.zshrc.local"
|
[ -f "$HOME/.zshrc.local" ] && source "$HOME/.zshrc.local"
|
||||||
|
|
||||||
|
# SSH interactif hors tmux (et hors terminal VS Code Remote-SSH) : entrer dans tmux,
|
||||||
|
# session partagee "main" (rattachee si elle existe). Le shell lance dans tmux relit ce
|
||||||
|
# fichier et ouvre le menu dtach ci-dessous ; quitter tmux ferme la connexion (exec).
|
||||||
|
case $- in *i*)
|
||||||
|
if [ -n "${SSH_CONNECTION:-}" ] && [ -z "${TMUX:-}" ] \
|
||||||
|
&& [ "${TERM_PROGRAM:-}" != vscode ] && command -v tmux >/dev/null; then
|
||||||
|
exec tmux new-session -A -s main
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Au demarrage d'un shell interactif, proposer de reprendre une session dtach existante
|
# Au demarrage d'un shell interactif, proposer de reprendre une session dtach existante
|
||||||
# (silencieux si aucune).
|
# (silencieux si aucune).
|
||||||
case $- in *i*) [ -x "$HOME/.local/bin/dtach-router" ] && . "$HOME/.local/bin/dtach-router" ;; esac
|
case $- in *i*) [ -x "$HOME/.local/bin/dtach-router" ] && . "$HOME/.local/bin/dtach-router" ;; esac
|
||||||
Reference in new issue
Block a user