{"id":18105655,"url":"https://github.com/tesujimath/bash-env-nushell","last_synced_at":"2025-03-29T13:30:59.673Z","repository":{"id":210788284,"uuid":"727454704","full_name":"tesujimath/bash-env-nushell","owner":"tesujimath","description":"Bash environment for Nushell","archived":false,"fork":false,"pushed_at":"2024-10-28T05:20:14.000Z","size":106,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-28T08:42:07.484Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tesujimath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-04T22:29:01.000Z","updated_at":"2024-10-28T05:19:38.000Z","dependencies_parsed_at":"2024-01-16T15:45:03.472Z","dependency_job_id":"6eb503d6-b238-4eb4-9b2b-14e83bd26a0e","html_url":"https://github.com/tesujimath/bash-env-nushell","commit_stats":null,"previous_names":["tesujimath/nu_plugin_bash_env","tesujimath/bash-env-nushell"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tesujimath%2Fbash-env-nushell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tesujimath%2Fbash-env-nushell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tesujimath%2Fbash-env-nushell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tesujimath%2Fbash-env-nushell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tesujimath","download_url":"https://codeload.github.com/tesujimath/bash-env-nushell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246190268,"owners_count":20738001,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-31T23:00:28.070Z","updated_at":"2025-03-29T13:30:59.666Z","avatar_url":"https://github.com/tesujimath.png","language":"Rust","readme":"# Bash environment for Nushell\n\nHistorically Bash environment for Nushell was provided via the `nu_plugin_bash_env` plugin in this repo.\n\nThat plugin has now been removed in favour of the `bash-env` module, which is more feature rich and also embarrassingly simpler than the plugin.  For historical documentation for the plugin see its [README](README.plugin.md).\n\n## bash-env module\n\n### Examples\n\n#### Simple Usage\n```\n\u003e bash-env ./tests/simple.env\n╭───┬───╮\n│ B │ b │\n│ A │ a │\n╰───┴───╯\n\u003e echo $env.A\nError: nu::shell::column_not_found\n\n  × Cannot find column 'A'\n   ╭─[entry #77:1:6]\n 1 │ echo $env.A\n   ·      ───┬──┬\n   ·         │  ╰── value originates here\n   ·         ╰── cannot find column 'A'\n   ╰────\n\n\u003e bash-env ./tests/simple.env | load-env\n\u003e echo $env.A\na\n\u003e echo $env.B\nb\n\n\n\u003e bash-env tests/simple.env\n╭──────────────╮\n│ empty record │\n╰──────────────╯\n\n# no new or changed environment variables, so nothing returned\n\n\u003e ssh-agent | bash-env\n╭───────────────┬─────────────────────────────────────╮\n│ SSH_AUTH_SOCK │ /tmp/ssh-XXXXXXOjZtSh/agent.1612713 │\n│ SSH_AGENT_PID │ 1612715                             │\n╰───────────────┴─────────────────────────────────────╯\n```\n\n#### Shell Variables\n\nRather than folding shell variables in with the environment variables as was done by the plugin, the `-s` or `--shellvars` option results in structured output with separate `env` and `shellvars`.\n\n```\n\u003e echo \"ABC=123\" | bash-env\n╭──────────────╮\n│ empty record │\n╰──────────────╯\n\n\u003e echo \"ABC=123\" | bash-env -s\n╭───────────┬───────────────────╮\n│ env       │ {record 0 fields} │\n│           │ ╭─────┬─────╮     │\n│ shellvars │ │ ABC │ 123 │     │\n│           │ ╰─────┴─────╯     │\n╰───────────┴───────────────────╯\n\u003e (echo \"ABC=123\" | bash-env -s).shellvars\n╭─────┬─────╮\n│ ABC │ 123 │\n╰─────┴─────╯\n\n\u003e bash-env /etc/os-release\n╭──────────────╮\n│ empty record │\n╰──────────────╯\n\n\u003e (bash-env /etc/os-release -s).shellvars\n╭───────────────────┬─────────────────────────────────────────╮\n│ LOGO              │ nix-snowflake                           │\n│ NAME              │ NixOS                                   │\n│ BUG_REPORT_URL    │ https://github.com/NixOS/nixpkgs/issues │\n│ HOME_URL          │ https://nixos.org/                      │\n│ VERSION_CODENAME  │ vicuna                                  │\n│ ANSI_COLOR        │ 1;34                                    │\n│ ID                │ nixos                                   │\n│ PRETTY_NAME       │ NixOS 24.11 (Vicuna)                    │\n│ DOCUMENTATION_URL │ https://nixos.org/learn.html            │\n│ SUPPORT_URL       │ https://nixos.org/community.html        │\n│ IMAGE_ID          │                                         │\n│ VERSION_ID        │ 24.11                                   │\n│ VERSION           │ 24.11 (Vicuna)                          │\n│ IMAGE_VERSION     │                                         │\n│ BUILD_ID          │ 24.11.20240916.99dc878                  │\n╰───────────────────┴─────────────────────────────────────────╯\n```\n\n### Shell Functions\n\nShell functions may be run and their effect on the environment captured.\n\n```\n\u003e cat ./tests/shell-functions.env\nexport A=1\nexport B=1\n\nfunction f2() {\n        export A=2\n        export B=2\n        C2=\"I am shell variable C2\"\n}\n\nfunction f3() {\n        export A=3\n        export B=3\n        C3=\"I am shell variable C3\"\n}\n\u003e bash-env ./tests/shell-functions.env\n╭───┬───╮\n│ B │ 1 │\n│ A │ 1 │\n╰───┴───╯\n\u003e bash-env -f [f2 f3] ./tests/shell-functions.env\n╭───────────┬──────────────────────────────────────────────────────────╮\n│           │ ╭───┬───╮                                                │\n│ env       │ │ B │ 1 │                                                │\n│           │ │ A │ 1 │                                                │\n│           │ ╰───┴───╯                                                │\n│ shellvars │ {record 0 fields}                                        │\n│           │ ╭────┬─────────────────────────────────────────────────╮ │\n│ fn        │ │    │ ╭───────────┬─────────────────────────────────╮ │ │\n│           │ │ f2 │ │           │ ╭───┬───╮                       │ │ │\n│           │ │    │ │ env       │ │ B │ 2 │                       │ │ │\n│           │ │    │ │           │ │ A │ 2 │                       │ │ │\n│           │ │    │ │           │ ╰───┴───╯                       │ │ │\n│           │ │    │ │           │ ╭────┬────────────────────────╮ │ │ │\n│           │ │    │ │ shellvars │ │ C2 │ I am shell variable C2 │ │ │ │\n│           │ │    │ │           │ ╰────┴────────────────────────╯ │ │ │\n│           │ │    │ ╰───────────┴─────────────────────────────────╯ │ │\n│           │ │    │ ╭───────────┬─────────────────────────────────╮ │ │\n│           │ │ f3 │ │           │ ╭───┬───╮                       │ │ │\n│           │ │    │ │ env       │ │ B │ 3 │                       │ │ │\n│           │ │    │ │           │ │ A │ 3 │                       │ │ │\n│           │ │    │ │           │ ╰───┴───╯                       │ │ │\n│           │ │    │ │           │ ╭────┬────────────────────────╮ │ │ │\n│           │ │    │ │ shellvars │ │ C3 │ I am shell variable C3 │ │ │ │\n│           │ │    │ │           │ ╰────┴────────────────────────╯ │ │ │\n│           │ │    │ ╰───────────┴─────────────────────────────────╯ │ │\n│           │ ╰────┴─────────────────────────────────────────────────╯ │\n╰───────────┴──────────────────────────────────────────────────────────╯\n\n\u003e (bash-env -f [f2 f3] ./tests/shell-functions.env).fn.f2.env\n╭───┬───╮\n│ B │ 2 │\n│ A │ 2 │\n╰───┴───╯\n\u003e (bash-env -f [f2 f3] ./tests/shell-functions.env).fn.f2.env | load-env\n\u003e echo $env.B\n2\n\n```\n\n### Installation\n\nDownload the module, and add to `config.nu`:\n\n```\nuse /path/to/bash-env.nu\n```\n\nIn contrast to the plugin, the module requires [`bash-env-json`](https://github.com/tesujimath/bash-env-json) to be separately downloaded and installed as an executable on the `$PATH`.\n\n## Nix flake\n\nThe module is installable from its flake using Nix Home Manager.\n\nSee my own [Home Manager flake](https://github.com/tesujimath/home.nix/blob/main/flake.nix#L12) and [nushell module](https://github.com/tesujimath/home.nix/blob/main/modules/nushell/default.nix) for hints how to achieve this.  Note in particular the requirement for [each-time plugin registration](https://github.com/tesujimath/home.nix/blob/main/modules/nushell/config.nu#L761).\n\n## Future work\n\n- unsetting an environment variable ought to be possible\n","funding_links":[],"categories":["Scripts"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftesujimath%2Fbash-env-nushell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftesujimath%2Fbash-env-nushell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftesujimath%2Fbash-env-nushell/lists"}