diff --git a/Library/Homebrew/cmd/shellenv.rb b/Library/Homebrew/cmd/shellenv.rb deleted file mode 100644 index 25a6c8114f..0000000000 --- a/Library/Homebrew/cmd/shellenv.rb +++ /dev/null @@ -1,16 +0,0 @@ -#: * `shellenv`: -#: Prints export statements - run them in a shell and this installation of -#: Homebrew will be included into your PATH, MANPATH, and INFOPATH. -#: Tip: have your dotfiles eval the output of this command - -module Homebrew - module_function - - def shellenv - puts <<~EOS - export PATH="#{HOMEBREW_PREFIX}/bin:#{HOMEBREW_PREFIX}/sbin:$PATH" - export MANPATH="#{HOMEBREW_PREFIX}/share/man:$MANPATH" - export INFOPATH="#{HOMEBREW_PREFIX}/share/info:$INFOPATH" - EOS - end -end diff --git a/Library/Homebrew/cmd/shellenv.sh b/Library/Homebrew/cmd/shellenv.sh new file mode 100644 index 0000000000..57627dc243 --- /dev/null +++ b/Library/Homebrew/cmd/shellenv.sh @@ -0,0 +1,18 @@ +#: * `shellenv`: +#: Prints export statements - run them in a shell and this installation of +#: Homebrew will be included into your PATH, MANPATH, and INFOPATH. +#: +#: HOMEBREW_PREFIX, HOMEBREW_CELLAR and HOMEBREW_REPOSITORY are also exported +#: to save multiple queries of those variables. +#: +#: Consider adding evaluating the output in your dotfiles (e.g. `~/.profile`) +#: with `eval $(brew shellenv)` + +homebrew-shellenv() { + echo "export HOMEBREW_PREFIX=\"$HOMEBREW_PREFIX\"" + echo "export HOMEBREW_CELLAR=\"$HOMEBREW_CELLAR\"" + echo "export HOMEBREW_REPOSITORY=\"$HOMEBREW_REPOSITORY\"" + echo "export PATH=\"$HOMEBREW_PREFIX/bin:$HOMEBREW_PREFIX/sbin:\$PATH\"" + echo "export MANPATH=\"$HOMEBREW_PREFIX/share/man:\$MANPATH\"" + echo "export INFOPATH=\"$HOMEBREW_PREFIX/share/info:\$INFOPATH\"" +} diff --git a/Library/Homebrew/test/cmd/shellenv_spec.rb b/Library/Homebrew/test/cmd/shellenv_spec.rb deleted file mode 100644 index 7297efb154..0000000000 --- a/Library/Homebrew/test/cmd/shellenv_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -describe "brew shellenv", :integration_test do - it "doesn't fail" do - expect { brew "shellenv" } - .to output(%r{#{HOMEBREW_PREFIX}/bin}).to_stdout - .and not_to_output.to_stderr - .and be_a_success - end -end diff --git a/docs/Manpage.md b/docs/Manpage.md index c00ceac7b6..163b2b8151 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -444,7 +444,12 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note * `shellenv`: Prints export statements - run them in a shell and this installation of Homebrew will be included into your PATH, MANPATH, and INFOPATH. - Tip: have your dotfiles eval the output of this command + + HOMEBREW_PREFIX, HOMEBREW_CELLAR and HOMEBREW_REPOSITORY are also exported + to save multiple queries of those variables. + + Consider adding evaluating the output in your dotfiles (e.g. `~/.profile`) + with `eval $(brew shellenv)` * `style` [`--fix`] [`--display-cop-names`] [`--only-cops=``cops`|`--except-cops=``cops`] [`files`|`taps`|`formulae`]: Check formulae or files for conformance to Homebrew style guidelines. diff --git a/manpages/brew.1 b/manpages/brew.1 index 680ad252a2..88514c779e 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -404,7 +404,13 @@ If \fB\-\-desc\fR is passed, search formulae with a description matching \fItext If \fB\-\-env=std\fR is passed, use the standard \fBPATH\fR instead of superenv\'s\. . .IP "\(bu" 4 -\fBshellenv\fR: Prints export statements \- run them in a shell and this installation of Homebrew will be included into your PATH, MANPATH, and INFOPATH\. Tip: have your dotfiles eval the output of this command +\fBshellenv\fR: Prints export statements \- run them in a shell and this installation of Homebrew will be included into your PATH, MANPATH, and INFOPATH\. +. +.IP +HOMEBREW_PREFIX, HOMEBREW_CELLAR and HOMEBREW_REPOSITORY are also exported to save multiple queries of those variables\. +. +.IP +Consider adding evaluating the output in your dotfiles (e\.g\. \fB~/\.profile\fR) with \fBeval $(brew shellenv)\fR . .IP "\(bu" 4 \fBstyle\fR [\fB\-\-fix\fR] [\fB\-\-display\-cop\-names\fR] [\fB\-\-only\-cops=\fR\fIcops\fR|\fB\-\-except\-cops=\fR\fIcops\fR] [\fIfiles\fR|\fItaps\fR|\fIformulae\fR]: Check formulae or files for conformance to Homebrew style guidelines\.