badgerodon/penv

语言: Go

git: https://github.com/badgerodon/penv

永久设置/取消设置环境变量
Permanently set/unset environment variables
README.md (中文)

penv

penv永久设置环境变量。它支持以下内容:

  • bash - 条目被添加到〜/ .bashrc
  • fish - 条目被添加到〜/ .config / fish / config.fish中
  • windows - 将条目添加到当前用户的注册表中
  • osx - 条目被添加到用户launchctl脚本。你必须重新启动         获取新环境的计划。 (即重启你的终端)

安装

penv既是图书馆又是命令。要在您自己的代码中使用该库,请参阅 文件。 要安装命令运行:

go get github.com/badgerodon/penv/...

这是它的用法:

penv <command>

Commands:
  set <name> <value>
    Permanently NAME to VALUE in the environment

  unset <name>
    Permanently unset NAME in the environment

  append <name> <value>
    Permanently append VALUE to NAME in the environment

陷阱

Windows至少需要Go 1.3。

不同的操作系统/ shell实际上不兼容。我能够通过使用他们的配置文件来识别我负责使用shell(比如bash)的环境变量,但我不能用Windows做到这一点。所有追加都将折叠成集合,而取消设置不仅仅掩盖了值,它们实际上可能会将其删除。

换句话说,这个命令有效,但它很危险。如果你设置你的PATH,当它清除所有以前的值并且你无法取回它时不要感到惊讶。

执照

WITH

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

penv

penv permanently sets environment variables. It supports the following:

  • bash - entries are added to ~/.bashrc
  • fish - entries are added to ~/.config/fish/config.fish
  • windows - entries are added to the registry for the current user
  • osx - entries are added to a user launchctl script. You will have to restart
    programs to pick up the new environment. (ie restart your terminal)

Installation

penv is both a library and a command. To use the library in your own code see
the documentation.
To install the command run:

go get github.com/badgerodon/penv/...

Here's its usage:

penv <command>

Commands:
  set <name> <value>
    Permanently NAME to VALUE in the environment

  unset <name>
    Permanently unset NAME in the environment

  append <name> <value>
    Permanently append VALUE to NAME in the environment

Gotchas

Windows requires at least Go 1.3.

Different operating systems / shells aren't really compatible. I'm able to discern which environment variables I'm responsible for with shells (like bash) by using their config files, but I can't do that with Windows. All appends will get collapsed into sets, and unsets aren't just masking the value, they may actually remove it.

In other words this command works but it's dangerous. If you set your PATH don't be surprised when it clears all the previous values and you can't get them back.

License

MIT