# HG changeset patch # User Zachary Kanfer # Date 1615095560 18000 # Sun Mar 07 00:39:20 2021 -0500 # Node ID 84bc8e608dc96e4f848a31956432553b7cf005ef # Parent 783291706644436fa1e02df1500aa1e0258aa88d add custom prompt. diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish new file mode 100644 --- /dev/null +++ b/functions/fish_prompt.fish @@ -0,0 +1,21 @@ +function fish_prompt --description 'Informative prompt' + #Save the return status of the previous command + set -l last_pipestatus $pipestatus + + 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) + + # 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) + end +end