bashrc/.bashrc.d/12-prompt.sh

30 lines
891 B
Bash
Raw Normal View History

# shellcheck disable=SC2016
promptsetup() {
# Color definitions for prompt
local fg_brightred='\[$(tput setaf 9)\]'
local fg_blue='\[$(tput setaf 4)\]'
local fg_magenta='\[$(tput setaf 13)\]'
local fg_cyan='\[$(tput setaf 6)\]'
local fg_brightcyan='\[$(tput setaf 14)\]'
local fg_green='\[$(tput setaf 2)\]'
local reset='\[$(tput sgr0)\]'
local hostname='\h'
local mixin
# [hh:mm][username@hostname pwd]$
# Remotely, hostname is red.
[ -n "$SSH_CLIENT" ] && hostname="${fg_brightred}\h${reset}"
# If in a python venv, add venv name in green.
[ -n "$VIRTUAL_ENV" ] && mixin=" ${fg_green}$(basename "$VIRTUAL_ENV")${reset}"
# If in a vcsh repo env, add repo name in magenta.
[ -n "$VCSH_REPO_NAME" ] && mixin=" ${fg_magenta}$VCSH_REPO_NAME${reset}"
PS1="${fg_blue}[\A]${fg_cyan}[${fg_brightcyan}\u${fg_cyan}@${hostname}${mixin} ${fg_cyan}\W]${reset}\$ "
}
promptsetup