Files
easy-slack/etc/skel/.bashrc
2025-09-08 15:26:25 +02:00

29 lines
644 B
Bash

PROMPT_COMMAND=__prompt_command
__prompt_command() {
# Store current exit code
local EXIT="$?"
# Define some colors
local RESET='\[\e[0m\]'
local RED='\[\e[0;31m\]'
local GREEN='\[\e[0;32m\]'
local BOLD_GRAY='\[\e[1;30m\]'
# Start with an empty PS1
PS1=""
if [[ $EXIT -eq 0 ]]; then
# Add green if exit code 0
PS1+="${GREEN}0${RESET} "
else
# Add red if exit code non 0
PS1+="${RED}${EXIT}${RESET} "
fi
# These are the default prompts for root and user
if [ $(id -u) -eq 0 ]; then
PS1+="\u@\h:\w ($(ls | wc -l)) ${RESET}# "
else
PS1+="\u@\h:\w ($(ls | wc -l)) ${RESET}$ "
fi
}