Search code examples
zshoh-my-zsh

Prevent automatic terminal closure/idle process in ZSH


Is there any way to make sure zsh doesn't exit when cluster administrators auto-kill all idle processes after some fairly short amount of time?

I have already figured out how to do it with tmux, but my zsh sessions keep dying and the admins won't budge on the policy. I can always leave a dumb while loop going, but that is really tedious to do at the start of every single zsh session, but it is very frustrating to come back and find that my process has exited, but I have no idea why because the shell that hosted it was killed and the output history is gone.

I use oh-my-zsh, so if there is a module in there that can do this, that would be great too.


Solution

  • I just added a simple script to to my .zshrc. It is an inelegant solution but it does work.

    if [[ "$HOSTNAME" =~ "^myhost*" ]]; then
        while true; do echo 'hi' > /dev/null; sleep 120; done &
    

    I am sure there is a better way because this makes shell startup slower than I would like, but that is what I came up with for now.