Skip to content

Commit 1ec9681

Browse files
committed
Add tab completion to the edit command
1 parent e0fee9e commit 1ec9681

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

lib/msf/ui/console/command_dispatcher/modules.rb

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Modules
2626
def commands
2727
{
2828
"back" => "Move back from the current context",
29-
"edit" => "Edit the current module with the preferred editor",
29+
"edit" => "Edit the current module or a file with the preferred editor",
3030
"advanced" => "Displays advanced options for one or more modules",
3131
"info" => "Displays information about one or more modules",
3232
"options" => "Displays global options or for one or more modules",
@@ -68,14 +68,14 @@ def local_editor
6868
def cmd_edit_help
6969
print_line "Usage: edit [file/to/edit.rb]"
7070
print_line
71-
print_line "Edit a local file or the currently active module with #{local_editor}"
72-
print_line "If a file path is specified it will automatically be reloaded after editing"
71+
print_line "Edit the currently active module or a local file with #{local_editor}."
72+
print_line "If a file path is specified, it will automatically be reloaded after editing."
7373
print_line "Otherwise, you can reload the active module with 'reload' or 'rerun'."
7474
print_line
7575
end
7676

7777
#
78-
# Edit the currently active module
78+
# Edit the currently active module or a local file
7979
#
8080
def cmd_edit(*args)
8181
if args.length > 0
@@ -86,22 +86,32 @@ def cmd_edit(*args)
8686

8787
if path
8888
editor = local_editor
89+
8990
if editor.nil?
90-
editor = 'vim'
91+
editor = 'ed'
9192
print_warning("LocalEditor or $VISUAL/$EDITOR should be set. Falling back on #{editor}.")
9293
end
9394

9495
print_status("Launching #{editor} #{path}")
9596
system(editor, path)
96-
97+
98+
# XXX: This will try to reload *anything* and break on modules
9799
if args.length > 0
98-
load args[0]
100+
print_status("Reloading #{path}")
101+
load path
99102
end
100103
else
101104
print_error('Nothing to edit -- try using a module first.')
102105
end
103106
end
104107

108+
#
109+
# Tab completion for the edit command
110+
#
111+
def cmd_edit_tabs(str, words)
112+
tab_complete_filenames(str, words)
113+
end
114+
105115
def cmd_advanced_help
106116
print_line 'Usage: advanced [mod1 mod2 ...]'
107117
print_line

0 commit comments

Comments
 (0)