.profile: Overcomplicate the prompt
This commit is contained in:
parent
2b9982f8da
commit
035e07d395
35
.profile
35
.profile
@ -261,10 +261,15 @@ alias todo='$EDITOR "$HOME/Documents/todo"'
|
|||||||
_ps1() {
|
_ps1() {
|
||||||
exitcode="$?"
|
exitcode="$?"
|
||||||
r="\e[0m"
|
r="\e[0m"
|
||||||
fg_blue="\e[34m"
|
bg_red="\e[41m"
|
||||||
|
bg_yellow="\e[43m"
|
||||||
|
bg_blue="\e[44m"
|
||||||
|
fg_black="\e[30m"
|
||||||
fg_red="\e[31m"
|
fg_red="\e[31m"
|
||||||
fg_green="\e[32m"
|
fg_green="\e[32m"
|
||||||
fg_yellow="\e[33m"
|
fg_yellow="\e[33m"
|
||||||
|
fg_blue="\e[34m"
|
||||||
|
fg_magenta="\e[35m"
|
||||||
fg_grey="\e[37m"
|
fg_grey="\e[37m"
|
||||||
fg_bold="\e[1m"
|
fg_bold="\e[1m"
|
||||||
|
|
||||||
@ -298,13 +303,39 @@ _ps1() {
|
|||||||
else
|
else
|
||||||
cpwd="$PWD"
|
cpwd="$PWD"
|
||||||
fi
|
fi
|
||||||
|
# Show read-only status in certain directories
|
||||||
|
if [ "$UID" = 0 ]; then
|
||||||
|
# Fuck you I'm root
|
||||||
|
prompt="${fg_red}#${r}"
|
||||||
|
elif ! [ -d "$PWD" ]; then
|
||||||
|
# What the fuck happened to my directory
|
||||||
|
prompt="${bg_red}${fg_black}!${r}"
|
||||||
|
elif ! [ -r "$PWD" ]; then
|
||||||
|
# Can't read is worst case
|
||||||
|
prompt="${fg_red}"'$'"${r}"
|
||||||
|
elif ! [ -x "$PWD" ]; then
|
||||||
|
# Can read it but can't search it is weird but also bad
|
||||||
|
if [ -w "$PWD" ]; then
|
||||||
|
# Fixable
|
||||||
|
prompt="${bg_blue}${fg_black}"'$'"${r}"
|
||||||
|
else
|
||||||
|
# Unfixable
|
||||||
|
prompt="${bg_yellow}${fg_black}"'$'"${r}"
|
||||||
|
fi
|
||||||
|
elif ! [ -w "$PWD" ]; then
|
||||||
|
# Can't write is really common but also good to know
|
||||||
|
prompt="${fg_magenta}"'~'"${r}"
|
||||||
|
else
|
||||||
|
# Otherwise we should be fine
|
||||||
|
prompt="${fg_green}"'$'"${r}"
|
||||||
|
fi
|
||||||
# Alert us if the last command failed
|
# Alert us if the last command failed
|
||||||
unset fail
|
unset fail
|
||||||
if ! [ "$exitcode" = "0" ]; then
|
if ! [ "$exitcode" = "0" ]; then
|
||||||
fail="${fg_bold}${fg_red}?"
|
fail="${fg_bold}${fg_red}?"
|
||||||
fi
|
fi
|
||||||
# shellcheck disable=2059
|
# shellcheck disable=2059
|
||||||
printf "[${prefix}${cpwd}${r}]${fail}${r}${fg_green}\$${r} "
|
printf "[${prefix}${cpwd}${r}]${fail}${r}${prompt}${r} "
|
||||||
}
|
}
|
||||||
|
|
||||||
# And export our PS1
|
# And export our PS1
|
||||||
|
Loading…
Reference in New Issue
Block a user