Closed rypervenche closed 3 years ago
This is a good user requirement, but I don't want to add it as a cicada feature. Because there are more shells, bash, fish, zsh, xonsh etc, they all have different history layouts.
However, I think we can add a cicada builtin or something to export a way to import history items. And draft a section in the manual to guide users how to import.
Just added a new command history add
to the builtin history
in v0.9.13. Now you can load bash history with a script like this:
#!/usr/local/bin/cicada
for x in $(sed 's/ /UNIQ_TOKEN_CICADA_SPACE/g' ~/.bash_history)
history add "$(echo ${x} | sed 's/UNIQ_TOKEN_CICADA_SPACE/ /g')" -t $(date +"%s")
done
Save above content to foo.sh
and run it with cicada foo.sh
will do the work.
If you have bash available, you can use the bash way:
#!/bin/bash
while IFS= read -r line; do
cicada -c "history add "${line}""
done < ~/.bash_history
(NOT fully tested these scripts)
Happy hacking!
It would be nice if, upon first run (i.e., the cicada history database does not yet exist), the user could be prompted to import their Bash history into the database. If no date exists for an entry then it would use the current timestamp, otherwise it would use the provided timestamp from the .bash_history file:
Example .bash_history with timestamps