From 8b768c7a81b19fe40a152c24469ef99a380679ac Mon Sep 17 00:00:00 2001 From: Timofey Khoruzhii Date: Fri, 6 Jan 2023 15:07:41 +0300 Subject: [PATCH] remove logs; add exec --- include/tmuxub/tmuxub.hpp | 2 ++ src/tmuxub.cpp | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/tmuxub/tmuxub.hpp b/include/tmuxub/tmuxub.hpp index b88bdc2..b9afe5f 100644 --- a/include/tmuxub/tmuxub.hpp +++ b/include/tmuxub/tmuxub.hpp @@ -21,6 +21,8 @@ class Tmux { Tmux& LockSession(); Tmux& KillSession(); + void Exec(); + Tmux& CreateWindow(const std::string& window); // | vertical, - horizontal, > move to next window, {cmd1 cmd2; cmd3} diff --git a/src/tmuxub.cpp b/src/tmuxub.cpp index 62849a5..f2a11f2 100644 --- a/src/tmuxub.cpp +++ b/src/tmuxub.cpp @@ -62,28 +62,24 @@ Tmux& Tmux::SplitWindow(const std::string& pattern) { auto split_horizontal = [this, &number_pane]() { std::string command = GetCommandTmuxSocket() + "split-window -t " + "0." + std::to_string(number_pane); - std::cout << "split horizontal" << std::endl; system(command.data()); }; auto split_vertical = [this, &number_pane]() { std::string command = GetCommandTmuxSocket() + "split-window -h -t " + "0." + std::to_string(number_pane); - std::cout << "split vertical" << std::endl; system(command.data()); }; auto send_cmd = [this, &number_pane](const std::string& cmd) { std::string command = GetCommandTmuxSocket() + "send-keys -t " + "0." + std::to_string(number_pane) + " " + cmd; - std::cout << "CMD: " << command << std::endl; system(command.data()); }; auto select_current_pane = [this, &number_pane](){ std::string command = GetCommandTmuxSocket() + "select-pane -t " + "0." + std::to_string(number_pane); - std::cout << "select pane" << std::endl; system(command.data()); }; @@ -132,6 +128,13 @@ Tmux& Tmux::SplitWindow(const std::string& pattern) { return *this; } +void Tmux::Exec() { + std::string command = this->GetCommandTmuxSocket() + "attach -t " + session_.value(); + if (system(command.data()) != 0) { + throw std::logic_error("exec"); + } +} + Tmux& Tmux::KillSession() { std::string command = std::string("tmux ") + (socket_ ? "-S " + std::string(socket_.value()) + " " : "") +