Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash command history is not written when a window is closed

I found that the "bash for ubuntu for windows" installed on my laptop cannot load the command history once I reboot the "bash for ubuntu for windows".

More precisely, if I open the terminal, and input some commands, then all commands I inputted in this terminal session can be found by the arrow keys. But if I close (by clicking the "x" on the up right corner) the terminal and reopen it, I cannot find any command I typed before by the arrow keys.

Does anyone have any ideas about this?

Thank you very much.

like image 462
Minky J Avatar asked Aug 22 '17 13:08

Minky J


1 Answers

You need to leave the shell by typing exit or Ctrl+d rather than just closing the window. exit will write the history implicitly, you can explicitly trigger a history write with history -w at any time.

like image 137
hek2mgl Avatar answered Sep 28 '22 06:09

hek2mgl