summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/env.rs16
-rw-r--r--src/shell/mod.rs10
2 files changed, 16 insertions, 10 deletions
diff --git a/src/env.rs b/src/env.rs
index 4c461ff..6ac67f5 100644
--- a/src/env.rs
+++ b/src/env.rs
@@ -20,13 +20,19 @@ pub struct V0 {
}
impl Env {
- pub fn new() -> Self {
- Self::V0(V0 {
+ pub fn new() -> anyhow::Result<Self> {
+ let mut vars: std::collections::HashMap<
+ std::ffi::OsString,
+ std::ffi::OsString,
+ > = std::env::vars_os().collect();
+ vars.insert("SHELL".into(), std::env::current_exe()?.into());
+ vars.insert("TERM".into(), "screen".into());
+ Ok(Self::V0(V0 {
idx: 0,
latest_status: std::process::ExitStatus::from_raw(0),
- pwd: std::env::current_dir().unwrap(),
- vars: std::env::vars_os().collect(),
- })
+ pwd: std::env::current_dir()?,
+ vars,
+ }))
}
pub fn idx(&self) -> usize {
diff --git a/src/shell/mod.rs b/src/shell/mod.rs
index e7160be..0547bae 100644
--- a/src/shell/mod.rs
+++ b/src/shell/mod.rs
@@ -146,7 +146,7 @@ pub async fn main() -> anyhow::Result<i32> {
});
}
- let mut shell = Shell::new(crate::info::get_offset());
+ let mut shell = Shell::new(crate::info::get_offset())?;
let mut prev_dir = shell.env.current_dir().to_path_buf();
git_w.send(prev_dir.clone()).await.unwrap();
let event_reader = event::Reader::new(event_r);
@@ -211,18 +211,18 @@ pub struct Shell {
}
impl Shell {
- pub fn new(offset: time::UtcOffset) -> Self {
- Self {
+ pub fn new(offset: time::UtcOffset) -> anyhow::Result<Self> {
+ Ok(Self {
readline: readline::Readline::new(),
history: history::History::new(),
- env: Env::new(),
+ env: Env::new()?,
git: None,
focus: Focus::Readline,
scene: Scene::Readline,
escape: false,
hide_readline: false,
offset,
- }
+ })
}
pub async fn render(