File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ const (
39
39
outputPrefix = "[output]"
40
40
)
41
41
42
- var editorEnvVars = []string {"KUBE_EDITOR " , "K9S_EDITOR " , "EDITOR" }
42
+ var editorEnvVars = []string {"K9S_EDITOR " , "KUBE_EDITOR " , "EDITOR" }
43
43
44
44
type shellOpts struct {
45
45
clear , background bool
@@ -181,6 +181,20 @@ func execute(opts shellOpts, statusChan chan<- string) error {
181
181
cmds := make ([]* exec.Cmd , 0 , 1 )
182
182
cmd := exec .CommandContext (ctx , opts .binary , opts .args ... )
183
183
log .Debug ().Msgf ("RUNNING> %s" , opts )
184
+
185
+ if env := os .Getenv ("K9S_EDITOR" ); env != "" {
186
+ // There may be situations where the user sets the editor as the binary
187
+ // followed by some arguments (e.g. "code -w" to make it work with vscode)
188
+ //
189
+ // In such cases, the actual binary is only the first token
190
+ binTokens := strings .Split (env , " " )
191
+
192
+ if bin , err := exec .LookPath (binTokens [0 ]); err == nil {
193
+ binTokens [0 ] = bin
194
+ cmd .Env = append (os .Environ (), fmt .Sprintf ("KUBE_EDITOR=%s" , strings .Join (binTokens , " " )))
195
+ }
196
+ }
197
+
184
198
cmds = append (cmds , cmd )
185
199
186
200
for _ , p := range opts .pipes {
You can’t perform that action at this time.
0 commit comments