基本事項

参考:

デフォルトのプロンプト

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

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2024-11-11 (月) 09:07:06