fix(dtach): wire resume menu into ~/.bashrc for non-login VS Code shells
VS Code Remote-SSH integrated terminals are non-login interactive shells: they source ~/.bashrc but never ~/.profile, where the resume menu was wired (login-scope, BDR-007). The auto-check therefore never fired in the user's actual environment, even after install.sh. Source dtach-router from bashrc-linux (every interactive shell) instead, and turn install.sh's wire_dtach_profile() into unwire_dtach_profile(): it now strips any stale ~/.profile block so a plain SSH login (which reads ~/.bashrc via ~/.profile) does not prompt twice. README updated to match. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CN1KSmsuLG6TxSeN5m8xvM
This commit is contained in:
parent
4f03d87a86
commit
e37eb77ed5
@ -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-linux` | bashrc for desktop Linux (git-aware prompt + command timer). |
|
||||||
| `bash/bashrc-osx` | bashrc for macOS. |
|
| `bash/bashrc-osx` | bashrc for macOS. |
|
||||||
| `bin/dt` | dtach session manager for claude-in-dtach sessions. |
|
| `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. |
|
| `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. |
|
| `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`.
|
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`.
|
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.
|
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.
|
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.
|
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.
|
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`):
|
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 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.
|
- **`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`:
|
OpenRouter mode reads the key from **`$OPENROUTER_API_KEY`** (never hardcoded). Export it from a private, untracked file, e.g. `~/.bashrc.local`:
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
@ -117,5 +117,10 @@ PROMPT_COMMAND='set_prompt'
|
|||||||
dtach_claude() { dtach -c "$HOME/.dtach/${1:-claude-$(date +%H%M%S)}" -e '^\' claude; }
|
dtach_claude() { dtach -c "$HOME/.dtach/${1:-claude-$(date +%H%M%S)}" -e '^\' claude; }
|
||||||
alias cc='dtach_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'
|
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
|
||||||
|
|||||||
30
install.sh
30
install.sh
@ -113,16 +113,16 @@ install_disk_warning() {
|
|||||||
/etc/profile.d/disk-usage-warning.sh
|
/etc/profile.d/disk-usage-warning.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
# Wire the dtach session-resume menu into ~/.profile. At interactive login we SOURCE
|
# The dtach session-resume menu now ships in ~/.bashrc (deployed above): every interactive
|
||||||
# dtach-router rather than execute it: the script hands control back with `return` and
|
# shell sources it, including VS Code Remote-SSH terminals, which are non-login and therefore
|
||||||
# attaches to the host TTY, so running it as a command makes its interactivity guard
|
# never read ~/.profile. This strips any dtach block a previous install left in ~/.profile —
|
||||||
# fail and errors on /dev/tty whenever the login shell is non-interactive (bash -lc,
|
# the marker-delimited managed one AND the legacy execute-based one (DT=$(dt ls) ... fi) — so
|
||||||
# cron, scp). Sourced, the guard works and it is a silent no-op when no session exists.
|
# the menu does not also fire from there (a plain SSH login sources ~/.bashrc via ~/.profile,
|
||||||
# Idempotent: strips any prior block first — the marker-delimited managed one AND the
|
# which would otherwise prompt twice). No-op when absent. User scope, no sudo.
|
||||||
# legacy execute-based one (DT=$(dt ls) ... fi) from earlier installs. User scope, no sudo.
|
unwire_dtach_profile() {
|
||||||
wire_dtach_profile() {
|
|
||||||
local profile="$HOME/.profile"
|
local profile="$HOME/.profile"
|
||||||
touch "$profile"
|
[ -f "$profile" ] || return 0
|
||||||
|
grep -qF 'dtach-router' "$profile" || return 0
|
||||||
|
|
||||||
awk '
|
awk '
|
||||||
$0 == "# >>> claude-dtach >>>" { drop = 1; next }
|
$0 == "# >>> claude-dtach >>>" { drop = 1; next }
|
||||||
@ -131,14 +131,6 @@ wire_dtach_profile() {
|
|||||||
$0 == "DT=$(dt ls)", $0 == "fi" { next }
|
$0 == "DT=$(dt ls)", $0 == "fi" { next }
|
||||||
{ print }
|
{ print }
|
||||||
' "$profile" > "$profile.tmp" && mv "$profile.tmp" "$profile"
|
' "$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).
|
# 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
|
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).
|
# Remove any stale dtach wiring from ~/.profile (the menu now ships in ~/.bashrc; see above).
|
||||||
wire_dtach_profile
|
unwire_dtach_profile
|
||||||
|
|
||||||
echo "Done. Restart your shell or run: source ~/.bashrc"
|
echo "Done. Restart your shell or run: source ~/.bashrc"
|
||||||
echo "If you use zsh, switch to bash to enjoy these settings =)"
|
echo "If you use zsh, switch to bash to enjoy these settings =)"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user