Added loginshell config file #4620 (#5714)

* Added loginshell config file #4620

* added sample login.nu

* added environment variable loginshell-path
This commit is contained in:
sec65
2022-06-06 13:52:37 +02:00
committed by GitHub
parent 75b2d26187
commit 3c421c5726
5 changed files with 47 additions and 1 deletions

View File

@ -11,6 +11,7 @@ use std::path::PathBuf;
pub(crate) const NUSHELL_FOLDER: &str = "nushell";
const CONFIG_FILE: &str = "config.nu";
const ENV_FILE: &str = "env.nu";
const LOGINSHELL_FILE: &str = "login.nu";
const HISTORY_FILE: &str = "history.txt";
pub(crate) fn read_config_file(
@ -104,6 +105,26 @@ pub(crate) fn read_config_file(
}
}
pub(crate) fn read_loginshell_file(
engine_state: &mut EngineState,
stack: &mut Stack,
is_perf_true: bool,
) {
// read and execute loginshell file if exists
if let Some(mut config_path) = nu_path::config_dir() {
config_path.push(NUSHELL_FOLDER);
config_path.push(LOGINSHELL_FILE);
if config_path.exists() {
eval_config_contents(config_path, engine_state, stack);
}
}
if is_perf_true {
info!("read_loginshell_file {}:{}:{}", file!(), line!(), column!());
}
}
pub(crate) fn create_history_path() -> Option<PathBuf> {
nu_path::config_dir().and_then(|mut history_path| {
history_path.push(NUSHELL_FOLDER);