flox format

This commit is contained in:
death916 2025-05-30 04:11:32 -07:00
parent a0b4032457
commit 50808eb9bc

View file

@ -100,22 +100,26 @@ in
disabled = false;
};
custom.flox_display = { # Fresh name
description = "Flox environment via internal formatting";
# Command now ONLY outputs the raw variable content or nothing. echo -n is vital.
command = ''echo -n "$FLOX_PROMPT_ENVIRONMENTS"'';
# When clause: Starship should still evaluate this first.
# If this is false, the module should be skipped.
when = ''test -n "$FLOX_PROMPT_ENVIRONMENTS"'';
# Format string now does the prefixing and styling.
# [$output] is the key: if $output (from command) is empty, this group might not render.
# The space after $output is inside the styled group.
format = "[via $output ]($style)"; # If $output is empty, this *should* ideally not render.
style = "bold blue"; # Style applied to the entire "via ❄️ content " group.
shell = "bash";
custom.flox_status = {
description = "Shows current Flox environment status";
# Bash script: if variable is set, echo "via text "; otherwise, echo an empty string.
# Using explicit exit status as well, though output is primary.
command = ''
if [ -n "$FLOX_PROMPT_ENVIRONMENTS" ]; then
echo -n "via $FLOX_PROMPT_ENVIRONMENTS " # Trailing space included
exit 0 # Explicitly succeed
else
echo -n "" # Output nothing
exit 0 # Still succeed, but with no output for Starship
fi
'';
# NO 'when' CLAUSE. Logic is fully in the command.
format = "$output"; # Take the output of the command as is.
shell = ["bash" "-c"]; # Ensure the command is run with bash -c
};
format = ''$directory $git_branch $conda$custom.flox_display$nix_shell$cmd_duration$status$character'';
# Main format string, calling the custom module.
format = ''$directory $git_branch $conda$custom.flox_status$nix_shell$cmd_duration$status$character'';
};
};