Extract shared prompt values and refactor bash/git prompts
Move color constants and PS1 escape sequences from bash-prompt.sh into a new shared rc/03-values.sh, and extract the user@host:dir fragment as LWS_PS1_USER_HOST to eliminate duplication between bash-prompt.sh and git-prompt.sh. Wire up git-prompt to use bash-git-prompt with the shared prompt variables.
This commit is contained in:
@@ -2,19 +2,9 @@
|
||||
# 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} "
|
||||
echo "${debian_chroot:+($debian_chroot)}${LWS_PS1_USER_HOST}${LWS_PS1_TYPE} "
|
||||
}
|
||||
|
||||
function set_ps1_prompt()
|
||||
|
||||
Reference in New Issue
Block a user