Files
linux-workspace/rc/bash-prompt.sh
2024-03-16 11:11:55 +01:00

27 lines
610 B
Bash

# Inspired by
# https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/
# https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
CYAN=$(tput setaf 6)
COLOR_RESET=$(tput sgr0)
function get_ps1_prompt()
{
local username='\u'
local hostname='\h'
local workdir='\w'
local user_type='\$'
echo "${debian_chroot:+($debian_chroot)}${GREEN}${username}@${hostname}${COLOR_RESET}:${CYAN}${workdir}${COLOR_RESET}${user_type} "
}
function set_ps1_prompt()
{
PS1="$(get_ps1_prompt)"
export PS1
}
set_ps1_prompt