@@ -27,7 +27,7 @@ class Modules
27
27
def commands
28
28
{
29
29
"back" => "Move back from the current context" ,
30
- "edit" => "Edit the current module with $VISUAL or $EDITOR " ,
30
+ "edit" => "Edit the current module with the preferred editor " ,
31
31
"advanced" => "Displays advanced options for one or more modules" ,
32
32
"info" => "Displays information about one or more modules" ,
33
33
"options" => "Displays global options or for one or more modules" ,
@@ -61,39 +61,40 @@ def name
61
61
"Module"
62
62
end
63
63
64
-
65
64
def local_editor
66
- Rex ::Compat . getenv ( 'VISUAL' ) || Rex ::Compat . getenv ( 'EDITOR' ) || '/usr/bin/vim'
65
+ framework . datastore [ 'LocalEditor' ] || Rex ::Compat . getenv ( 'VISUAL' ) || Rex ::Compat . getenv ( 'EDITOR' )
67
66
end
68
67
69
68
def cmd_edit_help
70
69
msg = "Edit the currently active module"
71
- msg = "#{ msg } #{ local_editor ? "with #{ local_editor } " : "($VISUAL or $EDITOR must be set first)" } ."
70
+ msg = "#{ msg } #{ local_editor ? "with #{ local_editor } " : "(LocalEditor or $VISUAL/$ EDITOR should be set first)" } ."
72
71
print_line "Usage: edit"
73
72
print_line
74
73
print_line msg
75
- print_line "When done editing, you must reload the module with 'reload' or 'rexploit '."
74
+ print_line "When done editing, you must reload the module with 'reload' or 'rerun '."
76
75
print_line
77
76
end
78
77
79
78
#
80
79
# Edit the currently active module
81
80
#
82
81
def cmd_edit
83
- unless local_editor
84
- print_error "$VISUAL or $EDITOR must be set first. Try 'export EDITOR=/usr/bin/vim'"
85
- return
86
- end
87
82
if active_module
88
- path = active_module . file_path
89
- print_status "Launching #{ local_editor } #{ path } "
90
- system ( local_editor , path )
83
+ editor = local_editor
84
+ path = active_module . file_path
85
+
86
+ if editor . nil?
87
+ editor = 'vim'
88
+ print_warning ( "LocalEditor or $VISUAL/$EDITOR should be set. Falling back on #{ editor } ." )
89
+ end
90
+
91
+ print_status ( "Launching #{ editor } #{ path } " )
92
+ system ( editor , path )
91
93
else
92
- print_error " Nothing to edit -- try using a module first."
94
+ print_error ( ' Nothing to edit -- try using a module first.' )
93
95
end
94
96
end
95
97
96
-
97
98
def cmd_advanced_help
98
99
print_line 'Usage: advanced [mod1 mod2 ...]'
99
100
print_line
0 commit comments