# HG changeset patch # User Zachary Kanfer # Date 1670739545 18000 # Sun Dec 11 01:19:05 2022 -0500 # Node ID 97a998cac4d16f10c00729d19c52a32a93d319dd # Parent 55a8f7c752400396ccaba01a92a67cb99770c2cb update prompt, to work on new computer. Not sure why it wasn't diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -1,21 +1,31 @@ -function fish_prompt --description 'Informative prompt' - #Save the return status of the previous command - set -l last_pipestatus $pipestatus +function fish_prompt --description 'Write out the prompt' + set -l last_status $status + set -l normal (set_color normal) + set -l status_color (set_color brgreen) + set -l cwd_color (set_color $fish_color_cwd) + set -l vcs_color (set_color brpurple) + set -l prompt_status "" + + # Since we display the prompt on a new line allow the directory names to be longer. + set -q fish_prompt_pwd_dir_length + or set -lx fish_prompt_pwd_dir_length 0 - switch "$USER" - case root toor - printf '%s%s%s# ' (set -q fish_color_cwd_root - and set_color $fish_color_cwd_root - or set_color $fish_color_cwd) \ - (prompt_pwd) (set_color normal) - case '*' - set -l pipestatus_string (__fish_print_pipestatus "[" "] " "|" (set_color $fish_color_status) \ - (set_color --bold $fish_color_status) $last_pipestatus) + # Color the prompt differently when we're root + set -l suffix '❯' + if functions -q fish_is_root_user; and fish_is_root_user + if set -q fish_color_cwd_root + set cwd_color (set_color $fish_color_cwd_root) + end + set suffix '#' + end - # zck I'm including the status twice. Not ideal. - # The second one ($pipestatus_string) has nice coloring, and only prints when there's an error. - printf '\n[%s @ %s]\n%s%s %s%s\f\r> ' $last_pipestatus (date "+%H:%M:%S") \ - (set_color $fish_color_cwd) $PWD $pipestatus_string \ - (set_color normal) + # Color the prompt in red on error + if test $last_status -ne 0 + set status_color (set_color $fish_color_error) + set prompt_status $status_color "[" $last_status "]" $normal end + + echo "" + echo -s $cwd_color (prompt_pwd) $normal " [" (date "+%H:%M:%S") "]" $vcs_color (fish_vcs_prompt) $normal ' ' $prompt_status + echo -n -s $status_color $suffix ' ' $normal end