chris-marsh / pureline

A Pure Bash Powerline PS1 Command Prompt
MIT License
501 stars 94 forks source link

Fixes when inherited PROMPT_COMMAND is not empty #72

Closed CyrilOtheninGirard closed 2 years ago

CyrilOtheninGirard commented 2 years ago

[FIX-1] function 'pureline_pre' now returns the saved error code of the last executed command. => Does not break an inherited PROMPT_COMMAND that requires that value.

[FIX-2] Defines PROMPT_COMMAND as a call to a single function, which is dynamically generated using 'eval' in a robust way, so as to work whatever the content of the inherited PROMPT_COMMAND. => No need to strip trailing whitespaces => No need to check/add a trailing semicolon => No need to handle any other (undiscovered) special case

Note: the "new" function is called 'pureline_ps1', while the "old" one is renamed 'pureline_post'.

CyrilOtheninGirard commented 2 years ago

Defining PROMPT_COMMAND as a single function call ALSO simplifies a lot the integration of pureline with other prompt-modifying tools.

For example, without FIX-2, the 'shell integration' feature of vscode integrated terminals does not work when using pureline :

pureline in vscode - before

With FIX-2, it works again :

pureline in vscode - after