2020-07-21 14:15:44 +00:00
|
|
|
function fish_prompt
|
2021-07-14 20:54:12 +00:00
|
|
|
# Save variables before they are gone
|
2024-09-02 23:29:03 +00:00
|
|
|
set "DOTFISH_STATUS" $status
|
|
|
|
set "DOTFISH_UID" (id -u)
|
2020-07-21 14:15:44 +00:00
|
|
|
|
2021-07-14 20:54:12 +00:00
|
|
|
|
|
|
|
# User name
|
2021-07-15 00:57:25 +00:00
|
|
|
switch ~
|
2021-07-15 00:58:18 +00:00
|
|
|
case "/root"
|
2021-07-14 20:54:12 +00:00
|
|
|
# Root
|
2020-07-21 14:15:44 +00:00
|
|
|
set_color brred
|
2021-07-15 00:57:25 +00:00
|
|
|
case "/home/*"
|
2021-07-14 20:54:12 +00:00
|
|
|
# Regular user
|
|
|
|
set_color brgreen
|
2021-07-15 00:57:25 +00:00
|
|
|
case "*"
|
|
|
|
# Temporary account
|
2022-09-26 22:04:46 +00:00
|
|
|
set_color brpurple
|
2020-07-21 14:15:44 +00:00
|
|
|
end
|
|
|
|
echo -n "$USER"
|
2021-07-14 20:54:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Jobs
|
|
|
|
set "JOBSCOUNT" (jobs | count)
|
|
|
|
if test $JOBSCOUNT -ge 1
|
|
|
|
set_color brmagenta
|
|
|
|
echo -n "&$JOBSCOUNT"
|
|
|
|
end
|
2020-07-21 14:15:44 +00:00
|
|
|
|
2021-07-14 20:54:12 +00:00
|
|
|
|
|
|
|
# @
|
|
|
|
set_color normal
|
|
|
|
echo -n "@"
|
|
|
|
|
|
|
|
|
|
|
|
# Hostname
|
2022-09-26 22:04:46 +00:00
|
|
|
if test -n "$SSH_CLIENT"
|
2022-04-27 01:06:31 +00:00
|
|
|
set_color cyan
|
2022-09-26 22:04:46 +00:00
|
|
|
else if test -n "$SUDO_COMMAND"
|
|
|
|
set_color purple
|
|
|
|
else
|
|
|
|
set_color green
|
2021-07-14 20:54:12 +00:00
|
|
|
end
|
2021-09-30 21:51:15 +00:00
|
|
|
|
2021-07-14 20:54:12 +00:00
|
|
|
echo -n (prompt_hostname)
|
|
|
|
|
|
|
|
|
|
|
|
# :
|
2020-07-21 14:15:44 +00:00
|
|
|
set_color normal
|
2021-07-14 20:54:12 +00:00
|
|
|
echo -n ":"
|
|
|
|
|
2020-07-21 14:15:44 +00:00
|
|
|
|
2021-07-14 20:54:12 +00:00
|
|
|
# Current working directory
|
2022-02-07 12:48:26 +00:00
|
|
|
if not test -e "$PWD"
|
2021-07-14 20:54:12 +00:00
|
|
|
set_color brblack
|
2022-02-07 12:48:26 +00:00
|
|
|
else if not test -x .
|
|
|
|
set_color white
|
2021-07-14 20:54:12 +00:00
|
|
|
else if not test -r .
|
|
|
|
set_color white
|
|
|
|
else if not test -w .
|
|
|
|
set_color yellow
|
|
|
|
else
|
|
|
|
set_color brblue
|
|
|
|
end
|
2020-07-21 14:15:44 +00:00
|
|
|
echo -n (prompt_pwd)
|
|
|
|
|
2021-07-14 20:54:12 +00:00
|
|
|
|
|
|
|
# Exit status
|
2024-09-02 23:29:03 +00:00
|
|
|
if test $DOTFISH_STATUS -ne 0
|
2020-07-21 14:15:44 +00:00
|
|
|
set_color brred
|
2024-09-02 23:29:03 +00:00
|
|
|
echo -n "[$DOTFISH_STATUS]"
|
2021-07-14 20:54:12 +00:00
|
|
|
end
|
|
|
|
set_color normal
|
|
|
|
|
|
|
|
|
|
|
|
# Dollar
|
|
|
|
set_color --bold white
|
2024-09-02 23:29:03 +00:00
|
|
|
if test "$DOTFISH_UID" -eq 0
|
2021-07-14 20:54:12 +00:00
|
|
|
echo -n "# "
|
2020-07-21 14:15:44 +00:00
|
|
|
else
|
2021-07-14 20:54:12 +00:00
|
|
|
echo -n "\$ "
|
2020-07-21 14:15:44 +00:00
|
|
|
end
|
|
|
|
set_color normal
|
|
|
|
end
|