#!/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 # echo -n '[' set -l FishStatusCodeCache $status set_color -o 00FF00 echo -n (whoami) set_color normal echo -n '@' set_color AFD75F echo -n (hostname) set_color white echo -n ':' set_color 8787FF echo -n (prompt_abbr $PWD) set_color 5F87D7 echo -n (__fish_vcs_prompt) if test $FishStatusCodeCache -eq 0 #set_color 18C412 else set_color E84505 echo -n " [$FishStatusCodeCache]" end # set_color white # echo -n "]" set_color -o white echo -n "> " set_color normal end