Closed rpdelaney closed 6 years ago
It feels like this is not the responsibility of sexy-bash-prompt
. Why are you setting a global set -x
flag? Is there a problem with setting it inside your script?
For what it's worth, if someone is setting a global flag, then they might actually want debug output from sexy-bash-prompt
as well as everything else.
Setting it inside the script is not a 'problem', per se: it's just inconvenient.
For people who want to debug the prompt, I suppose we could support another env var like SEXY_BASH_PROMPT_DEBUG
. Or they could edit the script ;)
Yea, but that feels like we are adding more workarounds to the problem.
I added a set -x
to my terminal and only saw 2 invocations:
Then, I moved my prompt to use these set +x
flags:
# Define the sexy-bash-prompt
PS1="\[$sexy_bash_prompt_user_color\]\u\[$sexy_bash_prompt_reset\] \
\[$sexy_bash_prompt_preposition_color\]at\[$sexy_bash_prompt_reset\] \
\[$sexy_bash_prompt_device_color\]\h\[$sexy_bash_prompt_reset\] \
\[$sexy_bash_prompt_preposition_color\]in\[$sexy_bash_prompt_reset\] \
\[$sexy_bash_prompt_dir_color\]\w\[$sexy_bash_prompt_reset\]\
\$(set +x && sexy_bash_prompt_is_on_git && \
echo -n \" \[$sexy_bash_prompt_preposition_color\]on\[$sexy_bash_prompt_reset\] \" && \
echo -n \"\[$sexy_bash_prompt_git_status_color\]\$(sexy_bash_prompt_get_git_info)\" && \
echo -n \"\[$sexy_bash_prompt_git_progress_color\]\$(sexy_bash_prompt_get_git_progress)\" && \
echo -n \"\[$sexy_bash_prompt_preposition_color\]\")\n\[$sexy_bash_prompt_reset\]\
\[$sexy_bash_prompt_symbol_color\]$(set +x && sexy_bash_prompt_get_prompt_symbol) \[$sexy_bash_prompt_reset\]"
But there are still echos coming from the prompt.
Ah, never mind. I went into a git directory and now see al the noise.
I did some research but am going to step away for a bit. New info I found out:
set -o xtrace
is an alias for set -x
xtrace
is enabled
via set -o
)set -x
output via BASH_XTRACEFD
(all info via man bash
)
Alright, back. I am still on the fence about this. Can we research what other libraries do for this scenario?
I'm looking into it.
When I need to run anything with +x I run it like this: $ set -x; comand -arg1 -arg2 -arg3; set +x;
clean terminal again.
Yeah good enough for me.
set -x
is a familiar shell option for debugging. Usually, I like to set it from the command-line before running a script to debug, as is common practice. But this causes lots of unwanted debugging output from sexy-bash-prompt because the functions it invokes also return debugging output.Would it be reasonable to add a handler to each function that checks for this flag, disables it, and then restores it before exit? I could submit a pull request to that effect.