2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PowerShell でなんちゃって自作 export コマンド

Posted at

Windows と Linux を行き来しているとコマンドの違いがめんどくさい。

環境変数を設定するときに、Windows 環境でもつい export コマンド使いそうになるので、いっそそれっぽく使えるよう PowerShell Profile に function 用意してみた。

function export() {
    ($key, $value) = $args[0] -split "=";
    set-item "env:${key}" $value;
}

function unset() {
    $key = $args[0];
    remove-item "env:${key}";
}

これで、Windows でも export コマンドが使えて便利。

PS> # 環境変数を設定する
PS> export HOGE=hogehoge
PS> 
PS> # 動作確認
PS> echo $env:HOGE
hogehoge
PS> 
PS> # 環境変数を削除する
PS> unset HOGE
2
4
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
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?