# HG changeset patch # User zegervdv # Date 1643297636 -3600 # Node ID 8e2e42add3af4c383dbfe143395e328e6852b1e4 # Parent b12e86e6c110c6280321d70949abecf74b593220 add zsh-histdb plugin diff -r b12e86e6c110 -r 8e2e42add3af .chezmoiexternal.toml --- a/.chezmoiexternal.toml Thu Jan 27 14:20:13 2022 +0100 +++ b/.chezmoiexternal.toml Thu Jan 27 16:33:56 2022 +0100 @@ -41,6 +41,18 @@ stripComponents = 1 refreshPeriod = "168h" +[".zsh/zsh-histdb"] + type = "archive" + url = "https://github.com/larkery/zsh-histdb/archive/master.tar.gz" + exact = true + stripComponents = 1 + refreshPeriod = "168h" + +[".zsh/fzf-histdb.zsh"] + type = "file" + url = "https://github.com/m42e/zsh-histdb-fzf/raw/master/fzf-histdb.zsh" + refreshPeriod = "168h" + [".zsh/completions/_fd"] type = "file" url = "https://github.com/sharkdp/fd/raw/master/contrib/completion/_fd" diff -r b12e86e6c110 -r 8e2e42add3af dot_zshrc --- a/dot_zshrc Thu Jan 27 14:20:13 2022 +0100 +++ b/dot_zshrc Thu Jan 27 16:33:56 2022 +0100 @@ -7,6 +7,21 @@ source ~/.zsh/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh +source ~/.zsh/zsh-histdb/zsh-histdb.plugin.zsh +source ~/.zsh/fzf-histdb.zsh + +_zsh_autosuggest_strategy_histdb_top_here() { + local query="select commands.argv from +history left join commands on history.command_id = commands.rowid +left join places on history.place_id = places.rowid +where places.dir LIKE '$(sql_escape $PWD)%' +and commands.argv LIKE '$(sql_escape $1)%' +group by commands.argv order by count(*) desc limit 1" + suggestion=$(_histdb_query "$query") +} + +ZSH_AUTOSUGGEST_STRATEGY=histdb_top_here + fpath=(~/.zsh/completions $fpath) export TERM=xterm-256color @@ -242,7 +257,9 @@ export BAT_CONFIG_PATH=$HOME/.config/bat/config [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh -export FZF_DEFAULT_COMMAND='ag -g ""' + +bindkey '^r' histdb-fzf-widget + [ -f ~/.zshrc.local ] && source ~/.zshrc.local # Must run after brew is loaded