diff --git a/README.md b/README.md index e1d67c7..e0a7882 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/master/remote-instal | `bash/bashrc-linux` | bashrc for desktop Linux (git-aware prompt + command timer). | | `bash/bashrc-osx` | bashrc for macOS. | | `bin/dt` | dtach session manager for claude-in-dtach sessions. | -| `bin/dtach-router` | SSH-login dashboard to resume dtach sessions (wired into `~/.profile` 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. | | `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. | @@ -57,7 +57,7 @@ What it does: 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`. 7. Installs Python CLIs via `pipx` (`PyMuPDF` → `pymupdf`, `Markdown` → `markdown_py`) — skipped if `pipx` is absent. -8. Copies the `bin/` scripts (`dt`, `dtach-router`, `claude-provider`) into `~/.local/bin` and wires the dtach session-resume menu into `~/.profile` (idempotent — sourced only at interactive login, and replaces any prior block). +8. Copies the `bin/` scripts (`dt`, `dtach-router`, `claude-provider`) into `~/.local/bin`. The dtach session-resume menu ships in the deployed `bashrc-linux`, 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. 10. On Linux, installs **code-server** (VS Code in the browser) via its vendor script — skipped if already present — and enables the `code-server@$USER` systemd service. 11. On Linux, 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. @@ -82,7 +82,7 @@ The script is re-runnable: each run re-backs up to `~/Oldconfig` (overwriting th 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`. -- **`dtach-router`** — session dashboard on SSH login. The installer wires it into `~/.profile`, where it is **sourced** (not executed) at interactive login and is a 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. OpenRouter mode reads the key from **`$OPENROUTER_API_KEY`** (never hardcoded). Export it from a private, untracked file, e.g. `~/.bashrc.local`: ```sh diff --git a/bash/bashrc-linux b/bash/bashrc-linux index 78db31a..b081937 100644 --- a/bash/bashrc-linux +++ b/bash/bashrc-linux @@ -117,5 +117,10 @@ PROMPT_COMMAND='set_prompt' dtach_claude() { dtach -c "$HOME/.dtach/${1:-claude-$(date +%H%M%S)}" -e '^\' claude; } alias cc='dtach_claude' -# Rappeler a la demande le menu de reprise (sinon il s'affiche seul au login SSH). +# Rappeler a la demande le menu de reprise. alias d='source ~/.local/bin/dtach-router' + +# 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 +# Remote-SSH sont non-login et ne lisent pas ~/.profile ; ~/.bashrc, lui, est toujours lu. +case $- in *i*) [ -x "$HOME/.local/bin/dtach-router" ] && . "$HOME/.local/bin/dtach-router" ;; esac diff --git a/install.sh b/install.sh index 4c9b1c5..68838d0 100755 --- a/install.sh +++ b/install.sh @@ -113,16 +113,16 @@ install_disk_warning() { /etc/profile.d/disk-usage-warning.sh } -# Wire the dtach session-resume menu into ~/.profile. At interactive login we SOURCE -# dtach-router rather than execute it: the script hands control back with `return` and -# attaches to the host TTY, so running it as a command makes its interactivity guard -# fail and errors on /dev/tty whenever the login shell is non-interactive (bash -lc, -# cron, scp). Sourced, the guard works and it is a silent no-op when no session exists. -# Idempotent: strips any prior block first — the marker-delimited managed one AND the -# legacy execute-based one (DT=$(dt ls) ... fi) from earlier installs. User scope, no sudo. -wire_dtach_profile() { +# The dtach session-resume menu now ships in ~/.bashrc (deployed above): every interactive +# shell sources it, including VS Code Remote-SSH terminals, which are non-login and therefore +# never read ~/.profile. This strips any dtach block a previous install left in ~/.profile — +# the marker-delimited managed one AND the legacy execute-based one (DT=$(dt ls) ... fi) — so +# the menu does not also fire from there (a plain SSH login sources ~/.bashrc via ~/.profile, +# which would otherwise prompt twice). No-op when absent. User scope, no sudo. +unwire_dtach_profile() { local profile="$HOME/.profile" - touch "$profile" + [ -f "$profile" ] || return 0 + grep -qF 'dtach-router' "$profile" || return 0 awk ' $0 == "# >>> claude-dtach >>>" { drop = 1; next } @@ -131,14 +131,6 @@ wire_dtach_profile() { $0 == "DT=$(dt ls)", $0 == "fi" { next } { print } ' "$profile" > "$profile.tmp" && mv "$profile.tmp" "$profile" - - cat >> "$profile" << 'EOF' - -# >>> claude-dtach >>> -# At interactive login, offer to resume a claude-in-dtach session (no-op if none). -case $- in *i*) [ -x "$HOME/.local/bin/dtach-router" ] && . "$HOME/.local/bin/dtach-router" ;; esac -# <<< claude-dtach <<< -EOF } # System packages: Debian/Ubuntu only. Skipped where apt-get is absent (e.g. macOS). @@ -224,8 +216,8 @@ cp "$SCRIPT_DIR"/bin/* "$HOME/.local/bin/" chmod +x "$HOME"/.local/bin/dt "$HOME"/.local/bin/dtach-router "$HOME"/.local/bin/claude-provider -# Wire the dtach session-resume menu into ~/.profile (idempotent; migrates any prior block). -wire_dtach_profile +# Remove any stale dtach wiring from ~/.profile (the menu now ships in ~/.bashrc; see above). +unwire_dtach_profile echo "Done. Restart your shell or run: source ~/.bashrc" echo "If you use zsh, switch to bash to enjoy these settings =)"