Created
June 22, 2009 22:54
-
-
Save sidonath/134242 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Append to ~/.profile (or ~/.bashrc) | |
| # append to history, not overwrite | |
| shopt -s histappend | |
| # append command to history file before it's executed | |
| export PROMPT_COMMAND="history -a" | |
| # ignore duplicate consecutive commands | |
| export HISTCONTROL=ignoreboth | |
| # thanks to: | |
| # http://www.linuxforums.org/forum/linux-programming-scripting/109516-retaining-bash-history-all-sessions.html | |
| # and | |
| # http://www.ducea.com/2006/05/15/linux-tips-take-control-of-your-bash_history/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| def exec_undo(line) | |
| line.gsub! 'script/generate', 'script/destroy' | |
| puts "Execute command \"#{line}\"? (yN)" | |
| if (gets.chomp.downcase == 'y') | |
| puts line | |
| system line | |
| end | |
| end | |
| history = '~/.bash_history' | |
| lines = File.readlines(File.expand_path(history)).reverse | |
| lines.each do |l| | |
| if l =~ /script\/generate/ | |
| exec_undo l.chomp | |
| break | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment