1
0
Fork 0

Show welcome message after starting a shell ...

... with some basic information, mainly
to show that the dotfiles are used
This commit is contained in:
Alexander Hess 2026-06-11 18:28:03 +02:00
commit 033c1d4e27
Signed by: alexander
GPG key ID: D88F903B85326FFE
2 changed files with 56 additions and 0 deletions

52
.config/shell/welcome Normal file
View file

@ -0,0 +1,52 @@
#!/bin/sh
# Show system info each time a shell is started
_hostname=$(uname -n)
_os="$(uname -s) $(uname -r)"
_user=$(whoami)
_work_dir=$(echo "$PWD" | sed "s|^$HOME|~|")
if uptime -p >/dev/null 2>&1; then # because some systems (e.g. BusyBox) don't support "-p"
_uptime=$(uptime -p | sed 's/up //; s/weeks\?/w/g; s/days\?/d/g; s/hours\?/h/g; s/minutes\?/m/g; s/ //g')
else
_uptime=$(uptime 2>/dev/null | sed 's/.*up *//; s/,.*//')
fi
if [ "$(id -u)" -eq 0 ]; then
_prompt="#"
else
_prompt="$"
fi
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
_remote=" ssh"
else
_remote=" local"
fi
if _in_bash; then
_shell_type="bash"
elif _in_zsh; then
_shell_type="zsh"
else
_shell_type="non-bash/zsh shell"
fi
_info_line="$_user@$_hostname:$_work_dir$_prompt$_remote $_os uptime: $_uptime $_shell_type"
_sep_line=$(echo "$_info_line" | sed 's/./─/g')
echo ""
echo "$_sep_line"
echo "$_info_line"
echo "$_sep_line"
echo ""
unset _hostname _os _user _work_dir _uptime _prompt _remote _shell_type _info_line _sep_line

View file

@ -60,3 +60,7 @@ fi
# Put local executables on the `$PATH` # Put local executables on the `$PATH`
_prepend_to_path "$HOME/.local/bin" _prepend_to_path "$HOME/.local/bin"
# When everything is loaded, show a little welcome message
case $- in *i*) [ -f "$HOME/.config/shell/welcome" ] && . "$HOME/.config/shell/welcome";; esac