Support greyscale prompt for eInk terminal profile
This commit is contained in:
parent
cb6886d47a
commit
001035a19d
|
@ -26,6 +26,7 @@ foreground = "#000000"
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
TERM_TITLE = "Alacritty (Fedora eInk)"
|
TERM_TITLE = "Alacritty (Fedora eInk)"
|
||||||
|
TERM_LIGHT = "1"
|
||||||
|
|
||||||
[font]
|
[font]
|
||||||
size = 11.0
|
size = 11.0
|
||||||
|
|
|
@ -6,26 +6,13 @@ if [[ $1 && $1 != 'h' && $1 != '-h' && $1 != 'help' && $1 != '--help' && $1 != '
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Declare the S name (as used by `setterm`) and B for POSIX background colour
|
# Dark mode terminals should have black text on color; light mode has white
|
||||||
# Reference them later like: ${COLOURS["BLACK","S"]} or ${COLOURS["CYAN","B"]}
|
TEXT=0
|
||||||
declare -A COLOURS='(
|
BG=3
|
||||||
[0,S]="default"
|
if [[ -n $TERM_LIGHT ]]; then
|
||||||
[0,B]="\[\e[0m\]"
|
TEXT=7
|
||||||
[1,S]="red"
|
BG=4
|
||||||
[1,B]="\[\e[1;30;41m\]"
|
fi
|
||||||
[2,S]="green"
|
|
||||||
[2,B]="\[\e[1;30;42m\]"
|
|
||||||
[3,S]="yellow"
|
|
||||||
[3,B]="\[\e[1;30;43m\]"
|
|
||||||
[4,S]="blue"
|
|
||||||
[4,B]="\[\e[1;30;44m\]"
|
|
||||||
[5,S]="magenta"
|
|
||||||
[5,B]="\[\e[1;30;45m\]"
|
|
||||||
[6,S]="cyan"
|
|
||||||
[6,B]="\[\e[1;30;46m\]"
|
|
||||||
[7,S]="white"
|
|
||||||
[7,B]="\[\e[1;30;47m\]"
|
|
||||||
)'
|
|
||||||
|
|
||||||
# Assign colour to each module
|
# Assign colour to each module
|
||||||
P="7" # prompt default, white
|
P="7" # prompt default, white
|
||||||
|
@ -39,6 +26,35 @@ B="4" # distrobox
|
||||||
S="5" # ssh
|
S="5" # ssh
|
||||||
D="6" # dir
|
D="6" # dir
|
||||||
G="7" # git
|
G="7" # git
|
||||||
|
GS="1" # git sigils
|
||||||
|
|
||||||
|
# Declare the S name (as used by `setterm`) and B for POSIX background colour
|
||||||
|
# Reference them later like: ${COLOURS["BLACK","S"]} or ${COLOURS["CYAN","B"]}
|
||||||
|
declare -A COLOURS='(
|
||||||
|
[0,S]="default"
|
||||||
|
[0,B]="\[\e[0m\]"
|
||||||
|
[1,S]="red"
|
||||||
|
[1,B]="\[\e[1;3${TEXT};41m\]"
|
||||||
|
[2,S]="green"
|
||||||
|
[2,B]="\[\e[1;3${TEXT};42m\]"
|
||||||
|
[3,S]="yellow"
|
||||||
|
[3,B]="\[\e[1;3${TEXT};43m\]"
|
||||||
|
[4,S]="blue"
|
||||||
|
[4,B]="\[\e[1;3${TEXT};44m\]"
|
||||||
|
[5,S]="magenta"
|
||||||
|
[5,B]="\[\e[1;3${TEXT};45m\]"
|
||||||
|
[6,S]="cyan"
|
||||||
|
[6,B]="\[\e[1;3${TEXT};46m\]"
|
||||||
|
[7,S]="white"
|
||||||
|
[7,B]="\[\e[1;30;47m\]"
|
||||||
|
)'
|
||||||
|
|
||||||
|
if [[ $TEXT != 0 ]]; then
|
||||||
|
COLOURS[7,S]="black"
|
||||||
|
COLOURS[7,B]="\[\e[1;37;40m\]"
|
||||||
|
G=0
|
||||||
|
GS=7
|
||||||
|
fi
|
||||||
|
|
||||||
# If directory was just changed to the root of a git repository, print onefetch
|
# If directory was just changed to the root of a git repository, print onefetch
|
||||||
if [ -n "$DIRCHANGED" ]; then
|
if [ -n "$DIRCHANGED" ]; then
|
||||||
|
@ -83,7 +99,7 @@ esac
|
||||||
# Get current git branch
|
# Get current git branch
|
||||||
function parse_git_branch() {
|
function parse_git_branch() {
|
||||||
BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
|
BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
|
||||||
[ ! "${BRANCH}" == "" ] && echo "\[\e[1;31;4${G}m\]$(parse_git_dirty)${COLOURS["$G","B"]}${BRANCH}" || echo ""
|
[ ! "${BRANCH}" == "" ] && echo "\[\e[1;3${GS};4${G}m\]$(parse_git_dirty)\[\e[1;3${TEXT};4${G}m\]${BRANCH}" || echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get git status
|
# Get git status
|
||||||
|
@ -115,14 +131,14 @@ LASTB=$P
|
||||||
if [ -f "/run/.containerenv" ]; then
|
if [ -f "/run/.containerenv" ]; then
|
||||||
H=$B
|
H=$B
|
||||||
[[ $1 ]] && setterm --foreground ${COLOURS[$H,"S"]} && echo "distrobox" && setterm --foreground default
|
[[ $1 ]] && setterm --foreground ${COLOURS[$H,"S"]} && echo "distrobox" && setterm --foreground default
|
||||||
PS1="${PS1}\[\e[0;3${LASTB};4${H}m\]"${SEP}"${COLOURS["$H","B"]}📦"
|
PS1="${PS1}\[\e[0;${BG}${LASTB};4${H}m\]"${SEP}"${COLOURS["$H","B"]}📦"
|
||||||
elif [[ -z $SSH_CLIENT ]]; then
|
elif [[ -z $SSH_CLIENT ]]; then
|
||||||
[[ $1 ]] && setterm --foreground ${COLOURS[$H,"S"]} && echo "host session" && setterm --foreground default
|
[[ $1 ]] && setterm --foreground ${COLOURS[$H,"S"]} && echo "host session" && setterm --foreground default
|
||||||
PS1="${PS1}\[\e[0;3${LASTB};4${H}m\]"${SEP}"${COLOURS["$H","B"]}🏠"
|
PS1="${PS1}\[\e[0;${BG}${LASTB};4${H}m\]"${SEP}"${COLOURS["$H","B"]}🏠"
|
||||||
else
|
else
|
||||||
H=$S
|
H=$S
|
||||||
[[ $1 ]] && setterm --foreground ${COLOURS[$H,"S"]} && echo "ssh connection" && setterm --foreground default
|
[[ $1 ]] && setterm --foreground ${COLOURS[$H,"S"]} && echo "ssh connection" && setterm --foreground default
|
||||||
PS1="${PS1}\[\e[0;3${LASTB};4${H}m\]"${SEP}"${COLOURS["$H","B"]}🖧 "
|
PS1="${PS1}\[\e[0;${BG}${LASTB};4${H}m\]"${SEP}"${COLOURS["$H","B"]}🖧 "
|
||||||
fi
|
fi
|
||||||
LASTB=$H
|
LASTB=$H
|
||||||
|
|
||||||
|
@ -151,12 +167,12 @@ fi
|
||||||
# User
|
# User
|
||||||
[[ $(whoami) == 'root' ]] && U=$R
|
[[ $(whoami) == 'root' ]] && U=$R
|
||||||
[[ $1 ]] && setterm --foreground ${COLOURS["$U","S"]} && echo "user" && setterm --foreground default
|
[[ $1 ]] && setterm --foreground ${COLOURS["$U","S"]} && echo "user" && setterm --foreground default
|
||||||
PS1="${PS1}\[\e[0;3${LASTB};4${U}m\]"${SEP}"${COLOURS["$U","B"]}\\u\[\e[0;30;4${U}m\]@"
|
PS1="${PS1}\[\e[0;3${LASTB};4${U}m\]"${SEP}"${COLOURS["$U","B"]}\\u\[\e[0;3${TEXT};4${U}m\]@"
|
||||||
LASTB=$U
|
LASTB=$U
|
||||||
|
|
||||||
# Host
|
# Host
|
||||||
[[ $1 ]] && setterm --foreground ${COLOURS["$H","S"]} && echo "hostname" $([[ -z $SSH_TTY ]] || echo " (ssh)") && setterm --foreground default
|
[[ $1 ]] && setterm --foreground ${COLOURS["$H","S"]} && echo "hostname" $([[ -z $SSH_TTY ]] || echo " (ssh)") && setterm --foreground default
|
||||||
PS1="${PS1}\[\e[0;3${LASTB};4${H}m\]"${SEP}"${COLOURS["$H","B"]}\\h\[\e[0;30;4${H}m\]:"
|
PS1="${PS1}\[\e[0;3${LASTB};4${H}m\]"${SEP}"${COLOURS["$H","B"]}\\h\[\e[0;3${TEXT};4${H}m\]:"
|
||||||
LASTB=$H
|
LASTB=$H
|
||||||
|
|
||||||
# Dir
|
# Dir
|
||||||
|
|
Loading…
Reference in New Issue