aboutsummaryrefslogtreecommitdiffstats
path: root/ui/backend
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@atuin.sh>2024-07-25 23:31:38 +0100
committerGitHub <noreply@github.com>2024-07-25 23:31:38 +0100
commitc32bbcc7edc2cf99da52b1407c90238bc781a804 (patch)
tree4a8b307f69fb444f5c8c15a65e6f89170d9d4bbf /ui/backend
parentfeat(gui): allow interacting with the embedded terminal (#2312) (diff)
downloadatuin-c32bbcc7edc2cf99da52b1407c90238bc781a804.zip
feat(gui): directory block, re-org of some code (#2314)
Diffstat (limited to 'ui/backend')
-rw-r--r--ui/backend/Cargo.lock1
-rw-r--r--ui/backend/Cargo.toml8
-rw-r--r--ui/backend/src/pty.rs8
-rw-r--r--ui/backend/src/run/pty.rs5
4 files changed, 16 insertions, 6 deletions
diff --git a/ui/backend/Cargo.lock b/ui/backend/Cargo.lock
index 57de51ef..11659c11 100644
--- a/ui/backend/Cargo.lock
+++ b/ui/backend/Cargo.lock
@@ -6482,6 +6482,7 @@ dependencies = [
"portable-pty",
"serde",
"serde_json",
+ "shellexpand",
"sqlx",
"syntect",
"tauri",
diff --git a/ui/backend/Cargo.toml b/ui/backend/Cargo.toml
index 4d4646f8..96a9b1c6 100644
--- a/ui/backend/Cargo.toml
+++ b/ui/backend/Cargo.toml
@@ -24,17 +24,19 @@ serde_json = "1.0"
time = "0.3.36"
uuid = "1.7.0"
syntect = "5.2.0"
-tauri-plugin-http = "2.0.0-beta"
-tauri-plugin-single-instance = "2.0.0-beta"
tokio = "1.38.0"
-tauri-plugin-shell = "2.0.0-beta.7"
comrak = "0.22"
portable-pty = "0.8.1"
vt100 = "0.15.2"
bytes = "1.6.0"
nix = "0.29.0"
lazy_static = "1.5.0"
+shellexpand = "3.1.0"
+
+tauri-plugin-http = "2.0.0-beta"
+tauri-plugin-single-instance = "2.0.0-beta"
tauri-plugin-os = "2.0.0-beta.8"
+tauri-plugin-shell = "2.0.0-beta.7"
[target."cfg(target_os = \"macos\")".dependencies]
cocoa = "0.25"
diff --git a/ui/backend/src/pty.rs b/ui/backend/src/pty.rs
index 45502892..af394d95 100644
--- a/ui/backend/src/pty.rs
+++ b/ui/backend/src/pty.rs
@@ -16,7 +16,7 @@ pub struct Pty {
}
impl Pty {
- pub async fn open<'a>(rows: u16, cols: u16) -> Result<Self> {
+ pub async fn open<'a>(rows: u16, cols: u16, cwd: Option<String>) -> Result<Self> {
let sys = portable_pty::native_pty_system();
let pair = sys
@@ -28,7 +28,11 @@ impl Pty {
})
.map_err(|e| eyre!("Failed to open pty: {}", e))?;
- let cmd = CommandBuilder::new_default_prog();
+ let mut cmd = CommandBuilder::new_default_prog();
+
+ if let Some(cwd) = cwd {
+ cmd.cwd(cwd);
+ }
let child = pair.slave.spawn_command(cmd).unwrap();
drop(pair.slave);
diff --git a/ui/backend/src/run/pty.rs b/ui/backend/src/run/pty.rs
index 58bfccb7..0ca5ece0 100644
--- a/ui/backend/src/run/pty.rs
+++ b/ui/backend/src/run/pty.rs
@@ -11,9 +11,12 @@ use atuin_client::{database::Sqlite, record::sqlite_store::SqliteStore, settings
pub async fn pty_open<'a>(
app: tauri::AppHandle,
state: State<'a, AtuinState>,
+ cwd: Option<String>,
) -> Result<uuid::Uuid, String> {
let id = uuid::Uuid::new_v4();
- let pty = crate::pty::Pty::open(24, 80).await.unwrap();
+
+ let cwd = cwd.map(|c|shellexpand::tilde(c.as_str()).to_string());
+ let pty = crate::pty::Pty::open(24, 80, cwd).await.unwrap();
let reader = pty.reader.clone();