remove logs; add exec

This commit is contained in:
Timofey Khoruzhii 2023-01-06 15:07:41 +03:00
parent 2bc0cea52b
commit 8b768c7a81
2 changed files with 9 additions and 4 deletions

View file

@ -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}

View file

@ -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()) + " " : "") +