4
2

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 1 year has passed since last update.

Windows で history コマンドっぽいものが使いたい

Last updated at Posted at 2020-03-22

1. 使用

使い方は、以下の通りです。history の頭に cat $ がつきます。

cat $history

例えば、ある単語 foo を検索したい場合は

cat $history | grep foo

2. 設定

Step 1. $profile を開きます。

notepad $profile

Step 2. 以下の内容を追記します。

$history="C:\Users\{ユーザ名}\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt"
Set-Alias grep Select-String

Step 3. ターミナルを再起動します。

3. 補足

$profile は sh の ~/.profile や bash の ~/.bashrc に該当するような感じです。

Set-Alias はファイルパスには使用できなかったので、変数に代入する形にしました。

Get-Alias で既に設定されているエイリアスを確認することもできます。

4
2
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?