From 7e4141b2825b98ea9bde2e6a963687e7afa7efda Mon Sep 17 00:00:00 2001 From: Timofey Khoruzhii Date: Sat, 29 Oct 2022 20:33:30 +0300 Subject: [PATCH] Update color scheme; Change default tmp path; Fix runtime if target not exists --- src/clippy/clippy.cpp | 4 +++- src/clippy/target.hpp | 10 ++++++---- src/utils/editor.cpp | 6 +++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/clippy/clippy.cpp b/src/clippy/clippy.cpp index b961ccd..1b9d064 100644 --- a/src/clippy/clippy.cpp +++ b/src/clippy/clippy.cpp @@ -76,9 +76,11 @@ Clippy::TargetPtr Clippy::GetScriptTarget( auto cfg = p->GetConfig(); auto result = cfg.GetTarget(args[1]); - if (enable_aliases_) { + + if (result && enable_aliases_) { result->PushFront("shopt -s expand_aliases"); } + return result; } diff --git a/src/clippy/target.hpp b/src/clippy/target.hpp index 5ed303b..48fab11 100644 --- a/src/clippy/target.hpp +++ b/src/clippy/target.hpp @@ -69,12 +69,14 @@ class RunShellScript : public Target { } void Execute() override { - cppshell::Shell s; + auto tmp_path = utils::GetProjectDirectory() / "tmp"; + std::filesystem::create_directories(tmp_path); + + cppshell::Shell s("bash", tmp_path); for (auto& command : commands_) { - std::cout << rang::fg::green << rang::style::bold << "-> " - << rang::fg::reset << command << rang::style::reset - << std::endl; + std::cout << rang::fg::green << rang::style::bold << rang::bgB::blue << "->" << rang::fg::reset + << rang::bg::reset << " " << command << rang::style::reset << std::endl; s.Execute(command); if (int err = s.GetExitCodeLastCommand(); err != 0) { std::cout << rang::fg::red << rang::style::bold diff --git a/src/utils/editor.cpp b/src/utils/editor.cpp index eaaa85d..b228026 100644 --- a/src/utils/editor.cpp +++ b/src/utils/editor.cpp @@ -1,4 +1,5 @@ #include +#include #include @@ -6,7 +7,10 @@ namespace utils { void OpenEditor(const std::string& file) { std::string editors[] = {"nvim", "vim", "vi"}; - cppshell::Shell shell; + auto tmp_path = utils::GetProjectDirectory() / "tmp"; + std::filesystem::create_directories(tmp_path); + + cppshell::Shell shell("bash", tmp_path); for (auto& editor : editors) { shell.Execute(editor + " " + file);