1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::path::PathBuf;
use super::NuConfig;
const DEFAULT_LOCATION: &str = "history.txt";
pub fn default_history_path() -> PathBuf {
crate::config::user_data()
.map(|mut p| {
p.push(DEFAULT_LOCATION);
p
})
.unwrap_or_else(|_| PathBuf::from(DEFAULT_LOCATION))
}
pub fn history_path(config: &NuConfig) -> Option<PathBuf> {
config
.var("history-path")
.and_then(|custom_path| custom_path.as_string().map(PathBuf::from).ok())
}
pub fn history_path_or_default(config: &NuConfig) -> PathBuf {
history_path(config).unwrap_or_else(default_history_path)
}