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

Conversation

calebhearth
Copy link

In (some?) shells, it's sometimes preferable to set up env vars in a
different place than other configuration like most of what atuin init
sets up. For example, ZSH reads ~/.zshenv for all shells while ~/.zshrc
is only read for interactive shells.

This allows splitting the output of init such that in these two
different config files we could load environment variables and load all
other config seperately:

~/.zshenv:

eval "$(atuin init zsh --env-only)"

~/.zshrc:

eval "$(atuin init zsh --skip-env --disable-up-arrow)"

Which means that when launching noninteractive shells (I do this
frequently for running tests from Vim, for example, but it's more
generally useful) the specified env values will be sourced and we won't
redefine them in login shells.

Checks

  • I am happy for maintainers to push small adjustments to this PR,
    to speed up the review cycle
  • I have checked that there are no existing pull requests for the same thing

Note: I know I didn't create an issue or post anywhere else first. If
this is totally not a desired feature my feelings won't be hurt if you
say so and close this.

In (some?) shells, it's sometimes preferable to set up env vars in a
different place than other configuration like most of what `atuin init`
sets up. For example, ZSH reads ~/.zshenv for all shells while ~/.zshrc
is only read for interactive shells.

This allows splitting the output of init such that in these two
different config files we could load environment variables and load all
other config seperately:

~/.zshenv:

    eval "$(atuin init zsh --env-only)"

~/.zshrc:

    eval "$(atuin init zsh --skip-env --disable-up-arrow)"

Which means that when launching noninteractive shells (I do this
frequently for running tests from Vim, for example, but it's more
generally useful) the specified env values will be sourced and we won't
redefine them in login shells.
@calebhearth
Copy link
Author

I took a look at the clippy errors. I was able to fix a docs suggestion but extracting an enum and sharing across files proved more complicated. I've not done much rust before and while I had no problem (and my initial instinct had been to) extracting a 3 value enum, actually sharing that across files exceeded my skill level.

calebhearth added a commit to calebhearth/dotfiles that referenced this pull request Aug 30, 2024
When/if atuinsh/atuin#2371 is merged, split the
atuin init line across ~/.zshrc and ~/.zshenv.
@calebhearth
Copy link
Author

@ellie I know you're busy with Desktop, but wondering if you have a bit to look at this. I'm happy to try and fix clippy if you want to point me in the right direction, or if you know how to do the fix easily feel free.

@cosgroveb
Copy link

<3 this is a worthwhile enhancement

@cosgroveb
Copy link

CONTIRUBUTING.md doesn't say it but maybe @ellie would be more responsive with a corresponding issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants