0

I've got an annoying problem with iterm2 not remembering my history when I close out a terminal window. I'm not sure if it might be my .bash_profile config or what.

Here is what is happening:

1) type in some commands
2) issue `history` command
3) commands are listed
4) close terminal window and open brand new terminal window
5) issue `history` command
6) commands from previous sessions are NOT listed
7) close terminal window and open brand new terminal window
6) issue `history` command
7) commands from very first session now appearing

Anyone know why the previous commands aren't showing up right away when a new window is opened and only after a second terminal window is opened?

UPDATE: Everything works as expected with the plain old terminal app.

Update 2: I have the shell integration feature installed

Update 3: It turns out the first update was incorrect. It is also flaky on Terminal. Sometimes it will work and other times it doesn't.

  • What happens when you exit the shell before closing the window? – fd0 Aug 18 '18 at 15:02
  • If I type in the "exit" command, it works properly. – StevieD Aug 18 '18 at 15:19
  • Try adding SHELL_SESSION_HISTORY=0 to your ~/.bash_profile file, quite the Terminal/iTerm2 App and reopen, test again. – user3439894 Aug 18 '18 at 20:11
  • Yeah, I've done that for now until I can get the problem resolved. – StevieD Aug 18 '18 at 20:27
2

So it turns out iterm was actually working in iterm. It just waits 5 seconds before saving to .bash_history when you close out of a shell without using the exit command. This 5 second delay is to give you time to command-z the session back open, apparently.

You must log in to answer this question.

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