3

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

2
  • what shell is running on the server?
    – mmmmmm
    May 3, 2016 at 11:20
  • This is not related to the macOS terminal; this is a feature/issue with the shell of the system you are logging in to.
    – mhopeng
    Nov 8, 2022 at 6:54

3 Answers 3

6

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
2
  • I had the same issue as OP, and my returned histsize was 500. I tried your solution anyway and it worked.
    – Cebbie
    Mar 22, 2021 at 18:40
  • Just executing echo $HISTSIZE solved the problem. After executing this command console started work normally. Dec 29, 2021 at 15:47
4

Please try to temporarily change your shell, type the name of the shell:

$ /bin/csh 

See if that fixes your arrow key. If so, your shell or shell profile is having the cause of the problem.

Possible solutions:

  1. Fix your current shell or shell profile.
  2. You can change to a different shell permanently.

Reference: Mac OS X: How to change the Terminal shell

1
  • Thanks, I poked aroudn the settings and see that the terminal window has "SSH" in the window title, as opposed to csh or tcsh. Not sure how to fix that particular profile
    – Alex Stone
    Mar 16, 2016 at 14:29
0

For some reason, using the C command exit(0) messes up my shell, causing this shell issue among others. Specifically this happened while I was fiddling with FFMPEG source code.

Hope this helps other confused googlers :)

You must log in to answer this question.

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