> I thought that there was a Sage history file somewhere where the last 
command I gave would be stored but if there is (as I know there is) it 
seems to be unreadable. I think it is in 
.sage/ipython-*/profile_default/history.sqlite. 

I've never actually tried this, but you're right, it'll be there. And I 
just tested and it seems to update immediately, even in the middle of 
executing long-running sage commands. Reading it depends on your preferred 
sqlite parser.

For instance, in the `sqlite3` command line tool,  you can run `sqlite3 
path/to/history.sqlite`. You can then enter a query like

    SELECT * FROM history;

Depending on your sage usage, this might be tremendously long and 
inconvenient, but this is the basic idea. Default ordering will output 
commands from more recent sage sessions later, so it might be possible that 
running this and scanning the last few entries might work. A slightly more 
sophisticated use might be to use `sqlite3 path/to/history.sqlite "SELECT * 
FROM history" | grep -C5 <somethinginyourcommand>`. This runs the single 
SELECT command, pipes it to grep, and then you can examine.

Of course if you've run many similar commands afterwards, this might not be 
very effective. It might be necessary to actually leverage the structure of 
the database. For example, if it was actually the last sage command you've 
run, you could do something like

    SELECT * FROM history ORDER BY  session DESC LIMIT 1;

The schema of the history table can be seen with `.schema history` (note 
the period before schema and the lack of a semicolon). This will indicate 
that the history table contains a session integer, a line integer, the 
source text, and the raw source text.

Good luck! - DLD

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/12eae0f9-9e28-4e8e-8187-a9c91f0b9f87n%40googlegroups.com.

Reply via email to