How can I make command line history persistent in CMD and PowerShell?


MFaklis

New member
Local time
5:22 AM
Posts
2
Location
N 37° 47.932’ W 122° 24.038’
OS
Windows 11 Pro v.24H2 Build 26100.3476
Whenever I open CMD or PowerShell, I would like the command line history to reflect all previous sessions.
 

My Computer

System One

  • OS
    Windows 11 Pro v.24H2 Build 26100.3476
    Computer type
    Laptop
    Manufacturer/Model
    Framework 13
    CPU
    Intel Core Ultra Series 1
    Motherboard
    Framework
    Memory
    32 GB
I've never seen the Command Prompt save previous commands for years, retains in memory only as long as the Command Prompt stays open. Closing the window clears the memory of those commands. Pressing the Up arrow will restore or recall what is still in memory before closing the window.
 

My Computers

System One System Two

  • OS
    Win11 Pro RTM
    Computer type
    Laptop
    Manufacturer/Model
    Dell Vostro 3400
    CPU
    Intel Core i5 11th Gen. 2.40GHz
    Memory
    12GB
    Hard Drives
    256GB SSD NVMe M.2
  • Operating System
    Windows 11 Pro RTM x64
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Vostro 5890
    CPU
    Intel Core i5 10th Gen. 2.90GHz
    Memory
    16GB
    Graphics card(s)
    Onboard, no VGA, using a DisplayPort-to-VGA adapter
    Monitor(s) Displays
    24" Dell
    Hard Drives
    512GB SSD NVMe, 4TB Seagate HDD
    Browser
    Firefox, Edge
    Antivirus
    Windows Defender/Microsoft Security
cmd.exe does not save history between sessions, but you can use something like Clink as a replacement/enhancement.


PowerShell has this functionality via the PSReadLine module. There are lots of options related to history, so it's best to read over them yourself, because configuring it is definitely a matter of taste.


 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears

Latest Support Threads

Latest Tutorials

Back
Top Bottom