Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Rewriting History (letter LXF187p93)

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Magazine and coverdiscs
View previous topic :: View next topic  
Author Message
johnlane



Joined: Tue Nov 06, 2012 4:55 pm
Posts: 16

PostPosted: Tue Jul 15, 2014 10:01 am    Post subject: Rewriting History (letter LXF187p93) Reply with quote

A nice letter about the bash history in LXF187. I thought I'd jot down a couple of extra points for anyone interested. Here is my config (in /etc/bash.bashrc):

Code:

export HISTSIZE=999
export HISTFILESIZE=999
export HISTCONTROL=ignoredups:erasedups
export PROMPT_COMMAND="history -n; history -w; history -c; history -r"
export HISTIGNORE=ls:h:history
shopt -s histappend
alias h=history


There are a couple of differences.


    I set HISTSIZE and HISTFILESIZE - the former sets the size of the in-memory buffer and the latter sets the size of the on-disk file.

    I set PROMPT_COMMAND to save and re-load the history. The reasoning for this command sequence is explained here

    I set HISTIGNORE to common commands from being stored.

    I also set 'h' as an alias for 'history' because I like to save six keystrokes Laughing


Something to be aware is that the terminal's history is stored in memory and it is only written to and read from the file when PROMPT_COMMAND is executed. This only happens whenever the prompt is displayed. This means that you need to hit ENTER to update the history.

If you use multiple terminals (which is probably why you'd do this anyway) then you can still experience issues where their histories aren't properly in sync. I don't know why; I just live with it.

If anyone else can suggest anything better it would be good to hear.
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Magazine and coverdiscs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast