Update color scheme; Change default tmp path; Fix runtime if target not exists

This commit is contained in:
Timofey Khoruzhii 2022-10-29 20:33:30 +03:00
parent 9f22ea05a6
commit 7e4141b282
3 changed files with 14 additions and 6 deletions

View file

@ -76,9 +76,11 @@ Clippy::TargetPtr Clippy::GetScriptTarget(
auto cfg = p->GetConfig(); auto cfg = p->GetConfig();
auto result = cfg.GetTarget(args[1]); auto result = cfg.GetTarget(args[1]);
if (enable_aliases_) {
if (result && enable_aliases_) {
result->PushFront("shopt -s expand_aliases"); result->PushFront("shopt -s expand_aliases");
} }
return result; return result;
} }

View file

@ -69,12 +69,14 @@ class RunShellScript : public Target {
} }
void Execute() override { 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_) { for (auto& command : commands_) {
std::cout << rang::fg::green << rang::style::bold << "-> " std::cout << rang::fg::green << rang::style::bold << rang::bgB::blue << "->" << rang::fg::reset
<< rang::fg::reset << command << rang::style::reset << rang::bg::reset << " " << command << rang::style::reset << std::endl;
<< std::endl;
s.Execute(command); s.Execute(command);
if (int err = s.GetExitCodeLastCommand(); err != 0) { if (int err = s.GetExitCodeLastCommand(); err != 0) {
std::cout << rang::fg::red << rang::style::bold std::cout << rang::fg::red << rang::style::bold

View file

@ -1,4 +1,5 @@
#include <utils/editor.hpp> #include <utils/editor.hpp>
#include <utils/config_path.hpp>
#include <cppshell/shell.hpp> #include <cppshell/shell.hpp>
@ -6,7 +7,10 @@ namespace utils {
void OpenEditor(const std::string& file) { void OpenEditor(const std::string& file) {
std::string editors[] = {"nvim", "vim", "vi"}; 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) { for (auto& editor : editors) {
shell.Execute(editor + " " + file); shell.Execute(editor + " " + file);