aboutsummaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/atuin-pty-proxy/Cargo.toml (renamed from crates/atuin-hex/Cargo.toml)4
-rw-r--r--crates/atuin-pty-proxy/src/lib.rs (renamed from crates/atuin-hex/src/lib.rs)79
-rw-r--r--crates/atuin-pty-proxy/src/osc133.rs (renamed from crates/atuin-hex/src/osc133.rs)0
-rw-r--r--crates/atuin/Cargo.toml7
-rw-r--r--crates/atuin/src/command/client/search/interactive.rs12
-rw-r--r--crates/atuin/src/command/mod.rs15
6 files changed, 62 insertions, 55 deletions
diff --git a/crates/atuin-hex/Cargo.toml b/crates/atuin-pty-proxy/Cargo.toml
index 2c3fe16d..baacf776 100644
--- a/crates/atuin-hex/Cargo.toml
+++ b/crates/atuin-pty-proxy/Cargo.toml
@@ -1,7 +1,7 @@
[package]
-name = "atuin-hex"
+name = "atuin-pty-proxy"
edition = "2024"
-description = "a terminal emulator for atuin"
+description = "a PTY proxy for atuin"
version = { workspace = true }
authors = { workspace = true }
diff --git a/crates/atuin-hex/src/lib.rs b/crates/atuin-pty-proxy/src/lib.rs
index 75ec895f..16b29dff 100644
--- a/crates/atuin-hex/src/lib.rs
+++ b/crates/atuin-pty-proxy/src/lib.rs
@@ -4,7 +4,7 @@ use clap::{Args, Subcommand, ValueEnum};
#[derive(Subcommand, Debug)]
pub enum Cmd {
- /// Print shell code to initialize atuin-hex on shell startup
+ /// Print shell code to initialize atuin pty-proxy on shell startup
Init(Init),
}
@@ -42,7 +42,7 @@ pub fn run(cmd: Option<Cmd>) {
match cmd {
Some(Cmd::Init(init)) => {
if let Err(err) = init.run() {
- eprintln!("atuin hex: {err}");
+ eprintln!("atuin pty-proxy: {err}");
std::process::exit(1);
}
}
@@ -95,55 +95,57 @@ fn render_init(shell: Shell) -> &'static str {
match shell {
Shell::Bash | Shell::Zsh => {
r#"if [[ "$-" == *i* ]] && [[ -t 0 ]] && [[ -t 1 ]]; then
- _atuin_hex_tmux_current="${TMUX:-}"
- _atuin_hex_tmux_previous="${ATUIN_HEX_TMUX:-}"
+ _atuin_pty_proxy_tmux_current="${TMUX:-}"
+ _atuin_pty_proxy_tmux_previous="${ATUIN_PTY_PROXY_TMUX:-${ATUIN_HEX_TMUX:-}}"
- if [[ -z "${ATUIN_HEX_ACTIVE:-}" ]] || [[ "$_atuin_hex_tmux_current" != "$_atuin_hex_tmux_previous" ]]; then
- export ATUIN_HEX_ACTIVE=1
- export ATUIN_HEX_TMUX="$_atuin_hex_tmux_current"
- exec atuin hex
+ if [[ -z "${ATUIN_PTY_PROXY_ACTIVE:-${ATUIN_HEX_ACTIVE:-}}" ]] || [[ "$_atuin_pty_proxy_tmux_current" != "$_atuin_pty_proxy_tmux_previous" ]]; then
+ export ATUIN_PTY_PROXY_ACTIVE=1
+ export ATUIN_PTY_PROXY_TMUX="$_atuin_pty_proxy_tmux_current"
+ exec atuin pty-proxy
fi
- unset _atuin_hex_tmux_current _atuin_hex_tmux_previous
+ unset _atuin_pty_proxy_tmux_current _atuin_pty_proxy_tmux_previous
fi
"#
}
Shell::Fish => {
r#"if status is-interactive; and test -t 0; and test -t 1
- set -l _atuin_hex_tmux_current ""
+ set -l _atuin_pty_proxy_tmux_current ""
if set -q TMUX
- set _atuin_hex_tmux_current "$TMUX"
+ set _atuin_pty_proxy_tmux_current "$TMUX"
end
- set -l _atuin_hex_tmux_previous ""
- if set -q ATUIN_HEX_TMUX
- set _atuin_hex_tmux_previous "$ATUIN_HEX_TMUX"
+ set -l _atuin_pty_proxy_tmux_previous ""
+ if set -q ATUIN_PTY_PROXY_TMUX
+ set _atuin_pty_proxy_tmux_previous "$ATUIN_PTY_PROXY_TMUX"
+ else if set -q ATUIN_HEX_TMUX
+ set _atuin_pty_proxy_tmux_previous "$ATUIN_HEX_TMUX"
end
- if not set -q ATUIN_HEX_ACTIVE
- set -gx ATUIN_HEX_ACTIVE 1
- set -gx ATUIN_HEX_TMUX "$_atuin_hex_tmux_current"
- exec atuin hex
- else if test "$_atuin_hex_tmux_current" != "$_atuin_hex_tmux_previous"
- set -gx ATUIN_HEX_ACTIVE 1
- set -gx ATUIN_HEX_TMUX "$_atuin_hex_tmux_current"
- exec atuin hex
+ if not set -q ATUIN_PTY_PROXY_ACTIVE; and not set -q ATUIN_HEX_ACTIVE
+ set -gx ATUIN_PTY_PROXY_ACTIVE 1
+ set -gx ATUIN_PTY_PROXY_TMUX "$_atuin_pty_proxy_tmux_current"
+ exec atuin pty-proxy
+ else if test "$_atuin_pty_proxy_tmux_current" != "$_atuin_pty_proxy_tmux_previous"
+ set -gx ATUIN_PTY_PROXY_ACTIVE 1
+ set -gx ATUIN_PTY_PROXY_TMUX "$_atuin_pty_proxy_tmux_current"
+ exec atuin pty-proxy
end
end
"#
}
// Nushell cannot dynamically source the output of `atuin init nu`,
- // so we only output the hex preamble here. Users must also set up
+ // so we only output the pty-proxy preamble here. Users must also set up
// `atuin init nu` separately.
Shell::Nu => {
r#"if (is-terminal --stdin) and (is-terminal --stdout) {
let tmux_current = ($env.TMUX? | default "")
- let tmux_previous = ($env.ATUIN_HEX_TMUX? | default "")
+ let tmux_previous = ($env.ATUIN_PTY_PROXY_TMUX? | default ($env.ATUIN_HEX_TMUX? | default ""))
- if ($env.ATUIN_HEX_ACTIVE? | default "" | is-empty) or ($tmux_current != $tmux_previous) {
- $env.ATUIN_HEX_ACTIVE = "1"
- $env.ATUIN_HEX_TMUX = $tmux_current
- exec atuin hex
+ if (($env.ATUIN_PTY_PROXY_ACTIVE? | default ($env.ATUIN_HEX_ACTIVE? | default "")) | is-empty) or ($tmux_current != $tmux_previous) {
+ $env.ATUIN_PTY_PROXY_ACTIVE = "1"
+ $env.ATUIN_PTY_PROXY_TMUX = $tmux_current
+ exec atuin pty-proxy
}
}
"#
@@ -154,7 +156,7 @@ end
#[cfg(not(unix))]
mod app {
pub(crate) fn main() {
- eprintln!("atuin hex currently supports unix platforms");
+ eprintln!("atuin pty-proxy currently supports unix platforms");
std::process::exit(1);
}
}
@@ -177,14 +179,14 @@ mod app {
pub(crate) fn main() {
if let Err(e) = run() {
let _ = terminal::disable_raw_mode();
- eprintln!("atuin hex: {e:#}");
+ eprintln!("atuin pty-proxy: {e:#}");
std::process::exit(1);
}
}
fn socket_path() -> std::path::PathBuf {
let dir = std::env::temp_dir();
- dir.join(format!("atuin-hex-{}.sock", std::process::id()))
+ dir.join(format!("atuin-pty-proxy-{}.sock", std::process::id()))
}
/// Wire format written to the Unix socket:
@@ -249,6 +251,7 @@ mod app {
let mut cmd = CommandBuilder::new_default_prog();
cmd.cwd(std::env::current_dir()?);
+ cmd.env("ATUIN_PTY_PROXY_SOCKET", sock_path.as_os_str());
cmd.env("ATUIN_HEX_SOCKET", sock_path.as_os_str());
let mut child = pair
@@ -304,7 +307,7 @@ mod app {
let listener = match UnixListener::bind(&sock_path_clone) {
Ok(l) => l,
Err(e) => {
- eprintln!("atuin hex: failed to bind socket: {e}");
+ eprintln!("atuin pty-proxy: failed to bind socket: {e}");
return;
}
};
@@ -445,8 +448,8 @@ mod tests {
#[test]
fn posix_init_uses_exec_and_tmux_guard() {
let script = render_init(Shell::Bash);
- assert!(script.contains("exec atuin hex"));
- assert!(script.contains("ATUIN_HEX_TMUX"));
+ assert!(script.contains("exec atuin pty-proxy"));
+ assert!(script.contains("ATUIN_PTY_PROXY_TMUX"));
assert!(!script.contains("eval \"$(atuin init bash)\""));
}
@@ -459,17 +462,17 @@ mod tests {
#[test]
fn fish_init_uses_source() {
let script = render_init(Shell::Fish);
- assert!(script.contains("exec atuin hex"));
+ assert!(script.contains("exec atuin pty-proxy"));
assert!(!script.contains("atuin init fish | source"));
}
#[test]
fn nu_init_uses_exec_and_tty_guard() {
let script = render_init(Shell::Nu);
- assert!(script.contains("exec atuin hex"));
- assert!(script.contains("ATUIN_HEX_TMUX"));
+ assert!(script.contains("exec atuin pty-proxy"));
+ assert!(script.contains("ATUIN_PTY_PROXY_TMUX"));
assert!(script.contains("is-terminal --stdin"));
assert!(script.contains("is-terminal --stdout"));
- assert!(script.contains("ATUIN_HEX_ACTIVE"));
+ assert!(script.contains("ATUIN_PTY_PROXY_ACTIVE"));
}
}
diff --git a/crates/atuin-hex/src/osc133.rs b/crates/atuin-pty-proxy/src/osc133.rs
index d6ee1220..d6ee1220 100644
--- a/crates/atuin-hex/src/osc133.rs
+++ b/crates/atuin-pty-proxy/src/osc133.rs
diff --git a/crates/atuin/Cargo.toml b/crates/atuin/Cargo.toml
index 768827c2..e9bad2ec 100644
--- a/crates/atuin/Cargo.toml
+++ b/crates/atuin/Cargo.toml
@@ -33,12 +33,13 @@ buildflags = ["--release"]
atuin = { path = "/usr/bin/atuin" }
[features]
-default = ["client", "sync", "clipboard", "check-update", "daemon", "ai", "hex"]
+default = ["client", "sync", "clipboard", "check-update", "daemon", "ai", "pty-proxy"]
client = ["atuin-client"]
sync = ["atuin-client/sync"]
daemon = ["atuin-client/daemon", "atuin-daemon"]
ai = ["atuin-ai"]
-hex = ["atuin-hex"]
+pty-proxy = ["dep:atuin-pty-proxy"]
+hex = ["pty-proxy"]
clipboard = ["arboard"]
check-update = ["atuin-client/check-update"]
@@ -49,7 +50,7 @@ atuin-common = { workspace = true }
atuin-dotfiles = { workspace = true }
atuin-history = { workspace = true }
atuin-daemon = { path = "../atuin-daemon", version = "18.16.0", optional = true, default-features = false }
-atuin-hex = { path = "../atuin-hex", version = "18.16.0", optional = true, default-features = false }
+atuin-pty-proxy = { path = "../atuin-pty-proxy", version = "18.16.0", optional = true, default-features = false }
atuin-scripts = { workspace = true }
atuin-kv = { workspace = true }
diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs
index 4464bf22..553f954a 100644
--- a/crates/atuin/src/command/client/search/interactive.rs
+++ b/crates/atuin/src/command/client/search/interactive.rs
@@ -1377,7 +1377,7 @@ impl Drop for TerminalWriter {
}
}
-/// Screen state captured from atuin-hex's screen server.
+/// Screen state captured from atuin pty-proxy's screen server.
#[cfg(unix)]
struct SavedScreen {
#[allow(dead_code)]
@@ -1390,7 +1390,7 @@ struct SavedScreen {
rows_data: Vec<Vec<u8>>,
}
-/// Connect to atuin-hex's Unix socket and fetch the current screen state.
+/// Connect to atuin pty-proxy's Unix socket and fetch the current screen state.
///
/// The wire format is:
/// ```text
@@ -1447,7 +1447,7 @@ fn fetch_screen_state(socket_path: &str) -> Option<SavedScreen> {
/// Restore the screen area that was covered by the popup.
///
-/// Writes the pre-formatted per-row ANSI bytes received from atuin-hex
+/// Writes the pre-formatted per-row ANSI bytes received from atuin pty-proxy
/// directly to stdout, which correctly handles wide characters, colors, and
/// all text attributes without needing a client-side vt100 parser.
#[cfg(unix)]
@@ -1629,11 +1629,13 @@ pub async fn history(
inline_height
};
- // Popup mode: if running under atuin-hex and inline mode is requested,
+ // Popup mode: if running under atuin pty-proxy and inline mode is requested,
// fetch the screen state and render as a centered overlay.
#[cfg(unix)]
let (saved_screen, popup_rect, popup_scroll_offset) = {
- let socket_path = std::env::var("ATUIN_HEX_SOCKET").ok();
+ let socket_path = std::env::var("ATUIN_PTY_PROXY_SOCKET")
+ .or_else(|_| std::env::var("ATUIN_HEX_SOCKET"))
+ .ok();
if let Some(ref path) = socket_path
&& inline_height > 0
{
diff --git a/crates/atuin/src/command/mod.rs b/crates/atuin/src/command/mod.rs
index 7896628d..7deb72d6 100644
--- a/crates/atuin/src/command/mod.rs
+++ b/crates/atuin/src/command/mod.rs
@@ -21,11 +21,12 @@ pub enum AtuinCmd {
#[command(flatten)]
Client(client::Cmd),
- /// Terminal emulator for atuin
- #[cfg(feature = "hex")]
- Hex {
+ /// PTY proxy for atuin
+ #[cfg(feature = "pty-proxy")]
+ #[command(alias = "hex")]
+ PtyProxy {
#[command(subcommand)]
- cmd: Option<atuin_hex::Cmd>,
+ cmd: Option<atuin_pty_proxy::Cmd>,
},
/// Generate a UUID
@@ -54,9 +55,9 @@ impl AtuinCmd {
#[cfg(feature = "client")]
Self::Client(client) => client.run(),
- #[cfg(feature = "hex")]
- Self::Hex { cmd } => {
- atuin_hex::run(cmd);
+ #[cfg(feature = "pty-proxy")]
+ Self::PtyProxy { cmd } => {
+ atuin_pty_proxy::run(cmd);
Ok(())
}