updated bash prompt to show if I have permissions for the folder I'm in

This commit is contained in:
Solomon Laing 2022-06-26 15:46:23 +09:30
parent 009c7c50e1
commit b428d48fb3

View File

@ -23,7 +23,7 @@ shopt -s checkwinsize
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias lsa='ls -lah'
@ -59,7 +59,15 @@ set_exit_code() {
set_prompt() {
PS1_BAT="$(bash-status-bat)"
PS1_GIT="$(bash-status-git)"
PS1L="\[\033[00;32m\]\u\[\033[00;34m\]@\[\033[01;32m\]\h \[\033[00m\]\$PS1_BAT \[\033[00;36m\]\w\[\033[00m\] $PS1_GIT"
dir_perm=$(ls -ld | awk '{ print $3 }')
if [[ "$dir_perm" == "$USER" ]]; then
dir="\[\033[00;36m\]\w"
else
dir="\[\033[00;31m\]\w"
fi
PS1L="\[\033[00;32m\]\u\[\033[00;34m\]@\[\033[01;32m\]\h \[\033[00m\]\$PS1_BAT $dir\[\033[00m\] $PS1_GIT"
PS1R=$(date +"%R:%S")
PS1=$(printf "%*s\r%s\n\[\033[00m\]\$(set_exit_code)-[ " "$(tput cols)" "$PS1R" "$PS1L")
}