Giter Site home page Giter Site logo

Comments (11)

amtoine avatar amtoine commented on May 18, 2024 1

@jacobono
would you mind fixing the issue in the original script you pointed at? 😊
that'd be amazing 😌

from nu_scripts.

fdncred avatar fdncred commented on May 18, 2024

I don't think we have an export env do we?

❯ help export
Export definitions or environment variables from a module.

This command is a parser keyword. For details, check:
  https://www.nushell.sh/book/thinking_in_nu.html

Search terms: module

Usage:
  > export

Subcommands:
  export alias - Alias a command (with optional flags) to a new name and export it from a module.
  export def - Define a custom command and export it from a module.
  export def-env - Define a custom command that participates in the environment and export it from a module.
  export extern - Define an extern and export it from a module.
  export module - Export a custom module from a module.
  export use - Use definitions from a module and export them from this module.

Flags:
  -h, --help - Display the help message for this command

Examples:
  Export a definition from a module
  > module utils { export def my-command [] { "hello" } }; use utils my-command; my-command
  hello

from nu_scripts.

scubacabra avatar scubacabra commented on May 18, 2024

i don't think there is one, that is where i was confused. i am using version 0.81.0

that's why i was thinking maybe it should be let-env BROWSER = "firefox" or something like that instead maybe?

the file was committed like 2 years ago, did something change between now and then that just doesn't work now?

from nu_scripts.

fdncred avatar fdncred commented on May 18, 2024

@kubouch Should export env be updated to let-env now?

from nu_scripts.

amtoine avatar amtoine commented on May 18, 2024

@fdncred
maybe you're looking for export-env?

part of the init.nu file could be written as

export-env { load-env {
    BROWSER: "firefox"
    CARGO_TARGET_DIR: "~/.cargo/target"
    EDITOR: "nvim"
    VISUAL: "nvim"
    PAGER: "less"
    SHELL: "~/.cargo/bin/nu"
    JULIA_NUM_THREADS: nproc
    HOSTNAME: (hostname | split row '.' | first | str trim)
    SHOW_USR: "true"
}}

from nu_scripts.

fdncred avatar fdncred commented on May 18, 2024

@amtoine ya, maybe that's what this script needs to be updated with. Is this a naming inconsistency? It kind of crosses both worlds of export commands and env commands. At a minimum, it would be helpful to have these commands that cross both worlds have a deprecated command that says, "Please use export-env" or a "did you mean?".

commands with env in them

config env
def-env
export def-env
export-env
hide-env
let-env
load-env
source-env
with-env

commands with export in them

export
export alias
export def
export def-env
export extern
export module
export use
export-env

from nu_scripts.

amtoine avatar amtoine commented on May 18, 2024

@amtoine ya, maybe that's what this script needs to be updated with.

i think this is the cleanest way to do it, yup 😌

one can also write something without load-env

export-env {
    let-env BROWSER = "firefox"
    let-env CARGO_TARGET_DIR = "~/.cargo/target"
    let-env EDITOR = "nvim"
    let-env VISUAL = "nvim"
    let-env PAGER = "less"
    let-env SHELL = "~/.cargo/bin/nu"
    let-env JULIA_NUM_THREADS = nproc
    let-env HOSTNAME = (hostname | split row '.' | first | str trim)
    let-env SHOW_USR = "true"
}

but this requires more let-envs 🤔

Is this a naming inconsistency? It kind of crosses both worlds of export commands and env commands. At a minimum, it would be helpful to have these commands that cross both worlds have a deprecated command that says, "Please use export-env" or a "did you mean?".

yeah this might be a good idea!

"did you mean?"s are hardcoded in Nushell?

from nu_scripts.

scubacabra avatar scubacabra commented on May 18, 2024

thank you for your help! i was looking at load-env

i just didn't think to combine with export-env!

i really would not have figured this one on my own so thanks again

this is what i ended up with for init.nu and it works well.

export-env {
    load-env {
            EDITOR: "hx"
            BROWSER: "brave"
            PAGER: "less"
            HOSTNAME: (hostname | split row '.' | first | str trim)
            SHOW_USER: true
            LS_COLORS: ([
                   "di=01;34;2;102;217;239"
                   "or=00;40;31"
                   "mi=00;40;31"
                   "ln=00;36"
                   "ex=00;32"
            ] | str join (char env_sep))
            PROMPT_COMMAND: { build-prompt }
    }
}

load-env is clear, but what was i missing by not including export-env? it seemed to me all you would need to do is load the environment (with load-env or let-env) but what is the concept i was missing to think "i need to use export-env to make this work?

from nu_scripts.

amtoine avatar amtoine commented on May 18, 2024

i think load-env only loads the variables into the local-scoped environment.
if it's in a used file, it then needs to be exported, with export-env 😋

from nu_scripts.

scubacabra avatar scubacabra commented on May 18, 2024

@amtoine the changes are in the pr now 😀

from nu_scripts.

amtoine avatar amtoine commented on May 18, 2024

coool, thanks 😋

eheh, look at this, we can do even better than closing this issue manually 😏

from nu_scripts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.