diff --git a/src/ui/app_state/update/mod.rs b/src/ui/app_state/update/mod.rs index a7c3a7d..81f40ce 100644 --- a/src/ui/app_state/update/mod.rs +++ b/src/ui/app_state/update/mod.rs @@ -47,16 +47,26 @@ impl Default for Nova { false, ); let mut nova = Self { - tabs: vec![Tab::new( - 0, - cols, - rows, - default_shell, - std::env::current_dir() + tabs: vec![Tab::new(0, cols, rows, default_shell, { + let cur = std::env::current_dir().ok(); + let exe_dir = std::env::current_exe() .ok() - .and_then(|p| p.into_os_string().into_string().ok()) - .unwrap_or_default(), - )], + .and_then(|e| e.parent().map(|p| p.to_path_buf())); + let in_install_dir = cur + .as_ref() + .zip(exe_dir.as_ref()) + .map(|(c, e)| c == e) + .unwrap_or(false); + if in_install_dir { + dirs::home_dir() + .and_then(|p| p.into_os_string().into_string().ok()) + .unwrap_or_default() + } else { + cur + .and_then(|p| p.into_os_string().into_string().ok()) + .unwrap_or_default() + } + })], active_index: 0, next_tab_id: 1, window_id: None,