Tuning bash colors
This commit is contained in:
@@ -1,24 +1,20 @@
|
||||
#!/usr/bin/env 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/
|
||||
|
||||
function get_color()
|
||||
{
|
||||
local color="$1"
|
||||
echo "\[$(tput setaf "$color")\]"
|
||||
}
|
||||
|
||||
readonly RED=$(get_color 1)
|
||||
readonly GREEN=$(get_color 2)
|
||||
readonly CYAN=$(get_color 6)
|
||||
readonly END_COLOR='\[\033[00m\]'
|
||||
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 working_directory='\w'
|
||||
local workdir='\w'
|
||||
local user_type='\$'
|
||||
|
||||
echo "${debian_chroot:+($debian_chroot)}${GREEN}${username}@${hostname}${END_COLOR}:${CYAN}${working_directory}${END_COLOR}${user_type} "
|
||||
echo "${debian_chroot:+($debian_chroot)}${GREEN}${username}@${hostname}${COLOR_RESET}:${CYAN}${workdir}${COLOR_RESET}${user_type} "
|
||||
}
|
||||
|
||||
function set_ps1_prompt()
|
||||
|
||||
Reference in New Issue
Block a user