sh/PowerShell/プロンプト
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
* 基本事項 [#c5e513e4]
- PowerShellのプロンプトは pronpt 関数で定義する
-- cmd.exe で言うところの環境変数 PROMPT 相当
- PowerShellのエスケープ文字は ` (バッククオート)です
- ~/.bashrc 的なもの
-- マイドキュメント(shell:personal)\WindowsPowerShell\pro...
-- C:\WINDOWS\SYSTEM32\windowspowershell\v1.0\profile.ps1
(要 管理者権限)
--
参考:
- [[PowerShellのプロンプト文字列をカスタマイズする - @I...
- [[タブや改行を文字列値に含める方法[PowerShell] : バヤシ...
* デフォルトのプロンプト [#ib88d44d]
cmd.exe: PROMPT $p$g$s 相当
#prism(powershell){{{
PS C:\Users\1000202334\Desktopn>
}}}
定義(の中身)を表示させる
- 参考:[[PowerShell/Functionの一覧および内容を表示する方...
#prism(powershell){{{
PS C:\Users\1000202334\Desktop> (get-item function:prompt...
"PS " + $(get-location) + "> "
PS C:\Users\1000202334\Desktop>
}}}
つまりこう
#prism(powershell){{{
function prompt {
"PS " + $(get-location) + "> "
}
}}}
* 途中で改行する [#y6611e1a]
cmd.exe: PROMPT $p$_$g$s 相当
#prism(powershell){{{
PS C:\Users\1000202334\Desktop
>
}}}
profile.ps1
#prism(powershell){{{
function prompt {
"PS " + $(get-location) + "`r`n> "
}
}}}
powershellで設定
#prism(powershell){{{
# ユーザーのドキュメントディレクトリのパスを取得
$userDocuments = [Environment]::GetFolderPath('MyDocument...
# WindowsPowerShellディレクトリのパスを作成
$powershellDir = Join-Path $userDocuments "WindowsPowerSh...
# ディレクトリが存在しない場合は作成
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
}}}
終了行:
* 基本事項 [#c5e513e4]
- PowerShellのプロンプトは pronpt 関数で定義する
-- cmd.exe で言うところの環境変数 PROMPT 相当
- PowerShellのエスケープ文字は ` (バッククオート)です
- ~/.bashrc 的なもの
-- マイドキュメント(shell:personal)\WindowsPowerShell\pro...
-- C:\WINDOWS\SYSTEM32\windowspowershell\v1.0\profile.ps1
(要 管理者権限)
--
参考:
- [[PowerShellのプロンプト文字列をカスタマイズする - @I...
- [[タブや改行を文字列値に含める方法[PowerShell] : バヤシ...
* デフォルトのプロンプト [#ib88d44d]
cmd.exe: PROMPT $p$g$s 相当
#prism(powershell){{{
PS C:\Users\1000202334\Desktopn>
}}}
定義(の中身)を表示させる
- 参考:[[PowerShell/Functionの一覧および内容を表示する方...
#prism(powershell){{{
PS C:\Users\1000202334\Desktop> (get-item function:prompt...
"PS " + $(get-location) + "> "
PS C:\Users\1000202334\Desktop>
}}}
つまりこう
#prism(powershell){{{
function prompt {
"PS " + $(get-location) + "> "
}
}}}
* 途中で改行する [#y6611e1a]
cmd.exe: PROMPT $p$_$g$s 相当
#prism(powershell){{{
PS C:\Users\1000202334\Desktop
>
}}}
profile.ps1
#prism(powershell){{{
function prompt {
"PS " + $(get-location) + "`r`n> "
}
}}}
powershellで設定
#prism(powershell){{{
# ユーザーのドキュメントディレクトリのパスを取得
$userDocuments = [Environment]::GetFolderPath('MyDocument...
# WindowsPowerShellディレクトリのパスを作成
$powershellDir = Join-Path $userDocuments "WindowsPowerSh...
# ディレクトリが存在しない場合は作成
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
}}}
ページ名: