Command Line History

I use the CommandLine often in most of my interactions with Unix/Linux and Windows machines (What else is there? PlanNine).

My preferred shell is bash and I have told it in my .profile to maintain a rather large history file - the last 4000 commands.

 #> grep HIST .profile # -- produced this result:
         HISTFILE=$HOME/History/$HostName$tickenv     # tickenv was a variable used per ticket in our trouble ticket tracking system -- past tense because it no longer tracks thanks to junior staff who had no idea of UnitTests
         HISTFILESIZE=4000
         HISTSIZE=4000
  export HISTFILE HISTFILESIZE HISTSIZE
20080702 WikiGnomes, please give me a day or three to flesh out this code, but go right ahead and refactor CategoryHistory and CategoryDataMining. -- ChrisGarrod

With the thousands of lines of history on a variety of hosts (various architectures), I can examine where I have used some function, and the several commands that follow it. For example: I have a function that searches my wiki for files which contain a string in their title. Given the list, I might then edit all of them, or add a line to one of them, or use one as a target for make, cat, view, et cetera.

I am seeing some recurring patterns. The most common involves SelectOne of the pages, in a loop, add a bunch of lines to it, edit it, and view it in the browser open the URL when I'm in a Mac terminal window.

When our trouble ticket tracking system was working, the saved history helped me continue efforts to resolve the trouble tickets even after reboots with !! or (my memory was better in those days) !x where x was some letter that began the command that had become one of my UnitTests.


One missing piece of information in the CommandLineHistory is the path where the command was executed. I often like to filter by the directory where the command was executed. Or follow the directory changes.

I have coded that into my prompt, so that it can be pasted as the next command -- here or in another window. This is demonstrated here and described better in ComplicatedPrompt -- note that the prompt ends with &&

 # 00:50:14 garrod@humu 1.69 $ cd /net/logs && set | grep ^PS
 PS1='\n# \t \u@\h 1.\# \$ cd \w && '
 PS2=$'\t'
 PS3=$'Pick a number:\t'
 PS4='+ '
 # 00:50:45 garrod@humu 1.70 $ cd /net/logs && cd
 # 00:50:46 garrod@humu 1.71 $ cd ~ && 
See ComplicatedPrompt


CategoryDataMining


EditText of this page (last edited November 7, 2008) or FindPage with title or text search