A customized PowerShell profile with environment handling, package management, and productivity features.
This guide will help you set up your PowerShell profile to import a custom profile script from this repository.
- 🔄 Git-based auto-update mechanism
- 📦 Chocolatey integration
- 🎨 Oh My Posh theme support
- 🌿 Posh-Git integration
- 🔑 Elevated privileges helper (sudo)
- 🌍 Environment variable management
- ⚡ Performance optimizations
- 💤 Sleep function to pause execution
- 🔗 Mklink function to create symbolic links
- ⏱️ Timing and logging for performance measurement
- 🤖 GitHub Copilot CLI integration
- 💫 Animated loading indicators during profile initialization
- PowerShell 5.1 or later
- Git installed
- Oh My Posh installed
- Chocolatey installed
- Posh-Git installed
- GitHub CLI (
gh
) installed
-
Clone the Repository
Clone this repository to your local machine:
git clone https://github.com/ScottWilliamAnderson/scripts.git
-
Modify Your Main PowerShell Profile Script
Add the following code snippet to your main PowerShell profile script (e.g.,
...\PowerShell\Microsoft.PowerShell_profile.ps1
):You can open your main profile script by running:
notepad $PROFILE
or
code $PROFILE
Once the profile script is open, add the following code snippet:
# Check for required environment variables if (-not $env:USERPROFILE) { Write-Host "USERPROFILE environment variable is not set. Skipping profile import." return } # Define the path to the repository's profile script here and uncomment the following line # $repoPath = "$env:USERPROFILE\path\to\scripts" # Check if the repository profile script exists if (Test-Path $repoPath) { $profilePath = "$repoPath\powershell-profile\profile.ps1" Write-Host "Importing profile from $profilePath" . $profilePath } else { Write-Host "Repository profile script not found at $repoPath. Have you defined $repoPath in profile.ps1?" }
-
Customize the Repository Path
Uncomment the
$repoPath
variable in the code snippet and set it to the path where you cloned the repository.For example:
$repoPath = "$env:USERPROFILE\Documents\GitHub\scripts"
Command | Description |
---|---|
pull-profile |
Updates profile from Git repository |
sudo |
Opens elevated Windows Terminal |
refreshenv |
Refreshes environment variables |
choco |
Chocolatey package manager |
posh-git |
Posh-Git integration |
oh-my-posh |
Oh My Posh theme support |
$PROFILE |
Path to the current profile script |
sleep |
Pauses execution for a specified number of seconds |
mklink |
Creates symbolic links |
copilot-setup |
Configures GitHub Copilot CLI to use ghcs and ghce aliases |
vlcs |
Quickly activates the VLC speedup AutoHotkey script (vlc-speed-controls.ahk ) from anywhere |
The profile script now includes timing and logging functionality to measure the performance of each section. Timing information is logged to a file named profile_timing.log
in the powershell-profile
directory. The log file records the start time, end time, and duration for each section of the profile script.
Logging is optional and controlled by the ENABLE_PROFILE_LOGGING
environment variable. By default, logging is disabled. To enable logging, set the ENABLE_PROFILE_LOGGING
environment variable to true
.
For more information, refer to the main repository here.