在全文搜索数据库中自动索引shell历史记录。魔术!
duiker的Python项目详细描述
在全文搜索数据库中自动索引shell历史记录。魔法!
功能
- 使用sqlite3的优秀FTS4 提供全文搜索的扩展名。
- 如果已设置,则尊重HISTTIMEFORMAT。
要求
- 猛击
- Python3
设置
导入您现有的shell历史:
history | duiker import -
配置
如果您想动态自动导入shell历史记录,则 可以将duiker import添加到PROMPT_COMMAND[1]
运行duiker magic打印自动导入的外壳代码段 最后一个进入duiker的命令:
duiker magic
将此shell片段配置为PROMPT_COMMAND的一部分。跑步 duiker magic --help例如。
搜索
Duiker在SQLite3全文搜索表中索引shell历史记录
您可以使用任何MATCH[2]表达式来搜索数据库:
$ duiker search git 2017-04-13 15:50:02 git staged 2017-04-13 15:50:14 git commit -a 2017-04-13 15:55:07 git diff
$ duiker search '(git OR fossil) diff' 2017-04-27 15:15:01 git diff 2017-04-27 15:15:49 git diff 2017-04-28 14:49:19 fossil diff 2017-04-28 14:53:09 fossil diff src/main.rs
$ duiker search 'sqlite*' 2017-03-04 19:00:42 sqlite3 db.sqlite 2017-03-04 19:13:11 rm db.sqlite
限制
duiker目前只支持bash。请求其他外壳 欢迎。
许可证
麻省理工学院
[1] | https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html#Controlling-the-Prompt |
[2] | https://sqlite.org/fts3.html#full_text_index_queries |