Skip to content

Commit

Permalink
add zshrc config to setup if it exists (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
sslivkoff authored Jan 30, 2024
1 parent fa0f4b8 commit 21ab52a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 5 additions & 2 deletions rust/crates/mesc_cli/src/cli/subcommands/setup/command.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{MescCliError, SetupArgs};
use mesc::{MescError, RpcConfig};
use toolstr::Colorize;
use std::path::PathBuf;
use toolstr::Colorize;

use super::{config_modification::*, inquire_utils::*, selectors::*, shell_config::*, writing::*};

Expand All @@ -25,7 +25,10 @@ pub(crate) async fn setup_command(args: SetupArgs) -> Result<(), MescCliError> {
let result = modify_existing_config(config, Some(mode)).await;
if shell_config_modified {
println!();
println!("{}", "Shell config files were modified. Restart shell to load these files.".magenta())
println!(
"{}",
"Shell config files were modified. Restart shell to load these files.".magenta()
)
}
result
}
Expand Down
10 changes: 9 additions & 1 deletion rust/crates/mesc_cli/src/cli/subcommands/setup/shell_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ pub(crate) fn get_shell_config_paths() -> Result<Vec<PathBuf>, MescCliError> {
let home_dir =
std::env::var("HOME").map_err(|_| MescCliError::Error("home dir not found".to_string()))?;
let home_path = PathBuf::from(home_dir);
let candidates = vec![home_path.join(".bashrc"), home_path.join(".profile")];
let mut candidates = vec![home_path.join(".bashrc"), home_path.join(".profile")];

// paths added only if they exist
for path in [home_path.join(".zshrc")] {
if path.exists() {
candidates.push(path)
}
}

Ok(candidates)
}

Expand Down

0 comments on commit 21ab52a

Please sign in to comment.