2021-11-03 12:01:43 -05:00
|
|
|
set MAX_PATH_PIECE_CHARS 3
|
2020-01-16 17:01:59 -06:00
|
|
|
|
2021-11-03 12:01:43 -05:00
|
|
|
function get_hostname
|
|
|
|
has_command hostname && hostname || cat /etc/hostname
|
|
|
|
end
|
2020-01-16 17:01:59 -06:00
|
|
|
|
2021-11-03 12:01:43 -05:00
|
|
|
function fish_greeting
|
2022-10-11 22:59:06 -05:00
|
|
|
set_color -b normal brblack
|
2021-11-03 12:01:43 -05:00
|
|
|
printf "%s@%s %s\n" $USER (get_hostname) (date)
|
|
|
|
end
|
2020-01-16 17:01:59 -06:00
|
|
|
|
|
|
|
function preprocess_pwd
|
|
|
|
test (pwd) = / && echo "/" && return 1
|
|
|
|
test (pwd) = $NICE_HOME && echo "~" && return 0
|
2022-05-10 13:23:32 -05:00
|
|
|
pwd | cut -c2- | \
|
|
|
|
awk '{n=split($0,p,"/");for(i=1;i<=n;i++){if(i==n){printf "/%s",p[i]}else{printf "/%.'$MAX_PATH_PIECE_CHARS[1]'s",p[i]}}}'
|
2020-01-16 17:01:59 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
function fish_prompt
|
2020-04-21 16:38:58 -05:00
|
|
|
set last_cmd_status $status
|
2022-10-11 22:59:06 -05:00
|
|
|
if set -q SUDO_USER
|
|
|
|
set_color -b yellow black
|
|
|
|
printf " SUDO "
|
|
|
|
set_color -b normal normal
|
|
|
|
printf " "
|
|
|
|
end
|
|
|
|
if test $last_cmd_status -eq 0
|
|
|
|
set_color -b normal blue
|
|
|
|
else
|
|
|
|
set_color -b normal red
|
|
|
|
end
|
|
|
|
printf "$USER@$hostname"
|
|
|
|
set_color -b normal magenta
|
|
|
|
printf " %s" (preprocess_pwd)
|
|
|
|
set_color -b normal green
|
|
|
|
set -q CMD_DURATION && printf " %dms" $CMD_DURATION
|
|
|
|
if jobs -q
|
|
|
|
set_color -b normal cyan
|
2022-10-11 23:14:24 -05:00
|
|
|
printf " &%d" (jobs -p | wc -l)
|
2022-10-11 22:59:06 -05:00
|
|
|
end
|
|
|
|
printf "\n"
|
|
|
|
set_color brblack
|
2020-04-21 16:38:58 -05:00
|
|
|
if test (id -u) -eq 0
|
2022-10-11 22:59:06 -05:00
|
|
|
printf "# "
|
2020-01-16 17:01:59 -06:00
|
|
|
else
|
2022-10-11 22:59:06 -05:00
|
|
|
printf '$ '
|
2020-01-16 17:01:59 -06:00
|
|
|
end
|
2022-10-11 22:59:06 -05:00
|
|
|
set_color -b normal normal
|
2020-01-16 17:01:59 -06:00
|
|
|
end
|
|
|
|
|
2020-01-17 03:02:53 -06:00
|
|
|
function fish_mode_prompt; end
|
|
|
|
|
2022-10-11 22:59:06 -05:00
|
|
|
function fish_right_prompt
|
|
|
|
end
|