How to change editor for sensuctl with Windows

Change editor for sensuctl when using Windows operating systems

Set environment variable

sensuctl will look for an environment variable EDITOR we can set it to a different text editor, in this example I am using VSCODE

Using Powershell you can set the EDITOR variable, in this example the scope it is set to Machine

[System.Environment]::SetEnvironmentVariable('EDITOR','code --wait --new-window',[System.EnvironmentVariableTarget]::Machine)

VSCode should be installed and available in your system path in order to use code in the above example

Windows and Linux installations should add the VS Code binaries location to your system path. If this isn’t the case, you can manually add the location to the Path environment variable ( $PATH on Linux). For example, on Windows, VS Code is installed under AppData\Local\Programs\Microsoft VS Code\bin .

I have not tested with notepad.exe it is the default text editor available on Windows. There are several alternatives, vim is available as a chocolatey package or notepad++

Once this variable has been set you may need to restart your shell in order for the variable to be recognized.

sensuctl edit check <checkname>

will now launch vscode and allow you to make changes using that as your text editor.

1 Like

Nice! :ok_hand: