Last active
March 13, 2025 19:37
-
-
Save mehargags/7eb5b90a4918c1a399a18143bd21f3a8 to your computer and use it in GitHub Desktop.
Prompt-user-domain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this to your ~/.bashrc | |
# Colors | |
USER_GREEN="\[\033[32m\]" | |
BRIGHT_AQUA="\[\033[96m\]" | |
PINK="\[\033[38;5;213m\]" | |
RESET="\[\033[0m\]" | |
# Custom prompt function | |
custom_prompt() { | |
# Get current working directory and logged in user | |
local pwd=$(pwd) | |
local logged_user="$USER" | |
# Get just the current directory name | |
local current_dir=${pwd##*/} | |
# Handle root directory special case | |
[[ $pwd == "/" ]] && current_dir="/" | |
# Check if we're in the specific web directory structure | |
if [[ $pwd =~ /home/([^/]+)/web/([^/]+)/public_html ]]; then | |
local user="${BASH_REMATCH[1]}" | |
local domain="${BASH_REMATCH[2]}" | |
# Web directory prompt with logged user, user/domain in brackets, and p_h indicator | |
PS1="${BRIGHT_AQUA}${logged_user}${RESET}:[${USER_GREEN}${user}${RESET}/${PINK}${domain}${RESET}]p_h\$ " | |
else | |
# Default prompt with just current directory name | |
PS1="${BRIGHT_AQUA}${logged_user}${RESET}:${current_dir}\$ " | |
fi | |
} | |
PROMPT_COMMAND=custom_prompt | |
if [ "${PATH#*/usr/local/hestia/bin*}" = "$PATH" ]; then | |
. /etc/profile.d/hestia.sh | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment