MacOS – Mac Terminal app – unable to use the up arrow to load previous commands when using SSH on remote server ( ^[[A )

command linemacosremote desktopsshterminal

I'm running into a weird issue where the UP arrow no longer restores commands previously entered on a remote server during SSH session:

:~ user$ ssh user@myserver
//... type the password, get welcome message
$ ^[[A  //<- This is what I see when pressing up arrow on the server
$ ls //<- I expect to see my previous commands to be visible

How can I make Terminal recall commands entered on a remote server when pressing the Up arrow? This is the behavior that I've observed previously, currently running OSX 10.11.2

Best Answer

Try this:

echo $HISTSIZE

If that number is negative or zero, it will cause the behaviour you're seeing. You need to set it to a positive number in your remote ~/.bash_profile (or ~/.bashrc depending on the remote OS).

export HISTSIZE=100000