modules/dgn-console: Update hostname display

This commit is contained in:
Tom Hubrecht 2023-07-20 15:48:24 +02:00
parent ef211567a8
commit fef1e90386

View file

@ -32,18 +32,19 @@ in
services.nscd.enableNsncd = false; services.nscd.enableNsncd = false;
programs.bash.promptInit = '' programs.bash.promptInit = ''
FQDN="$(hostname).$(domainname)"
# Provide a nice prompt if the terminal supports it. # Provide a nice prompt if the terminal supports it.
if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then
PROMPT_COLOR="1;31m" PROMPT_COLOR="1;31m"
((UID)) && PROMPT_COLOR="1;32m" ((UID)) && PROMPT_COLOR="1;32m"
if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then
# Emacs term mode doesn't support xterm title escape sequence (\e]0;) # Emacs term mode doesn't support xterm title escape sequence (\e]0;)
PS1="\n\[\033[$PROMPT_COLOR\][\u@$(hostname -f):\w]\\$\[\033[0m\] " PS1="\n\[\033[$PROMPT_COLOR\][\u@$FQDN:\w]\\$\[\033[0m\] "
else else
PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\H: \w\a\]\u@$(hostname -f):\w]\\$\[\033[0m\] " PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\H: \w\a\]\u@$FQDN:\w]\\$\[\033[0m\] "
fi fi
if test "$TERM" = "xterm"; then if test "$TERM" = "xterm"; then
PS1="\[\033]2;$(hostname -f):\u:\w\007\]$PS1" PS1="\[\033]2;$FQDN:\u:\w\007\]$PS1"
fi fi
fi fi
''; '';