dotfiles/dot_bashrc.d/executable_10.sshrc.tmpl
2021-02-06 20:19:30 +01:00

92 lines
2.3 KiB
Cheetah

#
# System Name and type detectedn
#
mySystem=$(uname -n)
myFQDN="$(uname -n).$(dnsdomainname)"
myCategory="{{.bash.prompt.category}}"
myType="{{.chezmoi.hostname}}"
{{ if eq .chezmoi.os "windows" -}}
myPrettyName="{{.chezmoi.os}}"
{{ else -}}
myPrettyName="{{.chezmoi.osRelease.prettyName}}"
{{ end -}}
myNum=0
# last exit code
function lastExitCode {
local exit="$?"
if [ $exit != 0 ];then
printf '\e[38;5;160m%-5s' "✕ ❗ ($exit)"
else
printf '✔'
fi
}
# sourcing Solarized Theme is already done in .bashrc.d
echo "mySystem: $mySystem"
echo "myFQDN: $myFQDN"
bg_type="\[\e[48;5;254m\]"
bg_reset="\[\e[49m\]"
fg_reset="\[\e[39m\]"
fg_system="${sol_base3}"
{{- if eq .bash.prompt.category "Materna" }}
# Materna cyan
bg_system="${sol_bg_cyan}"
fg_type="${sol_cyan}"
{{- else if eq .bash.prompt.category "AWS" }}
# AWS specific color
bg_system="${sol_bg_orange}"
fg_type="${sol_orange}"
{{- else }}
# Default color
bg_system="${sol_bg_magenta}"
fg_type="${sol_magenta}"
{{- end }}
bg_type="${sol_bg_base3}"
fg_arrow1="${fg_type}"
fg_arrow2="${sol_base3}"
if [[ -z "${myType// }" ]]; then
TYPE=$(uname -n)
else
TYPE=" $myType "
fi
if [ "$myNum" != "0" ]; then
TYPE="$TYPE ($myNum)"
fi
echo "System Prompt: $SYSTEM_PROMPT"
SYSTEM_PROMPT="\n${fg_arrow1}░▒▓${bg_system} ${fg_system}${myCategory} ${bg_type}${fg_arrow1}▓▒░"
TYPE_PROMPT="$TYPE  \$(lastExitCode) ${fg_arrow1}$myPrettyName ${sol_blue}\${STY#[0-9]*.} ${bg_reset}${fg_arrow2}▓▒░"
PROMPT="${SYSTEM_PROMPT} ${TYPE_PROMPT}"
DATE="\[\e[0;32m\]\d \t"
if [ "$(whoami)" = "root" ]; then
DIR="\[\e[97;49m\]\[\e[0;91;107m\] \u@\h \[\e[97;49m\]\[\e[39;49m\] in \[\e[0;32m\]\w"
else
DIR="\[\e[0;32m\]\u@\h \[\e[31m\]☆ \[\e[0;32m\]\w"
fi
# PROMPT_COMMAND=promptcmd
PS1="${PROMPT}\[\e[0m\] \n${DIR}\n${DATE} → \[\e[0m\]"
if [ $(whoami | grep root | wc -l) == 1 ]; then
echo -e "\e[31;107m┌─────────────────────────────┐\e[0m"
echo -e "\e[31;107m│ YOU ARE ROOT, BE CAREFUL! │\e[0m"
echo -e "\e[31;107m└─────────────────────────────┘\e[0m"
# Test mintty
echo -ne '\e]11;44,10,10\a'
fi
# TODO: background colors...
# TODO: private history file for shared accounts
# TODO: vim