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 --login to be used with nu's --commands parameter #10253

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

fdncred
Copy link
Collaborator

@fdncred fdncred commented Sep 6, 2023

Description

This PR allows the --login/-l parameter to be used with nushell's --commands/-c parameter. When you do this, since you're invoking it with the -l flag, nushell will load your env.nu, config.nu, and login.nu, in that order. Then it will proceed to run your commands. I think this provides a better quality of life when you want to run scripts with your personal config files as a login shell.

Before (these entries are from the default_env.nu)

image

After (these entries are from my personal env.nu)

image

closes #9833

User-Facing Changes

Tests + Formatting

After Submitting

Copy link
Member

@amtoine amtoine left a comment

Choose a reason for hiding this comment

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

changes look simple enough 👌

@balupton, i see you've added a 👍 to the PR, does that mean your issue is gone with it? 😇

@fdncred fdncred merged commit a9216de into nushell:main Sep 6, 2023
19 checks passed
@fdncred fdncred deleted the update_login_shell_usage branch September 6, 2023 18:27
@balupton
Copy link
Contributor

balupton commented Sep 7, 2023

@amtoine

So this works for nu -l -c {0]} to make it consistent with nu -l -e {0}, however there is no change to nu -l {0} despite nu -l loading the config files:

> cargo run  -- -l
    Finished dev [unoptimized + debuginfo] target(s) in 0.17s
     Running `/Users/balupton/.cargo/target/debug/nu -l`
Env
Config
Login
     __  ,
 .--()°'.' Welcome to Nushell,
'|, . ,'   based on the nu language,
 !_-(_\    where all data is structured!

Please join our Discord community at https://discord.gg/NtAbbGn
Our GitHub repository is at https://github.com/nushell/nushell
Our Documentation is located at https://nushell.sh
Tweet us at @nu_shell
Learn how to remove this at: https://nushell.sh/book/configuration.html#remove-welcome-message

It's been this long since Nushell's first commit:
4yrs 3months 26days 18hrs 3mins 45secs 623ms 940µs 

Startup Time: 169ms 569µs 250ns

~/Projects/nushell> exit                                  09/07/2023 07:03:00 PM
19:03:00:/Users/balupton/Projects/nushell:main
> cargo run  -- -l ~/Downloads/test.nu 
    Finished dev [unoptimized + debuginfo] target(s) in 0.17s
     Running `/Users/balupton/.cargo/target/debug/nu -l /Users/balupton/Downloads/test.nu`
File
19:03:13:/Users/balupton/Projects/nushell:main
> cargo run  -- -l -c ~/Downloads/test.nu
    Finished dev [unoptimized + debuginfo] target(s) in 0.17s
     Running `/Users/balupton/.cargo/target/debug/nu -l -c /Users/balupton/Downloads/test.nu`
Env
Config
Login
File

This is still a deviation from fish/zsh/bash, so not sure if Nushell team want to go further on this.

I'm happy as this this means I can adjust the CI testing for dorothy to just use nu -l -c instead of the current workaround that I am using:
https://github.com/bevry/dorothy/blob/b483848ed98201050d41b13529f0918da7a7c43d/.github/workflows/dorothy-workflow.yml#L53-L57

@fdncred
Copy link
Collaborator Author

fdncred commented Sep 7, 2023

I didn't look at nu -l <run_a_script> functionality yesterday with this PR. If someone else wants to do that, have at it.

balupton added a commit to bevry/dorothy that referenced this pull request Sep 29, 2023
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.

nu -c doesn't use env.nu in 0.83.0
3 participants