Synchronization of history when the ipython laptop and console are connected to the same core

My ipython notebook running on a remote server, i.e.

 ipython notebook --profile=nbserver 

which I handle from my local machine. In addition, I ssh to a remote server from my machine and run ipython console (terminal) on this server. I found the following command to work well:

 ipython console --existing \ ~/.config/ipython/profile_nbserver/security/kernel-*.json 

Now I am connected to the same remote kernel from two different clients (lets call them browser and terminal ). Everything works well, except for one annoying detail:

1) in browser , I type a=1

2) in terminal , I type b=2

3) in both clients I can see both commands using %history . But when I want to iterate over the history (in terminal ) using Up , it only displays the commands that were entered into the terminal, (i b=2 ). Similarly, I cannot use a + PageDown in the terminal to go back in history and find a command starting with a .

From what I understand, my two clients use two separate history.sqlite history files. But why does %history show all the commands?

Question: Is there a way to configure using one history.sqlite for both clients?

I believe that easy access to history is crucial. Moreover, I consider the use of both terminals and the browser as optional, they both have compromises and are best combined.

+6
source share
1 answer

You can set where the story is loaded, or by installing it on the terminal:

 ipython --HistoryManager.hist_file=$HOME/ipython_hist.sqlite 

or inside ipython configuration files:

 import os c.HistoryManager.hist_file=os.path.expanduser("~/ipython_hist.sqlite") 
+3
source

Source: https://habr.com/ru/post/973593/


All Articles