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
|
|
|
|
set_color -b black brblack
|
|
|
|
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
|
2021-11-03 12:01:43 -05:00
|
|
|
# TODO: fix for macOS
|
2020-11-17 17:17:03 -06:00
|
|
|
echo (pwd) | cut -c2- | \
|
|
|
|
awk '{split($0,p,"/");for(k in p){if(k==length(p)){printf "/%s",p[k]}else{printf "/%.'$MAX_PATH_PIECE_CHARS[1]'s",p[k]}}}'
|
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
|
|
|
|
if test (id -u) -eq 0
|
|
|
|
if test $last_cmd_status -eq 0
|
|
|
|
set_color -b blue black
|
|
|
|
else
|
|
|
|
set_color -b red black
|
|
|
|
end
|
2020-05-18 15:34:35 -05:00
|
|
|
printf " SUDO $USER@$hostname "
|
2020-01-16 17:01:59 -06:00
|
|
|
else
|
2020-04-21 16:38:58 -05:00
|
|
|
if test $last_cmd_status -eq 0
|
|
|
|
set_color blue
|
|
|
|
else
|
|
|
|
set_color red
|
|
|
|
end
|
2020-11-17 17:17:03 -06:00
|
|
|
printf %s@%s $USER (echo $hostname | cut -d '.' -f1)
|
2020-01-16 17:01:59 -06:00
|
|
|
end
|
2020-04-21 16:38:58 -05:00
|
|
|
set_color normal
|
|
|
|
printf " "
|
2020-01-16 17:01:59 -06:00
|
|
|
set_color magenta
|
2020-04-21 16:38:58 -05:00
|
|
|
printf (preprocess_pwd)""
|
|
|
|
set_color normal
|
|
|
|
printf " "
|
2020-01-16 17:01:59 -06:00
|
|
|
end
|
|
|
|
|
2020-01-17 03:02:53 -06:00
|
|
|
function fish_mode_prompt; end
|
|
|
|
|
2020-01-24 12:45:49 -06:00
|
|
|
# function fish_right_prompt
|
|
|
|
# set_color brblack
|
|
|
|
# switch $fish_bind_mode
|
|
|
|
# case default
|
|
|
|
# echo 'N'
|
|
|
|
# case insert
|
|
|
|
# echo 'I'
|
|
|
|
# case replace_one
|
|
|
|
# echo 'R'
|
|
|
|
# case replace
|
|
|
|
# echo 'R'
|
|
|
|
# case visual
|
|
|
|
# echo 'V'
|
|
|
|
# end
|
|
|
|
# end
|