mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-05-28 06:00:54 +00:00
2233683410
This creates a custom logger for the log crate which logs everything to a file (/tmp/starship/session_$STARSHIP_SESSION_KEY.log) and it logs everything above Warn to stderr, but only if the log file does not contain the line that should be logged resulting in an error or warning to be only logged at the first starship invocation after opening the shell.
21 lines
1.1 KiB
Plaintext
21 lines
1.1 KiB
Plaintext
# The PROMPT function is called whenever a prompt needs to be drawn. Docs: https://doc.redox-os.org/ion-manual/html/misc/06-prompt_fn.html
|
|
fn PROMPT
|
|
# Save the status immediately, since the status is also updated after variable assignment, etc.
|
|
let STARSHIP_ION_STATUS = $?
|
|
# Save the ION_CMD_DURATION before running any other commands, but after the status since the
|
|
# duration is not updated during variable assignment
|
|
# Account for variable name change sometime during December 2019 - January 2020
|
|
let STARSHIP_ION_CMD_DURATION = $or($CMD_DURATION $ION_CMD_DURATION)
|
|
let STARSHIP_ION_CMD_DURATION = $((STARSHIP_ION_CMD_DURATION * 1000))
|
|
|
|
# The STARSHIP between the colons will be replaced with the actual path to the starship executable.
|
|
# The jobs command outputs to stderr, therefore we need to pipe stderr to `wc -l`.
|
|
::STARSHIP:: prompt --status $STARSHIP_ION_STATUS --jobs $(jobs ^| wc -l) --cmd-duration $STARSHIP_ION_CMD_DURATION
|
|
end
|
|
|
|
# Export the correct name of the shell
|
|
export STARSHIP_SHELL="ion"
|
|
|
|
# Set up the session key that will be used to store logs
|
|
export STARSHIP_SESSION_KEY=$(::STARSHIP:: session)
|