What setup do I need to use up-arrow to run previous command? With Mac, I can use up-arrow to rerun the command that I just run, but it doesn't seem to work with my bash shell.
I use 8.04 (I can't use the newest distribution because of some compiler version issues).
ADDED
I didn't change anything as it's a fresh install with VMWare Fusion on Mac.
Make sure you are actually using bash. A common gotcha is creating a new user with
useradd
instead ofadduser
or the Users and groups (GUI) application. With the former, the default shell set is/bin/sh
. Runchsh
(change shell) to make sure it's set to/bin/bash
.Make sure that your history is enabled. You can check the current status by running:
The output should contain (note the
history on
line):If this is not enabled, you need to run
set -o history
. To make this change persistent, you need to append it to~/.bashrc
:If you want to run the previous command, you can run the next command as well:
From Bash manual page:
If you're using Bash, you can use the default shortcuts for navigating through the history as well:
Ctrl + N: Next command
Commands for Manipulating the History previous-history (C-p) Fetch the previous command from the history list, moving back in the list. next-history (C-n) Fetch the next command from the history list, moving forward in the list.
In terminal enter:
Then copy paste and save:
From now on in terminal you can do incremental search, All you need to do to find a previous command is to enter say the first two or three letters and upward arrow will take you there quickly.
My solution is:
vi /etc/inputrc