You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nixos-template-base/configuration/bash-prompt.sh

33 lines
889 B
Bash

# Git information in prompt
. /run/current-system/sw/share/bash-completion/completions/git-prompt.sh
# Prompt colors
9 years ago
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
PS1_USER='\[$(tput setaf 27)\]'
PS1_HOST='\[$(tput setaf 37)\]'
PS1_ROOT='\[$(tput setaf 160)\]'
PS1_PATH='\[$(tput setaf 64)\]'
PS1_GIT='\[$(tput setaf 136)\]'
PS1_MISC='\[$(tput setaf 230)\]'
else
PS1_USER='\[$(tput setaf 4)\]'
PS1_HOST='\[$(tput setaf 6)\]'
PS1_ROOT='\[$(tput setaf 1)\]'
PS1_PATH='\[$(tput setaf 2)\]'
PS1_GIT='\[$(tput setaf 3)\]'
PS1_MISC='\[$(tput setaf 7)\]'
fi
BOLD='\[$(tput bold)\]'
RESET='\[$(tput sgr0)\]'
# Username or red color if root
9 years ago
if [ $UID = 0 ]; then
PS1_ID=$PS1_ROOT
else
PS1_ID=$PS1_USER'\u'$PS1_MISC@$PS1_HOST
fi
# Prompt definition
9 years ago
PS1=$RESET$BOLD$PS1_ID'\h '$PS1_PATH'\w'$PS1_GIT'$(__git_ps1)'"\n"$PS1_MISC'\$ '$RESET