Reputation: 388
For some reason, in an ipython shell I use, I can find certain commands but it doesn't care to complete them.
Examples are:
hist -g bla
gives me the following history line:
659/1: import os as bla
which works with
rerun 659/1
but when I type
import os as
and then hit the up arrow, it refuses to complete the line, even though the hist command clearly finds it.
What could be the cause for this? Is there a way for me to recover the commands other than manually using hist -g for each and copy pasting it anew into the terminal?
The up arrow DOES complete more recent commands, even though the length should be big enough (10000 lines) to complete the earlier ones too.
UPDATE: Tried creating a CLEAN history.sqlite file from scratch, and history.store_inputs for each line on all the commands, still doesn't complete certain commands while DOES complete others...
Upvotes: 1
Views: 278
Reputation: 388
TL;DR version:
ipython has a separate configuration for lines stored in history as opposed to lines used for code completion which it loads, I created an ipython configuration file and had to manually raise the number for the loaded completion lines:
c.InteractiveShell.history_load_length = 50000
Here's the full story:
ipython actually has 2 separate configs that affect code completion.
One for how much history to store (which for some reason stored over the defined number for me). The other and more important one - is the amount of lines to LOAD AT STARTUP which is what it actually uses for command completion.
To see those two values I had to run:
%config TerminalInteractiveShell.history_load_length
%config TerminalInteractiveShell.history_length
and to change it I had to run two commands (had no configuration profile before it):
ipython profile create
Which creates the default ipython_config.py file at the path
~/.ipython/profile_default/ipython_config.py
If you don't know where your profile is you can run
ipython locate profile default
To get the full path to it and find the config file.
Last thing you need to do is uncomment and edit the line:
c.InteractiveShell.history_load_length = 50000
I personally put 50000 hoping I'll never hit this, but up to you of course.
The default was 1000 for me.
Upvotes: 4