bash history customizing
From: Gabkin (gabriell_at_programmer.net)
Date: 05/28/04
- Next message: Mabden: "Re: The Year 2038 Problem"
- Previous message: SM Ryan: "Re: The Year 2038 Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 28 May 2004 08:55:01 +0200
forgive me if this has been asked before, im a newbie to this
newsgroup, and a google search couldnt find me exactly what im looking
for.
I really like my bash history facility, so much so that i have about
the maximum size set to 50000 and my HISTIGNORE list is rather large.
I found a way to stop history from remembering duplicate commands
(HISTCONTROL=ignoredups), which helps, but I want it to go further.
For one thing, I would like to prevent invalid commands from being
saved in my history. (not terminated commands, if possible, just
invalid ones, i.e. "cd $HOMEE" or "emax afile.txt")
Does anyone know of a good way to do this?
I also want to eliminate all duplicate commands in my history file,
but I want to keep the most recent duplicate only.
In other words if my history contains this...
1 cd $HOME
2 vi somefile.txt
3 cp somefile anotherfile
4 exit
5 cd $HOME
6 vi somefile
7 exit
I would like it to become
1 cp somefile anotherfile
2 cd $HOME
3 vi somefile
4 exit
This way, over time most of my useful, regularly used commands would
rise to the top, while the useless ones would sift to the bottom of
the list. (for eventual manual purging?)
The obvious way is via a sort -u, but this sorts alphabetically which
is totally not what I want.
The only way I can thionk of doing this is via a regularly run script,
is ther a better way of doing it?
Surely im not the only one who has thought of this before...
- Next message: Mabden: "Re: The Year 2038 Problem"
- Previous message: SM Ryan: "Re: The Year 2038 Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|