Terminal: show the live full working-directory path in the toolbar
Deploy Ladill Hosting / deploy (push) Successful in 45s
Deploy Ladill Hosting / deploy (push) Successful in 45s
The toolbar showed a static ~/public_html. The jailed shell now reports its cwd via OSC 7 each prompt (jail rcfile keeps the user's prompt + emits it); xterm captures it and the toolbar shows the full path (/home/<user>/...), updating as the user cd's. Launcher/rcfile committed in deployment/ for reproducibility. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
d7b47e67fb
commit
75ba450938
@@ -25,6 +25,11 @@ window.hostingInteractiveTerminal = (config = {}) => {
|
||||
termHasOutput: false,
|
||||
currentPath: config.initialPath ?? '/public_html',
|
||||
currentPathLabel: `Starting in ${config.initialPath === '/' ? `/home/${config.username ?? ''}` : `/home/${config.username ?? ''}${config.initialPath ?? '/public_html'}`}`,
|
||||
// Full working-directory path shown in the toolbar; updated live from the
|
||||
// shell's OSC 7 cwd report as the user navigates.
|
||||
fullPath: config.initialPath === '/'
|
||||
? `/home/${config.username ?? ''}`
|
||||
: `/home/${config.username ?? ''}${config.initialPath ?? '/public_html'}`,
|
||||
promptPath() {
|
||||
if (this.currentPath === '/' || !this.currentPath) {
|
||||
return '~';
|
||||
@@ -79,6 +84,18 @@ window.hostingInteractiveTerminal = (config = {}) => {
|
||||
this.fitAddon = new FitAddon();
|
||||
this.term.loadAddon(this.fitAddon);
|
||||
this.term.open(this.$refs.terminal);
|
||||
// The shell reports its working directory via OSC 7 (file://host/path);
|
||||
// capture it so the toolbar shows the live full path as the user cd's.
|
||||
this.term.parser?.registerOscHandler(7, (data) => {
|
||||
try {
|
||||
let p = String(data || '').replace(/^file:\/\/[^/]*/, '');
|
||||
p = decodeURIComponent(p);
|
||||
if (p) {
|
||||
this.fullPath = p.replace(/\/$/, '') || '/';
|
||||
}
|
||||
} catch (e) { /* ignore malformed cwd reports */ }
|
||||
return true;
|
||||
});
|
||||
this.term.onData((data) => {
|
||||
if (this.sessionId) {
|
||||
this.queueInput(data);
|
||||
|
||||
Reference in New Issue
Block a user