@@ -54,10 +54,11 @@ class Console::CommandDispatcher::Stdapi::Fs
54
54
"-R" => [ false , "Recursively list subdirectories encountered" ] )
55
55
56
56
#
57
- # Options for the ls command
57
+ # Options for the lls command
58
58
#
59
59
@@lls_opts = Rex ::Parser ::Arguments . new (
60
60
"-h" => [ false , "Help banner." ] ,
61
+ "-S" => [ true , "Search string." ] ,
61
62
"-t" => [ false , "Sort by time" ] ,
62
63
"-s" => [ false , "Sort by size" ] ,
63
64
"-r" => [ false , "Reverse sort order" ] )
@@ -689,7 +690,7 @@ def cmd_lls_help
689
690
#
690
691
# Get list local path information for lls command
691
692
#
692
- def list_local_path ( path , sort , order )
693
+ def list_local_path ( path , sort , order , search_term = nil )
693
694
if !::File . directory? ( path )
694
695
perms = pretty_perms ( path )
695
696
stat = ::File . stat ( path )
@@ -721,8 +722,10 @@ def list_local_path(path, sort, order)
721
722
file
722
723
]
723
724
if file != '.' && file != '..'
724
- tbl << row
725
- items += 1
725
+ if row . join ( ' ' ) =~ /#{ search_term } /
726
+ tbl << row
727
+ items += 1
728
+ end
726
729
end
727
730
end
728
731
if items > 0
@@ -753,9 +756,11 @@ def pretty_perms(path)
753
756
# List local files
754
757
#
755
758
def cmd_lls ( *args )
759
+ # Set Defaults
756
760
path = ::Dir . pwd
757
761
sort = 'Name'
758
762
order = :forward
763
+ search_term = nil
759
764
760
765
# Parse the args
761
766
@@lls_opts . parse ( args ) { |opt , idx , val |
@@ -768,6 +773,15 @@ def cmd_lls(*args)
768
773
# Output options
769
774
when '-r'
770
775
order = :reverse
776
+ # Search
777
+ when '-S'
778
+ search_term = val
779
+ if search_term . nil?
780
+ print_error ( "Enter a search term" )
781
+ return true
782
+ else
783
+ search_term = /#{ search_term } /nmi
784
+ end
771
785
# Help and path
772
786
when "-h"
773
787
cmd_lls_help
@@ -777,7 +791,7 @@ def cmd_lls(*args)
777
791
end
778
792
}
779
793
780
- list_local_path ( path , sort , order )
794
+ list_local_path ( path , sort , order , search_term )
781
795
end
782
796
783
797
#
0 commit comments