1
0
Fork 0
mirror of https://github.com/vbatts/persistent-shell-history.git synced 2024-11-21 15:15:40 +00:00

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

This commit is contained in:
Vincent Batts 2012-05-18 12:28:58 -04:00
parent 4648c38255
commit 52ef8575a9

View file

@ -59,10 +59,17 @@ end
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
@ -70,17 +77,15 @@ if $0 == __FILE__
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"