@@ -88,7 +88,8 @@ class Core
88
88
@@history_opts = Rex ::Parser ::Arguments . new (
89
89
"-h" => [ false , "Help banner." ] ,
90
90
"-a" => [ false , "Show all commands in history." ] ,
91
- "-n" => [ true , "Show the last n commands." ] )
91
+ "-n" => [ true , "Show the last n commands." ] ,
92
+ "-u" => [ false , "Show only unique commands." ] )
92
93
93
94
@@irb_opts = Rex ::Parser ::Arguments . new (
94
95
"-h" => [ false , "Help banner." ] ,
@@ -480,6 +481,7 @@ def cmd_exit(*args)
480
481
481
482
def cmd_history ( *args )
482
483
length = Readline ::HISTORY . length
484
+ uniq = false
483
485
484
486
if length < @history_limit
485
487
limit = length
@@ -498,6 +500,8 @@ def cmd_history(*args)
498
500
else
499
501
limit = val . to_i
500
502
end
503
+ when "-u"
504
+ uniq = true
501
505
when "-h"
502
506
cmd_history_help
503
507
return false
@@ -508,6 +512,9 @@ def cmd_history(*args)
508
512
pad_len = length . to_s . length
509
513
510
514
( start ..length -1 ) . each do |pos |
515
+ if uniq && Readline ::HISTORY [ pos ] == Readline ::HISTORY [ pos -1 ]
516
+ next unless pos == 0
517
+ end
511
518
cmd_num = ( pos + 1 ) . to_s
512
519
print_line "#{ cmd_num . ljust ( pad_len ) } #{ Readline ::HISTORY [ pos ] } "
513
520
end
@@ -518,7 +525,6 @@ def cmd_history_help
518
525
print_line
519
526
print_line "Shows the command history."
520
527
print_line "If -n is not set, only the last #{ @history_limit } commands will be shown."
521
- print_line
522
528
print @@history_opts . usage
523
529
end
524
530
0 commit comments