PS /> Get-Host
Name : ConsoleHost
Version : 7.3.0
InstanceId : c3f625f0-dad8-4325-a0a1-f6499afecb8a
UI : System.Management.Automation.Internal.Host.InternalHostUserInte
rface
CurrentCulture : en-GB
CurrentUICulture : en-GB
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace Function Write-Color {
Param (
[ValidateNotNullOrEmpty()]
[string] $newColor
)
$oldColor = $host.UI.RawUI.ForegroundColor
$host.UI.RawUI.ForegroundColor = $newColor
If ($args) {
Write-Output $args
}
Else {
$input | Write-Output
}
$host.UI.RawUI.ForegroundColor = $oldColor
} # macOS
PS /{current_dir}>
# Windows
PS C:> PS /> function prompt { "Hello, World > " }
Hello, World > PS /> Function prompt { Get-Process Slack } System.Diagnostics.Process (Slack)
function prompt {
$time = (Get-Date).ToShortTimeString()
"$time $([net.dns]::GetHostName()):> "
}
# eg:
11:00 Sirwans-MacBook-Pro.local:> Function Write-Branch {
If (Test-Path .git) {
$branch = git branch --show-current
$lastCommitAuthor = git log -1 --pretty=format:"%an"
If ($null -ne $lastCommitAuthor) {
Return "($branch - latest commit written by
برچسب:
نویسنده: دانلودی
تاريخ: شنبه
19 آذر
1401 ساعت: 20:43