Bash style history in Power Shell

how bizarre

For those of us coming from the linux world, Power shell has a tempting assortment of linux like commands, however every so often it still feels like you are trapped in bizaro land and the commands don’t quite match up. Today was one of those days.

Bash has a great history command that will list all (or most) of your recent shell commands. In PoSH history (er ok it is Get-History under the hood) only gives you for your current session.

Fear not, there is a one-liner that will get you the history that you need and love:

Get-Content (Get-PSReadlineOption).HistorySavePath | tail -n 20

(this will get the text from your power shell history file and print the last 20 commands)

Leave a Reply

Your email address will not be published. Required fields are marked *