not2qubit
not2qubit

Reputation: 16912

How to print the directory stack in powershell?

I want to print the recently visited directory stack to save it to a file for later retrieval. According to this powershell documentation for Get-Location, it should be possible with:

Get-Location -Stack

But that only seem to work if you have previously done a Push-Location, which I can't be bothered with. Because I know Powershell 7+ keep track of your stack without this. So I want to access the internal directory stack and print it out without having to use additional commands to save location every time I do a cd.

How can I print the full internal directory stack using Powershell?


Related answers:


UPDATE: 2020-10-13

Some of the code for the internal stack seem to be in SessionState.cs. There you will also notice the way too small stack size: locationHistoryLimit = 20;. It would be great to be able to change this, as a starter.

Upvotes: 0

Views: 552

Answers (1)

js2010
js2010

Reputation: 27428

rm alias:cd
set-alias cd push-location
cd ..
cd ~
pwd -stack

Path
----
C:\Users
C:\Users\me

Upvotes: 2

Related Questions