From c89673f442616fff7a90afa531f26cfd3514b031 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Tue, 26 Dec 2023 11:57:02 +0100 Subject: [PATCH] Rename set-profile.ps1 to write-posershell-profile.ps1 --- scripts/set-profile.ps1 | 31 ---------------------------- scripts/write-powershell-profile.ps1 | 29 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 31 deletions(-) delete mode 100755 scripts/set-profile.ps1 create mode 100755 scripts/write-powershell-profile.ps1 diff --git a/scripts/set-profile.ps1 b/scripts/set-profile.ps1 deleted file mode 100755 index a08c07cd..00000000 --- a/scripts/set-profile.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -<# -.SYNOPSIS - Sets the user's PowerShell profile -.DESCRIPTION - This PowerShell script sets the PowerShell profile for the current user. -.EXAMPLE - PS> ./set-profile -.LINK - https://github.com/fleschutz/PowerShell -.NOTES - Author: Markus Fleschutz | License: CC0 -#> - -try { - "⏳ (1/3) Querying path to PowerShell profile 'CurrentUserCurrentHost'..." - $PathToProfile = $PROFILE.CurrentUserCurrentHost - "$PathToProfile" - - "⏳ (2/3) Creating the profile (if non-existent)..." - $Null = New-Item -Path $profile -ItemType "file" -Force - - "⏳ (3/3) Copying my-profile.ps1..." - $PathToRepo = "$PSScriptRoot/.." - Copy-Item "$PathToRepo/scripts/my-profile.ps1" "$PathToProfile" -force - - "✔️ updated your PowerShell profile by my-profile.ps1 - it gets active on next login" - exit 0 # success -} catch { - "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" - exit 1 -} diff --git a/scripts/write-powershell-profile.ps1 b/scripts/write-powershell-profile.ps1 new file mode 100755 index 00000000..9a85ad67 --- /dev/null +++ b/scripts/write-powershell-profile.ps1 @@ -0,0 +1,29 @@ +<# +.SYNOPSIS + Writes the user's PowerShell profile +.DESCRIPTION + This PowerShell script writes the PowerShell profile for the current user. +.EXAMPLE + PS> ./write-powershell-profile.ps1 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "⏳ (1/3) Querying path to PowerShell profile 'CurrentUserCurrentHost'..." + $pathToProfile = $PROFILE.CurrentUserCurrentHost + + "⏳ (2/3) Creating the profile (if non-existent)..." + $null = New-Item -Path $pathToProfile -ItemType "file" -Force + + "⏳ (3/3) Updating the profile by my-profile.ps1..." + Copy-Item "$PSScriptRoot/my-profile.ps1" "$pathToProfile" -force + + "✔️ Updated your PowerShell profile - it gets active on next login" + exit 0 # success +} catch { + "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}