Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add zshrc config to setup if it exists #20

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading