Setting Environment Variables
Setting Environment Variables for GitHub Tokens or SSH Keys
1. On Linux/macOS:
Setting a new environment variable:
export GITHUB_TOKEN=your_personal_access_tokenUsing the environment variable: You can reference the above variable in your scripts or terminal using $GITHUB_TOKEN.
2. On Windows:
Using Command Prompt:
set GITHUB_TOKEN=your_personal_access_tokenUsing PowerShell:
$env:GITHUB_TOKEN="your_personal_access_token"Using the environment variable: In Command Prompt, you'd reference it as %GITHUB_TOKEN%, and in PowerShell, you'd use $env:GITHUB_TOKEN.
Persisting Environment Variables
The above commands will only set the variable for your current session. If you want to make the variable persistent across sessions:
1. On Linux:
Add the export line to your ~/.bashrc, ~/.zshrc, or profile file of whatever shell you're using.
2. On macOS:
Add the export line to your ~/.bash_profile or ~/.zshrc depending on your shell.
3. On Windows:
Search for "Environment Variables" in your computer's search.
Choose "Edit the system environment variables".
In the System Properties window, click the "Environment Variables" button.
Under "User variables", click "New" and add your variable and value.
Important Note: Be cautious when setting environment variables, especially if you're sharing your scripts or dotfiles. You don't want to accidentally expose sensitive data. Always double-check what you're sharing.
Last updated