Clarify remote SSH shell hooks are optional
This commit is contained in:
parent
c696060a38
commit
eedc2786ee
2 changed files with 36 additions and 25 deletions
53
README.md
53
README.md
|
|
@ -92,31 +92,41 @@ terminal title. These options apply when starting a new session.
|
||||||
pipelines, the foreground process group leader supplies the name. Linux uses
|
pipelines, the foreground process group leader supplies the name. Linux uses
|
||||||
`/proc`; other systems use `ps`.
|
`/proc`; other systems use `ps`.
|
||||||
|
|
||||||
## SSH window names and directories
|
## SSH window names and directories (optional)
|
||||||
|
|
||||||
While an SSH pane is active, the outer terminal's window title shows
|
This section is **optional** and only needed if you want `moerx` to show
|
||||||
`[moerx] remote-hostname:program`, for example `[moerx] server:vim`.
|
details from inside an SSH session (remote hostname/program in window titles
|
||||||
The moerx window list also shows `server:vim`. Starting another
|
and the window list, remote working directory in the status line, and reported
|
||||||
remote program updates the title, and returning to the prompt shows the
|
remote root status). If you do not use SSH from `moerx`, or you are fine with
|
||||||
remote shell name, for example `[moerx] server:zsh`.
|
the pane being shown as the local `ssh` process (e.g. `local-hostname:ssh`),
|
||||||
The remote shell must send an OSC 0 or OSC 2 terminal title in
|
you can skip this entire section—no remote configuration is required for
|
||||||
that format: SSH itself does not report the remote foreground program.
|
normal local use.
|
||||||
Without a matching title, the window name remains `local-hostname:ssh`.
|
|
||||||
Names refresh within one second; disconnecting restores the local hostname
|
|
||||||
and shell name in the terminal title and window list.
|
|
||||||
|
|
||||||
For root detection after `su` or `sudo -i`, install the matching hook in
|
While an SSH pane is active, `moerx` can show `[moerx] remote-hostname:program`
|
||||||
**both the regular user's and root's shell startup files on the remote host**.
|
(for example `[moerx] server:vim`) in the outer terminal title and
|
||||||
The hooks also activate in interactive `screen-256color` terminals, so they
|
`server:vim` in the window list, update it as remote programs start/stop, and
|
||||||
continue working when privilege-switching tools remove `$SSH_CONNECTION`.
|
show the remote shell name (for example `server:zsh`) at a remote prompt.
|
||||||
Root prompts and commands then turn the active window name red; exiting back
|
Because SSH does not expose the remote foreground program, directory, or root
|
||||||
to the regular shell restores yellow. A reported remote `su` command is red
|
status to the local terminal, the **remote shell** must emit OSC title/reports
|
||||||
while it runs, even before the new shell reports its UID. SSH disconnects
|
for `moerx` to display this. Without those reports, names remain
|
||||||
restore local detection. No SSH server configuration change is required.
|
`local-hostname:ssh` and remote directory/root details are not tracked.
|
||||||
|
Names refresh within one second; disconnecting restores the local hostname,
|
||||||
|
shell name, and path.
|
||||||
|
|
||||||
|
To enable remote root detection after `su` or `sudo -i`, install the matching
|
||||||
|
hook in **both the regular user's and root's shell startup files on the remote
|
||||||
|
host you connect to over SSH**. The hooks also activate in interactive
|
||||||
|
`screen-256color` terminals, so they continue working when privilege-switching
|
||||||
|
tools remove `$SSH_CONNECTION`. Root prompts and commands then turn the active
|
||||||
|
window name red; exiting back to the regular shell restores yellow. A reported
|
||||||
|
remote `su` command is red while it runs, even before the new shell reports its
|
||||||
|
UID. SSH disconnects restore local detection. No SSH server configuration
|
||||||
|
change is required.
|
||||||
|
|
||||||
### Zsh
|
### Zsh
|
||||||
|
|
||||||
For **zsh**, add this to `~/.zshrc` on the **remote host**:
|
If you want this optional integration, add this to `~/.zshrc` on the remote
|
||||||
|
host you connect to over SSH:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
if [[ -o interactive && ( -n $SSH_CONNECTION || $TERM == screen-256color ) ]]; then
|
if [[ -o interactive && ( -n $SSH_CONNECTION || $TERM == screen-256color ) ]]; then
|
||||||
|
|
@ -155,7 +165,8 @@ existing moerx servers and reload the remote shell configuration after upgrading
|
||||||
|
|
||||||
### Bash
|
### Bash
|
||||||
|
|
||||||
For **Bash**, add this to `~/.bashrc` on the **remote host**:
|
If you want this optional integration, add this to `~/.bashrc` on the remote
|
||||||
|
host you connect to over SSH:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
if [[ $- == *i* && ( -n $SSH_CONNECTION || $TERM == screen-256color ) &&
|
if [[ $- == *i* && ( -n $SSH_CONNECTION || $TERM == screen-256color ) &&
|
||||||
|
|
|
||||||
4
moerx.1
4
moerx.1
|
|
@ -286,7 +286,7 @@ SSH_CONNECTION is set, so su and sudo login shells can report status even if
|
||||||
they clear the SSH environment. The parent shell clears root status at its
|
they clear the SSH environment. The parent shell clears root status at its
|
||||||
next prompt after the root shell exits.
|
next prompt after the root shell exits.
|
||||||
.SS Zsh
|
.SS Zsh
|
||||||
Add the following to ~/.zshrc on the remote host.
|
Add the following to ~/.zshrc on the remote host you connect to over SSH.
|
||||||
The preexec hook reports the first command of a pipeline;
|
The preexec hook reports the first command of a pipeline;
|
||||||
precmd restores the shell name and reports the directory after cd.
|
precmd restores the shell name and reports the directory after cd.
|
||||||
.nf
|
.nf
|
||||||
|
|
@ -318,7 +318,7 @@ fi
|
||||||
.ft
|
.ft
|
||||||
.fi
|
.fi
|
||||||
.SS Bash
|
.SS Bash
|
||||||
Add the following to ~/.bashrc on the remote host.
|
Add the following to ~/.bashrc on the remote host you connect to over SSH.
|
||||||
It preserves string and array PROMPT_COMMAND values and avoids duplicate
|
It preserves string and array PROMPT_COMMAND values and avoids duplicate
|
||||||
installation when sourced again. It installs a DEBUG trap: if an existing
|
installation when sourced again. It installs a DEBUG trap: if an existing
|
||||||
framework such as bash-preexec already owns that trap, integrate the functions
|
framework such as bash-preexec already owns that trap, integrate the functions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue