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

Implement PowerShell profile #42

Closed
blakeNaccarato opened this issue Oct 9, 2021 · 6 comments
Closed

Implement PowerShell profile #42

blakeNaccarato opened this issue Oct 9, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@blakeNaccarato
Copy link
Member

My PowerShell profile activates virtual environments detected in the current environment. I could instruct first-time contributors to modify their profile in CONTRIBUTING.md, but it would be nice to ship the appropriate profile options.

Maybe we can include a profile mix-in that can be dot-sourced by users.

@blakeNaccarato blakeNaccarato changed the title The shellLauncher setting depends on a particular PowerShell profile configuration Implement PowerShell profile Oct 9, 2021
@blakeNaccarato
Copy link
Member Author

This issue will now track effort on the PowerShell profile implementation. Things like automatic activation of the virtual environment, populating PYTHONSTARTUP with tooling\.pythonrc.py, and more.

@blakeNaccarato
Copy link
Member Author

Maybe I can minimally touch the user's profile by asking them to run Set-PsEnv if a .env file exists. This keeps the barrier between profile-specific matters and project-specific matters. Then we can ship a .env in the template that touches the relevant environment variables.

@blakeNaccarato
Copy link
Member Author

These two are roughly equivalent:

In the $PROFILE for pwsh:

# If there is an `.env` file in the PWD, load environment variables from it
Set-PsEnv

In .bashrc

#* Import dotenv aka .env environment variables if it is found
if [ -f ./.env ] ; then
    set -o allexport # enable shell option to export all created variables
    source ./.env # now this will export all vars instead of just one
    set +o allexport # disable shell option to export all created variables
fi

@blakeNaccarato
Copy link
Member Author

Even though we aren't bundling a PowerShell profile or .bashrc, the manual first-time setup for a user will need to be documented. For security reasons, this cannot be automated, and instead we will tell the user what to do and why its needed.

@blakeNaccarato blakeNaccarato added the enhancement New feature or request label Feb 11, 2022
@blakeNaccarato
Copy link
Member Author

PowerShell profile tinkering is automatically done in typer w/ shellingham as a way to check which terminal the user has. So maybe it's reasonable to do this, but have a manual "echo text to terminal for you to copy instead" option as well.

@blakeNaccarato
Copy link
Member Author

This is completed in scripts/Initialize-Shell.ps1, which is manually invoked wherever needed to set environment variables and activate the environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant