2024-11-12 08:56:52 +00:00
|
|
|
ps1() {
|
2024-11-13 12:14:58 +00:00
|
|
|
local date host
|
|
|
|
local code="${1}"
|
|
|
|
date="$(date +%H:%M:%S)"
|
2024-11-12 09:18:44 +00:00
|
|
|
local git
|
2024-11-13 12:14:58 +00:00
|
|
|
host="$(hostname)"
|
2024-11-12 09:18:44 +00:00
|
|
|
local path="${PWD}"
|
|
|
|
local user="${USER}"
|
|
|
|
local view="└ "
|
2024-11-13 12:14:58 +00:00
|
|
|
if [ "${code}" -ne 0 ]; then
|
2024-11-12 09:18:44 +00:00
|
|
|
view="${view}\e[0;31m"
|
|
|
|
else
|
|
|
|
view="${view}\e[0;32m"
|
|
|
|
fi
|
|
|
|
view="${view}${code}\e[0m @ \e[0;33m${date}\e[0m"
|
2024-11-13 10:34:59 +00:00
|
|
|
if [ "$(type -t __git_ps1)" == "function" ]; then
|
2024-11-12 09:18:44 +00:00
|
|
|
git="$(__git_ps1)"
|
2024-11-13 12:10:19 +00:00
|
|
|
if [ -n "${git}" ]; then
|
2024-11-12 09:18:44 +00:00
|
|
|
view="${view} –\e[0;35m${git}\e[0m"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
view="${view}\n\e[0;36m${path}\e[0m"
|
|
|
|
view="${view}\n┌ "
|
2024-11-13 10:34:59 +00:00
|
|
|
if [ ${EUID} -eq 0 ]; then
|
2024-11-12 09:18:44 +00:00
|
|
|
view="${view}\e[0;31m"
|
|
|
|
else
|
|
|
|
view="${view}\e[0;32m"
|
|
|
|
fi
|
|
|
|
view="${view}${user}\e[0m @ \e[0;33m${host}\e[0m"
|
|
|
|
echo -e "${view}\n${PS2}"
|
2023-08-20 16:33:26 +00:00
|
|
|
}
|
|
|
|
|
2024-11-12 08:59:53 +00:00
|
|
|
PS1="\$(ps1 \${?})"
|
2024-11-12 08:56:52 +00:00
|
|
|
|
|
|
|
PS2="\
|
|
|
|
├ "
|