minimal: Customize prompt to be able to always tell which machine

This commit is contained in:
traxys 2023-04-23 20:24:17 +02:00
parent 8f6bd2cfb5
commit 8ea83b3632

View file

@ -38,7 +38,7 @@
tokei
unzip
wget
frg
frg
# Useful for pandoc to latex
(texlive.combine {
@ -132,9 +132,35 @@
source ${./p10k.zsh}
source ${inputs.powerlevel10k}/powerlevel10k.zsh-theme
if [ -f "$HOME/.zvars" ]; then
source "$HOME/.zvars"
source "$HOME/.zvars"
fi
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
SESSION_TYPE=remote/ssh
else
case $(ps -o comm= -p "$PPID") in
sshd|*/sshd) SESSION_TYPE=remote/ssh;;
esac
fi
if [[ $SESSION_TYPE = remote/ssh ]]; then
title_prefix="$(whoami)@$(hostname) - "
fi
DISABLE_AUTO_TITLE="true"
preexec() {
cmd=$1
if [[ -n $cmd ]]; then
print -Pn "\e]0;$title_prefix$cmd\a"
fi
}
precmd() {
dir=$(pwd | sed "s:$HOME:~:")
print -Pn "\e]0;$(whoami)@$(hostname):$dir\a"
}
${pkgs.fortune}/bin/fortune \
| ${pkgs.cowsay}/bin/cowsay \
| ${pkgs.dotacat}/bin/dotacat