remove logs; add exec
This commit is contained in:
parent
2bc0cea52b
commit
8b768c7a81
|
@ -21,6 +21,8 @@ class Tmux {
|
||||||
Tmux& LockSession();
|
Tmux& LockSession();
|
||||||
Tmux& KillSession();
|
Tmux& KillSession();
|
||||||
|
|
||||||
|
void Exec();
|
||||||
|
|
||||||
Tmux& CreateWindow(const std::string& window);
|
Tmux& CreateWindow(const std::string& window);
|
||||||
|
|
||||||
// | vertical, - horizontal, > move to next window, {cmd1 cmd2; cmd3}
|
// | vertical, - horizontal, > move to next window, {cmd1 cmd2; cmd3}
|
||||||
|
|
|
@ -62,28 +62,24 @@ Tmux& Tmux::SplitWindow(const std::string& pattern) {
|
||||||
auto split_horizontal = [this, &number_pane]() {
|
auto split_horizontal = [this, &number_pane]() {
|
||||||
std::string command =
|
std::string command =
|
||||||
GetCommandTmuxSocket() + "split-window -t " + "0." + std::to_string(number_pane);
|
GetCommandTmuxSocket() + "split-window -t " + "0." + std::to_string(number_pane);
|
||||||
std::cout << "split horizontal" << std::endl;
|
|
||||||
|
|
||||||
system(command.data());
|
system(command.data());
|
||||||
};
|
};
|
||||||
auto split_vertical = [this, &number_pane]() {
|
auto split_vertical = [this, &number_pane]() {
|
||||||
std::string command =
|
std::string command =
|
||||||
GetCommandTmuxSocket() + "split-window -h -t " + "0." + std::to_string(number_pane);
|
GetCommandTmuxSocket() + "split-window -h -t " + "0." + std::to_string(number_pane);
|
||||||
std::cout << "split vertical" << std::endl;
|
|
||||||
|
|
||||||
system(command.data());
|
system(command.data());
|
||||||
};
|
};
|
||||||
auto send_cmd = [this, &number_pane](const std::string& cmd) {
|
auto send_cmd = [this, &number_pane](const std::string& cmd) {
|
||||||
std::string command =
|
std::string command =
|
||||||
GetCommandTmuxSocket() + "send-keys -t " + "0." + std::to_string(number_pane) + " " + cmd;
|
GetCommandTmuxSocket() + "send-keys -t " + "0." + std::to_string(number_pane) + " " + cmd;
|
||||||
std::cout << "CMD: " << command << std::endl;
|
|
||||||
|
|
||||||
system(command.data());
|
system(command.data());
|
||||||
};
|
};
|
||||||
auto select_current_pane = [this, &number_pane](){
|
auto select_current_pane = [this, &number_pane](){
|
||||||
std::string command =
|
std::string command =
|
||||||
GetCommandTmuxSocket() + "select-pane -t " + "0." + std::to_string(number_pane);
|
GetCommandTmuxSocket() + "select-pane -t " + "0." + std::to_string(number_pane);
|
||||||
std::cout << "select pane" << std::endl;
|
|
||||||
|
|
||||||
system(command.data());
|
system(command.data());
|
||||||
};
|
};
|
||||||
|
@ -132,6 +128,13 @@ Tmux& Tmux::SplitWindow(const std::string& pattern) {
|
||||||
return *this;
|
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() {
|
Tmux& Tmux::KillSession() {
|
||||||
std::string command = std::string("tmux ") +
|
std::string command = std::string("tmux ") +
|
||||||
(socket_ ? "-S " + std::string(socket_.value()) + " " : "") +
|
(socket_ ? "-S " + std::string(socket_.value()) + " " : "") +
|
||||||
|
|
Loading…
Reference in a new issue