historian icon indicating copy to clipboard operation
historian copied to clipboard

Support for zsh

Open teranex opened this issue 8 years ago • 8 comments

Support for zsh would be a very welcome addition ;)

teranex avatar Apr 16 '17 18:04 teranex

#2 might be of use to you; I've added overridable HISTORIAN_SRC and such in https://github.com/jcsalterego/historian/commit/05f3fa892544d4180ef346e0a3e9d18675c8f90a.

jcsalterego avatar Apr 16 '17 18:04 jcsalterego

Yes, #2 works indeed! :)

The only small problem I have is that historian doesn't really seem to handle EXTENDED_HISTORY (http://zsh.sourceforge.net/Doc/Release/Options.html#History).

My history looks like this:

$ tail $HISTFILE
: 1492369835:0;hist import
: 1492369844:0;hist /hist import
: 1492369861:0;hist shell
: 1492369868:0;hist version
: 1492369908:0;hist /hist
: 1492370096:0;history
: 1492370103:0;man history
: 1492370245:0;history-stat
: 1492370604:0;vi $HISTFILE
: 1492370674:0;tail $HISTFILE

And historian imports each line in it's entirety. This is not a big problem, except that it breaks deduplication (?):

$ hist /hist import
4194
	: 1492369835:0;hist import
4192
	: 1492369830:0;hist import
4188
	: 1492369810:0;hist import
4183
	: 1492369760:0;hist import
4181
	: 1492369659:0;hist import

teranex avatar Apr 16 '17 19:04 teranex

Aha, interesting. Thanks for the documentation and specific use-case. I'll have to give some thought about how to support that.

jcsalterego avatar Apr 16 '17 19:04 jcsalterego

@teranex Will you give #7 a shot? Granted, it's a very specific solution for a specific problem, but I hope this will be useful.

jcsalterego avatar Apr 17 '17 04:04 jcsalterego

#7 seems to work indeed, although I get some warnings:

/tmp/jeroen/tmp.rjTGU4eAeC/.zhistory:1813: expected 2 columns but found 1 - filling the rest with NULL
/tmp/jeroen/tmp.rjTGU4eAeC/.zhistory:1817: expected 2 columns but found 1 - filling the rest with NULL
/tmp/jeroen/tmp.rjTGU4eAeC/.zhistory:2086: unescaped " character
/tmp/jeroen/tmp.rjTGU4eAeC/.zhistory:2087: unescaped " character
....
Imported 4126 item(s).

But history is imported correctly :)

$ hist /hist import
4061
	hist /hist import
4051
	hist import

teranex avatar Apr 17 '17 18:04 teranex

Hrm interesting. Any chance you could provide those lines in .zhistory (scrubbing for sensitive material, etc)?

jcsalterego avatar Apr 17 '17 18:04 jcsalterego

Looking at my .zhistory I see the problem for the expected 2 columns but found 1: multi-line commands. (I guess those are possible in bash as well?). This is seen as 2 lines, but is actually one command.

: 1476438442:0;chmod +x drush\  
sudo mv drush /usr/local/bin

The second warning is triggered by a line such as:

: 1477165360:0;"/usr/lib/thunderbird/thunderbird" -thunderlink  'thunderlink://[email protected]'

teranex avatar Apr 17 '17 18:04 teranex

Very interesting. The import process can only handle one line at a time (per sqlite's .import function) so multi-lines are definitely tricky. IIRC, Bash strips backslashes & newlines.

jcsalterego avatar Apr 17 '17 18:04 jcsalterego

@teranex (Years later) Is this still a desired feature, or did you move on? :)

jcsalterego avatar Feb 08 '23 18:02 jcsalterego

haha not, but thx for asking :)

teranex avatar Feb 08 '23 20:02 teranex

@teranex OK thanks!

jcsalterego avatar Feb 08 '23 20:02 jcsalterego