Skip to content

Latest commit

 

History

History
120 lines (85 loc) · 3.93 KB

README.md

File metadata and controls

120 lines (85 loc) · 3.93 KB

PowerShell Profile Setup Guide 🖥️

PowerShell

📚 Overview

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.

📌 Features

  • 🔄 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

🔍 Requirements

  • PowerShell 5.1 or later
  • Git installed
  • Oh My Posh installed
  • Chocolatey installed
  • Posh-Git installed

Optional Requirements

  • GitHub CLI (gh) installed

🚀 Setup Instructions

  1. Clone the Repository

    Clone this repository to your local machine:

    git clone https://github.com/ScottWilliamAnderson/scripts.git
  2. 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?"
    }
  3. 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"

⚙️ Available Commands

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

⏱️ Timing and Logging

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.

📝 Optional Logging

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.