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 shellenv template for PowerShell #12494

Merged
merged 1 commit into from Nov 30, 2021
Merged

Add shellenv template for PowerShell #12494

merged 1 commit into from Nov 30, 2021

Conversation

jpawlowski
Copy link

@jpawlowski jpawlowski commented Nov 30, 2021

This is a more simple way to support running the brew command inside of a PowerShell session that is not a child process of a regular Unix shell session (e.g. where existing environment variables are not inherited). It is useful in case one wants to have a dedicated shell profile setup for PowerShell in Apple Terminal, iTerm, or other terminal emulators.

It is as simple as running brew shellenv | Invoke-Expression at the beginning of a PowerShell session or by adding the same command to the PowerShell $PROFILE file.

To automate this, the following command can be run once to finish the setup inside of a PowerShell session:

Add-Content -Path $PROFILE -Value '$(if (Test-Path -PathType Leaf /opt/homebrew/bin/brew) {/opt/homebrew/bin/brew shellenv} elseif (Test-Path -PathType Leaf /usr/local/bin/brew) {/usr/local/bin/brew shellenv}) | Invoke-Expression -ErrorAction SilentlyContinue'
$(if (Test-Path -PathType Leaf /opt/homebrew/bin/brew) {/opt/homebrew/bin/brew shellenv} elseif (Test-Path -PathType Leaf /usr/local/bin/brew) {/usr/local/bin/brew shellenv}) | Invoke-Expression -ErrorAction SilentlyContinue

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks so much for your first contribution and sponsorship! Without people like you submitting PRs we couldn't run this project. You rock, @jpawlowski!

@MikeMcQuaid MikeMcQuaid merged commit 13314ca into Homebrew:master Nov 30, 2021
@jpawlowski jpawlowski deleted the patch-1 branch December 1, 2021 08:46
@github-actions github-actions bot added the outdated PR was locked due to age label Jan 1, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants