/.bashrc 的なもの
参考:
cmd.exe: PROMPT $p$g$s 相当
PS C:\Users\1000202334\Desktopn>
定義(の中身)を表示させる
PS C:\Users\1000202334\Desktop> (get-item function:prompt).Definition
"PS " + $(get-location) + "> "
PS C:\Users\1000202334\Desktop>
つまりこう
function prompt {
"PS " + $(get-location) + "> "
}
cmd.exe: PROMPT $p$_$g$s 相当
PS C:\Users\1000202334\Desktop
>
profile.ps1
function prompt {
"PS " + $(get-location) + "`r`n> "
}
powershellで設定
# ユーザーのドキュメントディレクトリのパスを取得
$userDocuments = [Environment]::GetFolderPath('MyDocuments')
# WindowsPowerShellディレクトリのパスを作成
$powershellDir = Join-Path $userDocuments "WindowsPowerShell"
# ディレクトリが存在しない場合は作成
if (!(Test-Path $powershellDir)) {
New-Item -ItemType Directory -Path $powershellDir
}
# profile.ps1ファイルを作成し、関数定義を書き込む
$profilePath = Join-Path $powershellDir "profile.ps1"
$content = @'
function prompt {
"PS " + $(get-location) + "`r`n> "
}
'@
Set-Content -Path $profilePath -Value $content