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

Source ~/.shellrc automatically if it exists #173

Merged
merged 2 commits into from
Sep 30, 2024
Merged

Conversation

certik
Copy link
Collaborator

@certik certik commented Sep 30, 2024

Fixes #95.

Copy link
Collaborator

@prsabahrami prsabahrami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!
Looks good to me.

@certik certik merged commit d555365 into prefix-dev:main Sep 30, 2024
6 checks passed
@certik certik deleted the rc branch September 30, 2024 23:11
@prsabahrami
Copy link
Collaborator

Do you think this should only be done as an option in interactive mode? I'm not sure how useful it would be but we can also add something like

cargo r ./scripts/script.sh --withrc

@certik
Copy link
Collaborator Author

certik commented Sep 30, 2024

Thanks for the review! I had to add an option --norc to skip sourcing it if requested (just like Bash allows), as I quickly found out that sourcing every time breaks my MSVC loading script, as my ~/.shellrc sets the $PATH variable by overriding it (until #90 is fixed), so I need to skip sourcing it.

@certik
Copy link
Collaborator Author

certik commented Sep 30, 2024

It currently is an option in interactive mode only I think:

        execute(&script_text, &mut state).await?;
        if options.interact {
              interactive(Some(state), options.norc).await?;
        }

The script gets executed without sourcing .shellrc, and then if interactive mode is started, it will source it.

I think this takes care of most of the use cases, and since bash doesn't even have --withrc, we probably don't need it, but if we do, we can.

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.

Implement ~/.shellrc
2 participants