You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,6 +202,49 @@ function handleCommand(inputText) {
202
202
}
203
203
```
204
204
205
+
## Integration Tips
206
+
207
+
### Managing the Command Prompt
208
+
209
+
When building a terminal UI, you'll need to display a prompt that shows the current user and directory. The prompt typically needs to update after commands like `cd` or `su` that change the current path or user.
2. Capture the current prompt text (for display in command history)
238
+
3. Execute the command: `const output = shell.execute(command)`
239
+
4. Display the command with its original prompt in history
240
+
5. Display the command output
241
+
6. Update the active prompt to reflect any changes (new path, new user, etc.)
242
+
7. Clear the input field for the next command
243
+
244
+
**Key point:** When displaying command history, preserve the prompt as it was when the command was entered. Only update the active input prompt after command execution.
245
+
246
+
See the [live demo source code](https://github.com/hypexr/unix-shell-js/blob/main/docs/index.html) for a complete working example.
0 commit comments