Skip to content

Instantly share code, notes, and snippets.

@mehargags
Created November 23, 2025 15:59
Show Gist options
  • Select an option

  • Save mehargags/32ff5c3013b82616fd7a55731358076a to your computer and use it in GitHub Desktop.

Select an option

Save mehargags/32ff5c3013b82616fd7a55731358076a to your computer and use it in GitHub Desktop.
Custom-Bash-Prompt
# Try first in terminal
PS1='\[\e[48;5;178m\] \[\e[48;5;179m\] \[\e[0;38;5;179m\]__\[\e[0m\] \[\e[38;5;208m\]\u\[\e[0m\]@\[\e[38;5;43m\]\h\[\e[0m\] \[\e[38;5;179m\]__\[\e[0;48;5;179m\] \n\[\e[0;38;5;215m\][\w]\[\e[0m\]\$ '
# 1. Backup your current file
cp /etc/bash.bashrc /etc/bash.bashrc.bak-final-$(date +%F)
# 2. Replace /etc/bash.bashrc with the bullet-proof version
cat > /etc/bash.bashrc <<'EOF'
# /etc/bash.bashrc – Debian 13 – your exact colors + layout (fixed root/user swap)
# used https://bash-prompt-generator.org/ to generate prompt
# 1. Define colors
USER_COLOR_ROOT="\[\e[38;5;210m\]"
USER_COLOR_NORMAL="\[\e[38;5;183m\]"
HOST_COLOR="\[\e[38;5;36m\]"
PWD_COLOR="\[\e[38;5;178m\]"
RESET="\[\e[0m\]"
# 2. THIS PART WAS MISSING IN YOUR TEST – decide which color to use
if [ "$EUID" -eq 0 ]; then
UC="$USER_COLOR_ROOT"
END="#"
else
UC="$USER_COLOR_NORMAL"
END="\$"
fi
# 3. Now build PS1
PS1="${UC}\u${RESET}@${HOST_COLOR}\h${RESET}:\n[${PWD_COLOR}\w${RESET}]${END} "
EOF
# 3. Make sure skeleton doesn't overwrite it (new users)
cat > /etc/skel/.bashrc <<'EOF'
[[ $- != *i* ]] && return
[ -r /etc/bash.bashrc ] && . /etc/bash.bashrc
EOF
# 4. Fix ALL existing users right now (including gagan)
for dir in /home/*; do
[ -f "$dir/.bashrc" ] && cp /etc/skel/.bashrc "$dir/.bashrc" && chown --reference="$dir" "$dir/.bashrc"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment