LoginSignup
43
46

More than 5 years have passed since last update.

PowerShellの$profileに設定しておくと便利な定義

Last updated at Posted at 2014-02-19

$profileとは

powershell実行時に設定したいコマンドを記述するファイル。
> echo $profile でファイルパスが分かるから、存在しない場合は作成する。

> New-item –type file –force $profile

フォルダ移動のショートカット設定方法

powershellはフォルダ移動のaliasをshellのように %alias hoge= "cd fuga" と簡単にできないところがつらい。
しかし、以下のようにすることで近い動作は実現可能。

$profile 内で変数定義する

 $work = "C:\work" と定義すれば > cd $work で移動可能。

$profile 内で関数定義する

 function work(){cd "C:\work"} と定義すれば > work で移動可能

移動だけを目的としたら関数定義のほうがよいけど、よく参照するフォルダなら変数定義しておくと便利。

$profileの再読み込み

> . $profile で設定の再読み込み可能。

43
46
0

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
43
46