forked from ChrisTitusTech/powershell-profile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sent local PowerShell profile updates to GitHub
- Loading branch information
Showing
4 changed files
with
147 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
*.zip | ||
*.ttf | ||
oldprofile.ps1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 🎨 PowerShell Profile (Pretty PowerShell) | ||
|
||
A stylish and functional PowerShell profile that looks and feels almost as good as a Linux terminal. | ||
|
||
## ⚡ One Line Install (Administrator PowerShell Recommended) | ||
|
||
Execute the following command in an elevated PowerShell window to install the PowerShell profile: | ||
|
||
``` | ||
irm "https://github.com/F5T3/powershell-profile/raw/main/setup.ps1" | iex | ||
``` | ||
|
||
## 🛠️ Fix the Missing Font | ||
|
||
After running the script, you'll find a downloaded `cove.zip` file in the folder you executed the script from. Follow these steps to install the required nerd fonts: | ||
|
||
1. Extract the `cove.zip` file. | ||
2. Locate and install the nerd fonts. | ||
|
||
Now, enjoy your enhanced and stylish PowerShell experience! 🚀 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Ensure the script can run with elevated privileges | ||
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | ||
Write-Warning "Please run this script as an Administrator!" | ||
break | ||
} | ||
|
||
# Function to test internet connectivity | ||
function Test-InternetConnection { | ||
try { | ||
$testConnection = Test-Connection -ComputerName www.google.com -Count 1 -ErrorAction Stop | ||
return $true | ||
} | ||
catch { | ||
Write-Warning "Internet connection is required but not available. Please check your connection." -ForegroundColor Yellow | ||
return $false | ||
} | ||
} | ||
|
||
# Check for internet connectivity before proceeding | ||
if (-not (Test-InternetConnection)) { | ||
break | ||
} | ||
|
||
# Profile creation or update | ||
if (!(Test-Path -Path $PROFILE -PathType Leaf)) { | ||
try { | ||
# Detect Version of PowerShell & Create Profile directories if they do not exist. | ||
$profilePath = "" | ||
if ($PSVersionTable.PSEdition -eq "Core") { | ||
$profilePath = "$env:userprofile\Documents\Powershell" | ||
} | ||
elseif ($PSVersionTable.PSEdition -eq "Desktop") { | ||
$profilePath = "$env:userprofile\Documents\WindowsPowerShell" | ||
} | ||
|
||
if (!(Test-Path -Path $profilePath)) { | ||
New-Item -Path $profilePath -ItemType "directory" | ||
} | ||
|
||
Invoke-RestMethod https://github.com/F5T3/powershell-profile/raw/main/Microsoft.PowerShell_profile.ps1 -OutFile $PROFILE | ||
Write-Host "The profile @ [$PROFILE] has been created." -ForegroundColor Green | ||
Write-Host "If you want to add any persistent components, please do so at [$profilePath\Profile.ps1] as there is an updater in the installed profile which uses the hash to update the profile and will lead to loss of changes" -ForegroundColor Yellow | ||
} | ||
catch { | ||
Write-Error "Failed to create or update the profile. Error: $_" -ForegroundColor red | ||
} | ||
} | ||
else { | ||
try { | ||
Get-Item -Path $PROFILE | Move-Item -Destination "oldprofile.ps1" -Force | ||
Invoke-RestMethod https://github.com/F5T3/powershell-profile/raw/main/Microsoft.PowerShell_profile.ps1 -OutFile $PROFILE | ||
Write-Host "The profile @ [$PROFILE] and has replace the old profile." -ForegroundColor Green | ||
Write-Host "Please back up any persistent components of your old profile to [$HOME\Documents\PowerShell\Profile.ps1] as there is an updater in the installed profile which uses the hash to update the profile and will lead to loss of changes" -ForegroundColor Yellow | ||
} | ||
catch { | ||
Write-Error "Failed to backup and update the profile. Error: $_" -ForegroundColor Red | ||
} | ||
} | ||
|
||
# Font Install | ||
try { | ||
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | ||
$fontFamilies = (New-Object System.Drawing.Text.InstalledFontCollection).Families.Name | ||
|
||
if ($fontFamilies -notcontains "RobotoMono Nerd Font") { | ||
$webClient = New-Object System.Net.WebClient | ||
$webClient.DownloadFileAsync((New-Object System.Uri("https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/RobotoMono.zip")), ".\RobotoMono.zip") | ||
|
||
while ($webClient.IsBusy) { | ||
Start-Sleep -Seconds 2 | ||
} | ||
|
||
Expand-Archive -Path ".\RobotoMono.zip" -DestinationPath ".\RobotoMono" -Force | ||
$destination = (New-Object -ComObject Shell.Application).Namespace(0x14) | ||
Get-ChildItem -Path ".\RobotoMono" -Recurse -Filter "*.ttf" | ForEach-Object { | ||
If (-not(Test-Path "C:\Windows\Fonts\$($_.Name)")) { | ||
$destination.CopyHere($_.FullName, 0x10) | ||
} | ||
} | ||
|
||
Remove-Item -Path ".\RobotoMono" -Recurse -Force | ||
Remove-Item -Path ".\RobotoMono.zip" -Force | ||
} | ||
} | ||
catch { | ||
Write-Error "Failed to download or install the Roboto Mono Nerd Font. Error: $_" -ForegroundColor Red | ||
} | ||
|
||
# Final check and message to the user | ||
if ((Test-Path -Path $PROFILE) -and (winget list --name "OhMyPosh" -e) -and ($fontFamilies -contains "RobotoMono Nerd Font")) { | ||
Write-Host "Setup completed successfully. Please restart your PowerShell session to apply changes." -ForegroundColor Green | ||
} else { | ||
Write-Warning "Setup completed with errors. Please check the error messages above." | ||
} | ||
#Install packages | ||
try { | ||
$packages = @("Zoxide", "Starship", "Neovim", "Terminal-Icon", "Neofetch", "Everything", "EverythingToolbar", "Docker", "GlazeWM", "OhMyPosh", "Chocolatey", "Shell") | ||
$missingPackages = @() | ||
|
||
foreach ($package in $packages) { | ||
$packageInfo = winget list --id $package | ||
|
||
if (-not $packageInfo) { | ||
$missingPackages += $package | ||
} | ||
} | ||
|
||
if ($missingPackages.Count -eq 0) { | ||
Write-Host "The apps are already installed" -ForegroundColor Green | ||
} else { | ||
foreach ($packageName in $missingPackages) { | ||
winget install --id $packageName | ||
} | ||
$installed = ($missingPackages -join ", ") -replace ",([^,]+)$"," and`$1" | ||
Write-Host "The apps, $installed got installed" -ForegroundColor Green | ||
} | ||
} | ||
catch { | ||
Write-Error "Failed to download or install the apps. Error: $_" -ForegroundColor Red | ||
} |