starship icon indicating copy to clipboard operation
starship copied to clipboard

Access cmd_time and status in transient prompt

Open gaykitty opened this issue 2 years ago • 4 comments

Feature Request

Access cmd_time and status in transient prompt.

Is your feature request related to a problem? Please describe.

I don't want to lose the cmd_time in my shell scroll back with with transience enabled.

Describe the solution you'd like

Have those values be accessable in the starship_transient_prompt_func and starship_transient_rprompt_func functions.

Describe alternatives you've considered

Not sure, but the starship script needs to retain those values somehow.

gaykitty avatar Feb 25 '23 05:02 gaykitty

The status module’s value is accessible in the transient prompt functions like normally, but only if success_symbol is not empty, as per the docs:

If $success_symbol is empty (default), the module will be shown only if the exit code is not 0.

However, there’s a bug when the transience is enabled: the status code is interpreted as 0 for every previous command, no matter what the actual exit code was:

[🟢 (0)] ❯ bash -c 'exit 0'
[🟢 (0)] ❯ bash -c 'exit 1'
[🟢 (0)] ❯ bash -c 'exit 2'

❌ (2) ❯

This means that if you enable the status module and run it with its default configuration, it will never output anything when used in starship_transient_prompt_func or starship_transient_rprompt_func.

I have created a separate bug report for this: https://github.com/starship/starship/issues/5068


I don't want to lose the cmd_time

I think you meant cmd_duration? The time module already works in the history of the transient prompt.

Igetin avatar Apr 06 '23 13:04 Igetin

I think you meant cmd_duration? The time module already works in the history of the transient prompt.

@Igetin Is it expected that starship module cmd_duration shouldn't work inside of starship_transient_(r)prompt_func? I don't seem to get it, myself.

I can file a new issue for this component of things if that is helpful.

(edit: cc @davidkna, I see that lgetin is probably moreso just a helpful passerby?)

sloane-shark avatar Nov 02 '23 19:11 sloane-shark

I think you meant cmd_duration? The time module already works in the history of the transient prompt.

@Igetin Is it expected that starship module cmd_duration shouldn't work inside of starship_transient_(r)prompt_func? I don't seem to get it, myself.

I don’t think I have actually tried the cmd_duration module with the transient prompt myself. I was just asking for clarification from the OP, since I do use the time module they mentioned, and it works as expected for me (but apparently not for them, which is why I thought they might have accidentally mentioned the wrong module in their post).

I see that lgetin is probably moreso just a helpful passerby?

I’m not a code contributor or maintainer on Starship (yet!), if that’s what you mean. 🙂 I’m personally interested in the better status module support with the transient prompt, which is how I originally found and subscribed to this issue, and when I left the previous comment.

Igetin avatar Nov 02 '23 20:11 Igetin

I was excited to try the new right-prompt and transient prompt in bash via ble.sh, but this issue is making it lack a lot of functionality. It would be cool if the previous status/error/etc were cached and returned, until there was a new one to replace it, so that these functions always returned something.

pallaswept avatar Apr 14 '24 17:04 pallaswept