function fish_prompt set -l user $USER set -l cwd $PWD set -l home $HOME if test "$cwd" = "$home" # if in ~ echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"~"(set_color white)")\n" \ (set_color white)"λ "(set_color normal) # max at ~ # λ else if string match -q "$home/*" $cwd set -l relative (string replace "$home/" "~/" $cwd) set -l parts (string split "/" $relative) set -l colored "" for p in $parts if test -n "$p" set colored $colored(set_color white)$p(set_color red)"/" end end set colored (string trim -r -c "/" $colored) # if in a ~ subdir echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"$colored"(set_color white)")\n" \ (set_color white)"λ "(set_color normal) else set -l parts (string split "/" $cwd) set -l colored "" for p in $parts if test -n "$p" set colored $colored(set_color white)$p(set_color red)"/" end end set colored (string trim -r -c "/" $colored) set colored (set_color red)"#"$colored # if in any other dir echo -e (set_color white)"("(set_color red)"$user"(set_color white)" at "(set_color red)"$colored"(set_color white)")\n" \ (set_color white)"λ "(set_color normal) end end