Permalink
Browse files

adding flags to specifiy alternate .bash_history file, or database file

  • Loading branch information...
vbatts committed May 18, 2012
1 parent 4648c38 commit 52ef8575a9728b483e667a5232ffd31543889630
Showing with 10 additions and 5 deletions.
  1. +10 −5 bash_history.rb
View
@@ -59,28 +59,33 @@ def render(file)
if $0 == __FILE__
require 'optparse'
options = {}
+ bh_options = {}
OptionParser.new do |opts|
opts.on('--inspect','inspect the data') do |o|
options[:inspect] = o
end
+ opts.on('--history FILE','use bash_history FILE instead of the default (~/.bash_history)') do |o|
+ bh_options[:file] = o
+ end
+ opts.on('--db FILE','use database FILE instead of the default (~/.bash_history.db)') do |o|
+ bh_options[:archive_file] = o
+ end
opts.on('-l','--list','list history') do |o|
options[:list] = o
end
opts.on('--fix','fix times') do |o|
options[:fix] = o
end
opts.on('--format FORMAT','specify a different strftime format. (default is "%F %T")') do |o|
- options[:format] = o
+ bh_options[:time_format] = o
end
opts.on('-f','--find PAT','find a command with pattern PAT') do |o|
options[:find] = o
end
end.parse!(ARGV)
- bh = BashHistory.new
- if options[:format]
- bh.time_format = options[:format]
- end
+ bh = BashHistory.new(bh_options)
+
if options[:inspect]
p bh
p "storing #{bh.keys.count} commands"

0 comments on commit 52ef857

Please sign in to comment.