summaryrefslogtreecommitdiffstats
path: root/src/utils/command.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-07-30 07:45:29 +0800
committerGitHub <noreply@github.com>2024-07-30 07:45:29 +0800
commitcc74be5d2163fbb1e9d57f85d5546857c6602446 (patch)
tree9897a88950ad6fc65dbd63f0cb9bbc9e7290d950 /src/utils/command.rs
parent4c18e91165269970747bd2734b9b5db013ade2c2 (diff)
downloadaichat-cc74be5d2163fbb1e9d57f85d5546857c6602446.tar.gz
refactor: several improvements (#765)
Diffstat (limited to 'src/utils/command.rs')
-rw-r--r--src/utils/command.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/utils/command.rs b/src/utils/command.rs
index 3876f3d..caf70c7 100644
--- a/src/utils/command.rs
+++ b/src/utils/command.rs
@@ -4,13 +4,18 @@ use std::{collections::HashMap, env, ffi::OsStr, path::Path, process::Command};
use anyhow::{anyhow, bail, Context, Result};
+lazy_static::lazy_static! {
+ pub static ref OS: String = detect_os();
+ pub static ref SHELL: Shell = detect_shell();
+}
+
pub fn detect_os() -> String {
let os = env::consts::OS;
if os == "linux" {
if let Ok(contents) = std::fs::read_to_string("/etc/os-release") {
for line in contents.lines() {
if let Some(id) = line.strip_prefix("ID=") {
- return format!("{os}/{id}");
+ return format!("{os} ({id})");
}
}
}