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

Allow init --skip-env and --only-env #2371

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ All notable changes to this project will be documented in this file.
- *(gui)* Background terminals and more ([#2303](https://github.com/atuinsh/atuin/issues/2303))
- *(gui)* Clean up home page, fix a few bugs ([#2304](https://github.com/atuinsh/atuin/issues/2304))
- *(history)* Filter out various environment variables containing potential secrets ([#2174](https://github.com/atuinsh/atuin/issues/2174))
- *(init)* Allow splitting environment variable loading from remainder of setup
- *(tui)* Configurable prefix character ([#2157](https://github.com/atuinsh/atuin/issues/2157))
- *(tui)* Customizable Themes ([#2236](https://github.com/atuinsh/atuin/issues/2236))
- *(tui)* Fixed preview height option ([#2286](https://github.com/atuinsh/atuin/issues/2286))
Expand Down
16 changes: 16 additions & 0 deletions crates/atuin/src/command/client/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ pub struct Cmd {
/// Disable the binding of the Up Arrow key to atuin
#[clap(long)]
disable_up_arrow: bool,

/// Only import environment variables (useful for `~/.zsh_env` or `~/.bash_env`)
#[clap(long)]
only_env: bool,

/// Skip importing environment variables (useful if already imported)
#[clap(long)]
skip_env: bool,
}

#[derive(Clone, Copy, ValueEnum, Debug)]
Expand Down Expand Up @@ -122,6 +130,8 @@ $env.config = (
var_store,
self.disable_up_arrow,
self.disable_ctrl_r,
self.only_env,
self.skip_env,
)
.await?;
}
Expand All @@ -131,6 +141,8 @@ $env.config = (
var_store,
self.disable_up_arrow,
self.disable_ctrl_r,
self.only_env,
self.skip_env,
)
.await?;
}
Expand All @@ -140,6 +152,8 @@ $env.config = (
var_store,
self.disable_up_arrow,
self.disable_ctrl_r,
self.only_env,
self.skip_env,
)
.await?;
}
Expand All @@ -150,6 +164,8 @@ $env.config = (
var_store,
self.disable_up_arrow,
self.disable_ctrl_r,
self.only_env,
self.skip_env,
)
.await?;
}
Expand Down
16 changes: 11 additions & 5 deletions crates/atuin/src/command/client/init/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ pub async fn init(
vars: VarStore,
disable_up_arrow: bool,
disable_ctrl_r: bool,
only_env: bool,
skip_env: bool,
) -> Result<()> {
init_static(disable_up_arrow, disable_ctrl_r);
if !only_env {
init_static(disable_up_arrow, disable_ctrl_r);

let aliases = atuin_dotfiles::shell::bash::alias_config(&aliases).await;
let vars = atuin_dotfiles::shell::bash::var_config(&vars).await;
let aliases = atuin_dotfiles::shell::bash::alias_config(&aliases).await;
println!("{aliases}");
}

println!("{aliases}");
println!("{vars}");
if !skip_env {
let vars = atuin_dotfiles::shell::bash::var_config(&vars).await;
println!("{vars}");
}

Ok(())
}
16 changes: 11 additions & 5 deletions crates/atuin/src/command/client/init/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ pub async fn init(
vars: VarStore,
disable_up_arrow: bool,
disable_ctrl_r: bool,
only_env: bool,
skip_env: bool,
) -> Result<()> {
init_static(disable_up_arrow, disable_ctrl_r);
if !only_env {
init_static(disable_up_arrow, disable_ctrl_r);

let aliases = atuin_dotfiles::shell::fish::alias_config(&aliases).await;
let vars = atuin_dotfiles::shell::fish::var_config(&vars).await;
let aliases = atuin_dotfiles::shell::fish::alias_config(&aliases).await;
println!("{aliases}");
}

println!("{aliases}");
println!("{vars}");
if !skip_env {
let vars = atuin_dotfiles::shell::fish::var_config(&vars).await;
println!("{vars}");
}

Ok(())
}
16 changes: 11 additions & 5 deletions crates/atuin/src/command/client/init/xonsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@ pub async fn init(
vars: VarStore,
disable_up_arrow: bool,
disable_ctrl_r: bool,
only_env: bool,
skip_env: bool,
) -> Result<()> {
init_static(disable_up_arrow, disable_ctrl_r);
if !only_env {
init_static(disable_up_arrow, disable_ctrl_r);

let aliases = atuin_dotfiles::shell::xonsh::alias_config(&aliases).await;
let vars = atuin_dotfiles::shell::xonsh::var_config(&vars).await;
let aliases = atuin_dotfiles::shell::xonsh::alias_config(&aliases).await;
println!("{aliases}");
}

println!("{aliases}");
println!("{vars}");
if !skip_env {
let vars = atuin_dotfiles::shell::xonsh::var_config(&vars).await;
println!("{vars}");
}

Ok(())
}
16 changes: 11 additions & 5 deletions crates/atuin/src/command/client/init/zsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@ pub async fn init(
vars: VarStore,
disable_up_arrow: bool,
disable_ctrl_r: bool,
only_env: bool,
skip_env: bool,
) -> Result<()> {
init_static(disable_up_arrow, disable_ctrl_r);
if !only_env {
init_static(disable_up_arrow, disable_ctrl_r);

let aliases = atuin_dotfiles::shell::zsh::alias_config(&aliases).await;
let vars = atuin_dotfiles::shell::zsh::var_config(&vars).await;
let aliases = atuin_dotfiles::shell::zsh::alias_config(&aliases).await;
println!("{aliases}");
}

println!("{aliases}");
println!("{vars}");
if !skip_env {
let vars = atuin_dotfiles::shell::zsh::var_config(&vars).await;
println!("{vars}");
}

Ok(())
}
Loading