diff --git a/Cargo.lock b/Cargo.lock index 8852a7e..d73006b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -308,6 +308,16 @@ dependencies = [ "serde", ] +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "getrandom" version = "0.2.6" @@ -1155,6 +1165,7 @@ dependencies = [ "criterion", "crossterm", "dirs", + "gethostname", "humansize", "indexmap", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 41916f4..542d1ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ crossterm = "0.23.2" dirs = "4.0.0" ansi-to-tui-forked = "0.5.2-fix.offset" regex = "1.5.6" +gethostname = "0.2.3" [dependencies.lazy_static] version = "1.4.0" diff --git a/src/app.rs b/src/app.rs index 9299455..790fec7 100644 --- a/src/app.rs +++ b/src/app.rs @@ -20,6 +20,7 @@ pub use crate::pipe::Pipe; use crate::ui::Layout; use anyhow::{bail, Result}; use chrono::{DateTime, Local}; +use gethostname::gethostname; use indexmap::set::IndexSet; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -177,6 +178,7 @@ pub struct App { pub logs_hidden: bool, pub history: History, pub last_modes: Vec, + pub hostname: String, } impl App { @@ -288,6 +290,8 @@ impl App { prompt: config.general.prompt.format.clone().unwrap_or_default(), }; + let hostname = gethostname().to_string_lossy().to_string(); + let mut app = Self { version: VERSION.to_string(), config, @@ -307,6 +311,7 @@ impl App { logs_hidden: Default::default(), history: Default::default(), last_modes: Default::default(), + hostname, }; let has_errs = !load_errs.is_empty(); @@ -753,6 +758,7 @@ impl App { if save_history { self.history = self.history.push(format!("{}/", self.pwd)); } + print!("\x1b]7;file://{}{};\x1b\\", &self.hostname, &self.pwd); self.explore_pwd() } Err(e) => self.log_error(e.to_string()),