mirror of
https://github.com/vbatts/persistent-shell-history.git
synced 2024-10-31 21:36:38 +00:00
adding flags to specifiy alternate .bash_history file, or database file
This commit is contained in:
parent
4648c38255
commit
52ef8575a9
1 changed files with 10 additions and 5 deletions
|
@ -59,10 +59,17 @@ end
|
||||||
if $0 == __FILE__
|
if $0 == __FILE__
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
options = {}
|
options = {}
|
||||||
|
bh_options = {}
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.on('--inspect','inspect the data') do |o|
|
opts.on('--inspect','inspect the data') do |o|
|
||||||
options[:inspect] = o
|
options[:inspect] = o
|
||||||
end
|
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|
|
opts.on('-l','--list','list history') do |o|
|
||||||
options[:list] = o
|
options[:list] = o
|
||||||
end
|
end
|
||||||
|
@ -70,17 +77,15 @@ if $0 == __FILE__
|
||||||
options[:fix] = o
|
options[:fix] = o
|
||||||
end
|
end
|
||||||
opts.on('--format FORMAT','specify a different strftime format. (default is "%F %T")') do |o|
|
opts.on('--format FORMAT','specify a different strftime format. (default is "%F %T")') do |o|
|
||||||
options[:format] = o
|
bh_options[:time_format] = o
|
||||||
end
|
end
|
||||||
opts.on('-f','--find PAT','find a command with pattern PAT') do |o|
|
opts.on('-f','--find PAT','find a command with pattern PAT') do |o|
|
||||||
options[:find] = o
|
options[:find] = o
|
||||||
end
|
end
|
||||||
end.parse!(ARGV)
|
end.parse!(ARGV)
|
||||||
|
|
||||||
bh = BashHistory.new
|
bh = BashHistory.new(bh_options)
|
||||||
if options[:format]
|
|
||||||
bh.time_format = options[:format]
|
|
||||||
end
|
|
||||||
if options[:inspect]
|
if options[:inspect]
|
||||||
p bh
|
p bh
|
||||||
p "storing #{bh.keys.count} commands"
|
p "storing #{bh.keys.count} commands"
|
||||||
|
|
Loading…
Reference in a new issue