mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-10 15:06:51 +02:00
Updated my-profile.ps1 and update-powershell-profile.ps1
This commit is contained in:
parent
cbf0c4ce14
commit
b6fe047973
@ -1,11 +1,11 @@
|
|||||||
# MY POWERSHELL PROFILE (defines the look & feel of PowerShell)
|
# MY POWERSHELL PROFILE (defines the look & feel of PowerShell)
|
||||||
|
|
||||||
# WINDOW TITLE
|
# WINDOW TITLE
|
||||||
if ($IsLinux) { $Username = $(whoami) } else { $Username = $env:USERNAME }
|
if ($IsLinux) { $username = $(whoami) } else { $username = $env:USERNAME }
|
||||||
$host.ui.RawUI.WindowTitle = "$Username @ $(hostname)"
|
$host.ui.RawUI.WindowTitle = "$username @ $(hostname)"
|
||||||
|
|
||||||
# GREETING
|
# GREETING
|
||||||
Write-Host "Welcome $USERNAME at $(hostname), what's up?" -foregroundColor green
|
Write-Host "👋 Welcome $username to PowerShell at $(hostname)." -foregroundColor green
|
||||||
|
|
||||||
# COMMAND PROMPT
|
# COMMAND PROMPT
|
||||||
function prompt { Write-Host "`n➤ " -noNewline -foregroundColor yellow; return " " }
|
function prompt { Write-Host "`n➤ " -noNewline -foregroundColor yellow; return " " }
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Updates the PowerShell profile
|
Updates the user's PowerShell profile
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script write/overwrites the PowerShell profile for the current user.
|
This PowerShell script write/overwrites the PowerShell profile of the current user.
|
||||||
.PARAMETER path
|
.PARAMETER path
|
||||||
Specifies the path to the new profile ($PSScriptRoot/my-profile.ps1 by default)
|
Specifies the path to the new profile ($PSScriptRoot/my-profile.ps1 by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./update-powershell-profile.ps1
|
PS> ./update-powershell-profile.ps1
|
||||||
⏳ (1/2) Query location of PowerShell profile 'CurrentUserCurrentHost'...
|
⏳ (1/2) Query path to PowerShell profile 'CurrentUserCurrentHost'...
|
||||||
⏳ (2/2) Copy my-profile.ps1 to C:\Users\Markus\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1...
|
⏳ (2/2) Copy my-profile.ps1 to C:\Users\Markus\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1...
|
||||||
✔️ Your PowerShell profile is updated - it get's active on next login.
|
✔️ Updated your PowerShell profile - it get's active on next login.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -19,7 +19,7 @@
|
|||||||
param([string]$path = "$PSScriptRoot/my-profile.ps1")
|
param([string]$path = "$PSScriptRoot/my-profile.ps1")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
"⏳ (1/2) Query location of PowerShell profile 'CurrentUserCurrentHost'..."
|
"⏳ (1/2) Query path to PowerShell profile 'CurrentUserCurrentHost'..."
|
||||||
$pathToProfile = $PROFILE.CurrentUserCurrentHost
|
$pathToProfile = $PROFILE.CurrentUserCurrentHost
|
||||||
|
|
||||||
$filename = (Get-Item "$path").Name
|
$filename = (Get-Item "$path").Name
|
||||||
@ -27,7 +27,7 @@ try {
|
|||||||
$null = New-Item -Path $pathToProfile -ItemType "file" -Force
|
$null = New-Item -Path $pathToProfile -ItemType "file" -Force
|
||||||
Copy-Item "$path" "$pathToProfile" -force
|
Copy-Item "$path" "$pathToProfile" -force
|
||||||
|
|
||||||
"✔️ Your PowerShell profile is updated - it get's active on next login."
|
"✔️ Updated your PowerShell profile - it get's active on next login."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user