aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'atuin-common/src')
-rw-r--r--atuin-common/src/utils.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/atuin-common/src/utils.rs b/atuin-common/src/utils.rs
index d85b3b96..1d330390 100644
--- a/atuin-common/src/utils.rs
+++ b/atuin-common/src/utils.rs
@@ -1,3 +1,4 @@
+use std::env;
use std::path::PathBuf;
use chrono::NaiveDate;
@@ -36,6 +37,17 @@ pub fn data_dir() -> PathBuf {
data_dir.join("atuin")
}
+pub fn get_current_dir() -> String {
+ // Prefer PWD environment variable over cwd if available to better support symbolic links
+ match env::var("PWD") {
+ Ok(v) => v,
+ Err(_) => match env::current_dir() {
+ Ok(dir) => dir.display().to_string(),
+ Err(_) => String::from(""),
+ },
+ }
+}
+
pub fn get_days_from_month(year: i32, month: u32) -> i64 {
NaiveDate::from_ymd(
match month {