This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to know which are all the commands used in the past (in Anaconda prompt in Windows 10) ?

Hi. Is there a command that allows you to know which are all the commands that a user has typed in Anaconda prompt in Windows 10 ?

For example, in Linux (Ubuntu) I was used to know this just by clicking the arrow pointing up on the keyboard once opened the terminal. In this way I have one by one all the commands used in the past.

In Windows 10 this does not work :( how can I do ?

I hope that this question is suitable for this website and that I have been clear. Thank you in advance.

Manuela.

prompt commands windows anaconda

What is an anaconda prompt? Just windows command line prompt?

I haven't tested these and check if any of following commands work:

  1. doskey /history (in cmd cli)
  2. %userprofile%/.python_history (user profile is yours and open the file with a text pad/notepad)
  3. import readline; print('\n'.join([str(readline.get_history_item(i + 1)) for i in range(readline.get_current_history_length())])) (copy/paste this line and press enter)

1 answer

The word that describes the feature is "command history", the up-arrow key does work on Windows as well as long as the shell is open.

But, unlike Linux, it seems that Windows does not save the history once the terminal is closed (I am not on my Windows machine and I can't check) but this is what I found:

https://serverfault.com/questions/95404/is-there-a-global-persistent-cmd-history

Windows PowerShell (included in recent versions of windows) does save history of past commands (but can't be used for anaconda based on comment below).

Alas, the anaconda prompt relies on the traditional command-line prompt.

It is basically a command-line terminal shortcut that has all the paths set to properly work with Anaconda.

Thank you all... I searched better and it seems there is a command to know this that is grep -B1 "^# cmd" my_env/conda-meta/history (I found in StackOverflow) but I have problems in installing grep.

Log in to answer this question.