New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(bash): add case for vscode integrated terminal #5817
base: master
Are you sure you want to change the base?
fix(bash): add case for vscode integrated terminal #5817
Conversation
Problem: if starship was init as part of bashrc (or any user profile script), vscode will define function Current behavior: if we are in vscode and starship was NOT init in a user profile script, New behavior: if we are in vscode and starship was NOT init in a user profile script, then Converting this PR as draft, it needs more digging. |
@NeodymiumFerBore Now that #5735 is merged, debug traps are avoided on recent bash versions. |
@davidkna thank you for your comment, I wish I saw it before haha, integration with vscode is very tricky because of this debug trap. I will rebase my branch on master and only treat the |
685eff6
to
5468227
Compare
Update: Rebased onto master (f66bfd9 as of now). Squashed commits. Edited my tests: sourcing a file is not the same as evaluating it, and traps are not handled the same way. Tests done with With this patch, evaluating multiple times
For bash >= 4.4 evaluating |
5468227
to
a034121
Compare
I can't reproduce the issue, would you mind sharing more detailed instructions for reproducing the breakage in vscode? |
Description
In starship.bash init script, handle vscode integrated terminal
PROMPT_COMMAND
override.Motivation and Context
Fix an issue where manually sourcing a file evaluating
starship init bash
(typically a bashrc) would crash vscode integrated terminal if starship init had already been evaluated at terminal startup.Closes #5816
Screenshots (if appropriate):
How Has This Been Tested?
tests details
After reproducing the bug described in issue #5816 :
In vscode
cd
into starship git repositorygit checkout fix/vscode-infinite-loop
::STARSHIP::() { starship "$@"; }
eval "$(cat ./src/init/starship.bash)"
__vsc_original_prompt_command=()
eval "$(cat ./src/init/starship.bash)"
${__vsc_original_prompt_command[@]}
containsstarship_precmd
as expectedOutside vscode
cd
into starship git repositorygit checkout fix/vscode-infinite-loop
::STARSHIP::() { starship "$@"; }
eval "$(cat ./src/init/starship.bash)"
Both inside and outside vscode: check we didn't break something
unset PROMPT_COMMAND
eval "$(cat ./src/init/starship.bash)"
PROMPT_COMMAND
is restored tostarship_precmd
, the PS1 works as expectedstarship_precmd() { :; }
eval "$(cat ./src/init/starship.bash)"
Checklist:
I have 2 questions: