I have rdist set up to push out some of my dot files to all the remote machines that I need to ssh into. I also have zsh as my default shell on all of those machines.

When I ssh into a machine and then exit, the screen is cleared. I find this behavior bothersome. My attempt to prevent this behavior was to comment out the /usr/bin/clear line in my .logout file. I then dist'd this updated file out to all the remote machines.

The trouble is, that didn't work. I am unsure about this, but I thought .logout was for csh, but I don't have a .zlogout (or .bash_logout either, for that matter). There's nothing in any of my other dot files (e.g., .zshrc, .zshenv) that seems like it would cause the screen to clear. When I ssh into a remote machine, then exec zsh (in order to get a "fresh" shell session), then the terminal will not clear upon exiting the ssh session. But otherwise, the problem persists - on any machine that I connect to, the screen clears upon exiting.

For what it's worth, I don't appear to have the same problem when I set my default shell on the remote machines to bash. So I assume the problem is with zsh.

I checked the dot files to make sure they got dist'd correctly (they did). Aside from this, I'm running out of ideas... why does my terminal keep getting cleared when exiting ssh?

edit: I found the source of the problem: There is a /etc/zlogout file on many of the remote machines. I don't have sudo privileges on many of these machines and I don't want to globally affect users; is there a way to override the functionality in /etc/zlogout? Simply making a $HOME/.zlogout file doesn't seem to work.

  • 2
    I found kind of a hackish way to do what I want. I simply made clear an alias to "" in my .zlogout file. That way when the clear command in /etc/zlogout is called, nothing happens.
    – jayhendren
    Apr 2, 2013 at 22:38
  • Sorry, totally missed the part about your ~/.zlogout file. I'll delete my answer and you can add your own.
    – depquid
    Apr 3, 2013 at 16:15
  • If you turned your "edit" into an answer I would accept it, this has bothered me for a long time too. Aug 20, 2013 at 17:21

1 Answer 1


Zsh on RHEL 7 behaves the same a way, i.e. during ssh logout the terminal is cleared.

(Depending on the terminal the last terminal output is lost, or it is just scrolled out of view.)

This is because of /etc/zlogout - which is part of the zsh package - is containing:


(it does not contain other commands)

You can override this clearing in your own .zlogout file via completely disabling the reading of /etc/zlogout during logout:

$ cat ~/.zlogout
setopt norcs

Disabling the rcs option disables the sourcing of certain run control files - probably hence the name: no Run Control Sourcing

  • 3
    You can also alias clear="" in ~/.zlogout, though I think your solution is much cleaner.
    – jayhendren
    Dec 8, 2014 at 20:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .