mirror of
https://github.com/vbatts/persistent-shell-history.git
synced 2024-10-31 21:36:38 +00:00
adding a flag to allow time formatting
This commit is contained in:
parent
f2043f30a9
commit
4648c38255
1 changed files with 8 additions and 0 deletions
|
@ -15,6 +15,8 @@ class BashHistory
|
||||||
@options = OPTIONS.merge(opts)
|
@options = OPTIONS.merge(opts)
|
||||||
_parse
|
_parse
|
||||||
end
|
end
|
||||||
|
def time_format; @options[:time_format]; end
|
||||||
|
def time_format=(tf); @options[:time_format] = tf; end
|
||||||
def db
|
def db
|
||||||
@db ||= GDBM.new(@options[:archive_file])
|
@db ||= GDBM.new(@options[:archive_file])
|
||||||
end
|
end
|
||||||
|
@ -67,12 +69,18 @@ if $0 == __FILE__
|
||||||
opts.on('--fix','fix times') do |o|
|
opts.on('--fix','fix times') do |o|
|
||||||
options[:fix] = o
|
options[:fix] = o
|
||||||
end
|
end
|
||||||
|
opts.on('--format FORMAT','specify a different strftime format. (default is "%F %T")') do |o|
|
||||||
|
options[:format] = o
|
||||||
|
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
|
||||||
|
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