LoginSignup
16
9

More than 5 years have passed since last update.

PowerShellのプロンプトを短縮する

Posted at

Windows PowerShellのプロンプトが、標準だと

C:\Users\kuchitama\Documents > 

と長ったらしくフルパスを表示するので、カレントディレクトリ名だけ表示するように修正する。

フルパスが確認したいときは、pwdを使う。

シェルの作成

MyDocumentsにWindowsPowerShellフォルダを作成
作成したフォルダ内に以下のファイルを作成

Microsft.PowerShell_profile.ps1

function global:prompt {
    $idx = $pwd.ProviderPath.LastIndexOf("\")+1

    Write-Host($pwd.ProviderPath.Remove(0, $idx)) -nonewline

    return "> "
}

これで、カレントディレクトリ名だけが表示される。

エラーが出る場合

下記を参考にする。
http://qiita.com/Kuchitama/items/6cdb29fcfd53b730aea7

16
9
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
9