diff --git a/src/utils/editor.cpp b/src/utils/editor.cpp index aff39ef..01731ed 100644 --- a/src/utils/editor.cpp +++ b/src/utils/editor.cpp @@ -1,9 +1,22 @@ #include +#define SIGPIPE_ALWAYS_IGNORE +#include +#undef SIGPIPE_ALWAYS_IGNORE + #include namespace utils { void OpenEditor(const std::string& file) { - std::cout << "Open file " << file << " TODO" << std::endl; -} + std::string editors[] = {"nvim", "vim", "vi"}; + + cppshell::Shell shell; + + for (auto& editor : editors) { + shell.Execute(editor + " " + file); + if (shell.GetExitCodeLastCommand() == 0) { + break; + } + } } +} // namespace utils