#!/bin/fish set PROMPTDIRS "~":$HOME # # This function takes the $PROMPTDIRS variable and tries to shorten the # input (i.e. $argv[1]) w.r.t. the variable. # # e.g. If $PROMPTDIRS contains the pair $PR:$HOME/Projects, # # (prompt_abbr ~/Projects/Applications) # # will show "$PR/Applications", and ~/Projects will be converted to $PR. # # To set multiple $PROMPTDIRS entry, use successive (where $ABBR is some # directory to be abbreviated) # # set PROMPTDIRS \$ABBR:$ABBR $PROMPTDIRS # # with the outermost directory being set first. # function prompt_abbr set in $argv[1] for d in $PROMPTDIRS set -l kv (string split -m 1 ":" $d) switch "$in" case "$kv[2]/*" set in (string replace $kv[2] $kv[1] $in) break case "$kv[2]" set in "$kv[1]" break case "*" end end echo "$in" end function fish_prompt # set_color white # printf '[' set -l FishStatusCodeCache $status set_color -o 00FF00 printf (whoami) set_color normal printf '@' set_color AFD75F printf (prompt_hostname) set_color white printf ':' set_color 8787FF printf (prompt_abbr $PWD) set -l vcs_prompt (fish_vcs_prompt) if test -n "$vcs_prompt" printf " " set_color 5F87D7 printf '\uf126' printf (fish_vcs_prompt) end if test $FishStatusCodeCache -eq 0 #set_color 18C412 else set_color E84505 printf " [$FishStatusCodeCache]" end # set_color white # printf "]" set_color 999999 printf " " printf (date '+%Y/%m/%d %H:%M:%S') printf "\n" #set_color -o white #printf "> " set_color -o green printf "⮀ " set_color normal end