I recently embedded an "
alert" command into my
PROMPT_COMMAND to give me a little
notify-send screen notification with the exit code of each command (because I always forget to append the
alert when a long-running job is started).
That works like a charm, but then I discovered a minor nuisance about it:
When I connect to another computer in my network via slogin and want to disconnect with
exit, it states "logout" and then just sits there.
When I press [ctrl]+[c] it is back to my local session without a problem.
I figured out that if I chuck out the "auto-
alert" in all SSH-sessions the problem disappears. It's not that big of a deal, but I just wonder what is happening and maybe how to fix it, if possible.
Here's the command (in my aliases):
alias alert='notify-send --urgency=low -i "$([ $? -eq 0 ] && echo terminal || echo error)" "$(history 1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
And this is in my .bashrc:
if [[ "$PROMPT_COMMAND" != alert* ]]; then # && ([ -z "$SSH_CLIENT" ] || [ -z "$SSH_TTY" ]); then PROMPT_COMMAND="alert; $PROMPT_COMMAND" fi
If i add the comment to the line (remove
; then #), the slogin session exits immediately without a problem (but also doesn't notify me of long-running jobs ending, of course).