Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion reattachd/src/tmux/send.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::process::Command;
use std::{process::Command, thread, time::Duration};

use crate::tmux::TmuxError;

const SUBMIT_DELAY: Duration = Duration::from_millis(100);

pub fn send_keys(target: &str, text: &str) -> Result<(), TmuxError> {
let output = Command::new("tmux")
.args(["send-keys", "-t", target, "-l", text])
Expand All @@ -13,6 +15,10 @@ pub fn send_keys(target: &str, text: &str) -> Result<(), TmuxError> {
return Err(TmuxError::Command(stderr.to_string()));
}

// Keep the submit key out of terminal applications' rapid-input/paste
// detection so that it is consistently handled as Enter.
thread::sleep(SUBMIT_DELAY);

let output = Command::new("tmux")
.args(["send-keys", "-t", target, "Enter"])
.output()
Expand Down