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

Add brew shellenv - see #4780 #4849

Merged
merged 1 commit into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions Library/Homebrew/cmd/shellenv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#: * `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
8 changes: 8 additions & 0 deletions Library/Homebrew/test/cmd/shellenv_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe "brew shellenv", :integration_test do
it "doesn't fail" do
Copy link
Member

Choose a reason for hiding this comment

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

Could you assert_match on e.g. the HOMEBREW_PREFIX/bin being present?

expect { brew "shellenv" }
.to output(%r{#{HOMEBREW_PREFIX}/bin}).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end
5 changes: 5 additions & 0 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note

If `--env=std` is passed, use the standard `PATH` instead of superenv's.

* `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

* `style` [`--fix`] [`--display-cop-names`] [`--only-cops=``cops`|`--except-cops=``cops`] [`files`|`taps`|`formulae`]:
Check formulae or files for conformance to Homebrew style guidelines.

Expand Down
3 changes: 3 additions & 0 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ 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
.
.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\.
.
.IP
Expand Down