02 May, 2014

Making terminal(s) remember commands

English: Sample of Bash in GNOME Terminal. Scr...
English: Sample of Bash in GNOME Terminal. Screenshot taken in Fedora Linux. Results of ping, pwd, cd, yum and ls command. فارسی: نمونه‌ای از محیط متنی لینوکس (بش) در نرم‌افزار گنوم ترمینال، توزیع فدورا. خروجی دستورهای ping، pwd، cd، ls، و yum. (Photo credit: Wikipedia)
02-May-2014


Here is another trick that I did, and now I had to re-do, so I am recording it, so I can go back to it anytime.

Edit bashrc: gedit/vi ~/.bashrc
Add at last line: export PROMPT_COMMAND="history -a; history -n; $PROMPT_COMMAND"

-a switch is to make terminal record the commands
-n is to record the command history from all terminals (so this is an option)

Save and exit, and voila!

To look at command history, just type history and press [Enter]
To run (again) a command, type !number (on the left of the command) and press [Enter]

Here's the reference: [SOLVED] Terminal doesn't remember last commands

Till then!
Enhanced by Zemanta

No comments:

Post a Comment