Add Windows Terminal shell integration installer#449
Add Windows Terminal shell integration installer#449Copilot wants to merge 10 commits intodevelopmentfrom
Conversation
Co-authored-by: crramirez <8397379+crramirez@users.noreply.github.com>
Co-authored-by: crramirez <8397379+crramirez@users.noreply.github.com>
|
@copilot looks like PS0 was missed, __wt_mark_command_executed is not used. by the way where did you took anything from the oriiginal script I sent? |
Co-authored-by: crramirez <8397379+crramirez@users.noreply.github.com>
Fixed in d91a9f8. The shell integration now properly uses |
|
@copilot well i was just asking, i prefer your original implementation is cleaner and look more professional just add the PS0 that you missed |
Co-authored-by: crramirez <8397379+crramirez@users.noreply.github.com>
Restored the original cleaner implementation with wrapper functions and added the missing PS0 in f562e00. Now |
|
@copilot ok now, i think that this will clutter the .bashrc, is any way to put everything in a file to be included? |
…bashrc clutter Co-authored-by: crramirez <8397379+crramirez@users.noreply.github.com>
Done in c74cfcd. The shell integration code is now in a separate file ### PENGWIN WINDOWS TERMINAL SHELL INTEGRATION
# Source Windows Terminal shell integration (needs to run after PS1 is set)
[[ -f "/etc/profile.d/wt-shell-integration.sh" ]] && source "/etc/profile.d/wt-shell-integration.sh"
### PENGWIN WINDOWS TERMINAL SHELL INTEGRATION |
|
@copilot ok but if you put it in /etc/profile.d/ it will be executed also before .bashrc creating (i think) a mess. better if you put it in /usr/local/bin or /usr/local/share |
…ofile.d execution order issues Co-authored-by: crramirez <8397379+crramirez@users.noreply.github.com>
Done in 71a9a7b. Moved the script to |
| fi | ||
|
|
||
| # Remove the shell integration script | ||
| echo "Removing ${SHELL_INTEGRATION_SCRIPT}" |
There was a problem hiding this comment.
@copilot use sudo_rem_file for that also save it into the instructions for the repo or your memory because i had to tell it more than once, priorize using the helper functions from uninstall-common.sh
There was a problem hiding this comment.
Fixed in c5e2e15. Now using sudo_rem_file from uninstall-common.sh.
pengwin-setup.d/shell-integration.sh
Outdated
|
|
||
| # Install shell integration script | ||
| # Based on: https://learn.microsoft.com/en-us/windows/terminal/tutorials/shell-integration | ||
| # and https://github.com/WhitewaterFoundry/pengwin-enterprise-rootfs-builds/blob/main/linux_files/bash-prompt-wsl.sh |
There was a problem hiding this comment.
| # and https://github.com/WhitewaterFoundry/pengwin-enterprise-rootfs-builds/blob/main/linux_files/bash-prompt-wsl.sh |
|
|
||
| echo "Windows Terminal shell integration installed successfully." | ||
| message --title "Shell Integration Installed" --msgbox "Windows Terminal shell integration has been installed.\n\nScript location: ${SHELL_INTEGRATION_SCRIPT}\nSource added to: ${bashrc}\n\nPlease close and re-open your terminal or run 'source ~/.bashrc' to apply the changes.\n\nThis provides:\n- Command marks for scroll-to-command\n- Current working directory tracking\n- Command exit status reporting" 16 80 | ||
| } |
There was a problem hiding this comment.
@copilot put the flag to restart the distro. this is another thing that i need constantly repeating. if the installer needs a reload of the environment like source ~/.bashrc, use the function in commons.sh to signal a distro restart
There was a problem hiding this comment.
Fixed in c5e2e15. Added enable_should_restart call after successful installation.
… comment Co-authored-by: crramirez <8397379+crramirez@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a new installer for Windows Terminal shell integration to pengwin-setup, enabling OSC sequence support for features like scroll-to-command, working directory tracking, and command status reporting in Windows Terminal and WezTerm.
Key Changes
- Adds a shell integration installer that creates a script in
/usr/local/share/pengwin/and modifies~/.bashrcto source it, with marker-based tracking for clean uninstallation - Implements Windows Terminal's OSC 133 sequences (A, B, C, D) for command lifecycle tracking, plus OSC 9;9 for current working directory
- Adds comprehensive test coverage for both installation and uninstallation scenarios
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pengwin-setup.d/shell-integration.sh | Main installer that creates shell integration script and modifies .bashrc with markers |
| pengwin-setup.d/uninstall/shell-integration.sh | Uninstaller that removes .bashrc modifications and cleans up script file |
| pengwin-setup.d/shells.sh | Adds SHELLINT menu entry and handler in the shells menu |
| pengwin-setup.d/uninstall.sh | Adds SHELLINT to uninstall menu in correct alphabetical position |
| completions/pengwin-setup | Adds SHELLINT to bash completion for both SHELLS and UNINSTALL contexts |
| tests/shell-integration.sh | Unit tests verifying installation, script content, and uninstallation |
| tests/run_tests.sh | Integrates new test into CI test suites |
pengwin-setup.d/shell-integration.sh
Outdated
| PROMPT_COMMAND="__wt_update_prompt${PROMPT_COMMAND:+;}${PROMPT_COMMAND}" | ||
| PS1="\[\$(__wt_mark_command_start)\]${PS1}" | ||
| # PS0 is executed after reading a command but before executing it | ||
| PS0='\[\$(__wt_mark_command_executed)\]' |
There was a problem hiding this comment.
The backslash before the dollar sign in PS0 will prevent command substitution from working correctly. When bash expands PS0, \$ is interpreted as an escape sequence meaning "$ if UID != 0, otherwise #", not as the start of command substitution $(...).
This means PS0 will display the literal text $(__wt_mark_command_executed) instead of executing the function.
The fix is to remove the backslash before the dollar sign:
PS0='\[$(__wt_mark_command_executed)\]'For reference, line 77 correctly uses \$ within double quotes to prevent expansion during assignment, which results in PS1 containing $(...) without the backslash. But line 79 uses single quotes where everything is already literal, so the \$ results in PS0 containing the backslash, which then gets interpreted as an escape sequence during prompt expansion.
| PS0='\[\$(__wt_mark_command_executed)\]' | |
| PS0='\[$(__wt_mark_command_executed)\]' |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
pengwin-setup.d/shell-integration.sh
Outdated
| local last_exit_code="$?" | ||
| __wt_mark_command_finished "${last_exit_code}" | ||
| __wt_set_cwd | ||
| __wt_mark_prompt_start | ||
| PS1="${__wt_original_ps1}" |
There was a problem hiding this comment.
Preserve command-start OSC in prompt updates
The integration script resets PS1 to __wt_original_ps1 on every prompt (in __wt_update_prompt), but the PS1 update that prepends __wt_mark_command_start is only applied once during initialization below. Because PROMPT_COMMAND runs before the first prompt, the reset strips the 133;B command-start marker before any prompt is shown, so Windows Terminal never receives the command-start OSC sequence and features like scroll-to-command aren’t activated even after installation.
Useful? React with 👍 / 👎.
…otes Co-authored-by: crramirez <8397379+crramirez@users.noreply.github.com>
|
@copilot codex put the following feedback: P1 Badge Preserve command-start OSC in prompt updates The integration script resets PS1 to __wt_original_ps1 on every prompt (in __wt_update_prompt), but the PS1 update that prepends __wt_mark_command_start is only applied once during initialization below. Because PROMPT_COMMAND runs before the first prompt, the reset strips the 133;B command-start marker before any prompt is shown, so Windows Terminal never receives the command-start OSC sequence and features like scroll-to-command aren’t activated even after installation. Can you check? |
Co-authored-by: crramirez <8397379+crramirez@users.noreply.github.com>
The codex feedback is correct. Fixed in e5e903f. The |
pengwin-setup.d/shell-integration.shfor Windows Terminal shell integrationpengwin-setup.d/shells.shfor the new installerpengwin-setup.d/uninstall/shell-integration.shpengwin-setup.d/uninstall.shcompletions/pengwin-setuptests/shell-integration.shtests/run_tests.sh/usr/local/share/pengwin/wt-shell-integration.shOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.