mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
feat(zsh): add atuin+fzf for enhanced command history
This commit is contained in:
@@ -89,6 +89,7 @@ ruby_install = true
|
|||||||
actionlint = "latest"
|
actionlint = "latest"
|
||||||
argo-rollouts = "latest"
|
argo-rollouts = "latest"
|
||||||
argocd = "latest"
|
argocd = "latest"
|
||||||
|
atuin = "latest"
|
||||||
aws-cli = "latest"
|
aws-cli = "latest"
|
||||||
bat = "latest"
|
bat = "latest"
|
||||||
bat-extras = "latest"
|
bat-extras = "latest"
|
||||||
|
|||||||
62
zsh/atuin.zsh
Normal file
62
zsh/atuin.zsh
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#
|
||||||
|
# atuin
|
||||||
|
#
|
||||||
|
|
||||||
|
if command-exists atuin; then
|
||||||
|
# Atuin + FZF integration, stolen/adapted from:
|
||||||
|
# - https://github.com/atuinsh/atuin/issues/68
|
||||||
|
atuin-setup() {
|
||||||
|
if ! which atuin &>/dev/null; then return 1; fi
|
||||||
|
bindkey '^E' _atuin_search_widget
|
||||||
|
|
||||||
|
export ATUIN_NOBIND="true"
|
||||||
|
eval "$(atuin init zsh)"
|
||||||
|
|
||||||
|
zle -N fzf-atuin-history-widget
|
||||||
|
bindkey '^R' fzf-atuin-history-widget
|
||||||
|
}
|
||||||
|
|
||||||
|
fzf-atuin-history-widget() {
|
||||||
|
local selected num
|
||||||
|
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2>/dev/null
|
||||||
|
|
||||||
|
# local atuin_opts="--cmd-only --limit ${ATUIN_LIMIT:-5000}"
|
||||||
|
local atuin_opts="--cmd-only"
|
||||||
|
local fzf_opts=(
|
||||||
|
# from $FZF_DEFAULT_OPTS
|
||||||
|
--bind=ctrl-k:kill-line
|
||||||
|
--bind=ctrl-v:half-page-down
|
||||||
|
--bind=alt-v:half-page-up
|
||||||
|
--tabstop=4
|
||||||
|
--highlight-line
|
||||||
|
|
||||||
|
# from $FZF_CTRL_R_OPTS
|
||||||
|
--tmux=75%
|
||||||
|
--border=rounded
|
||||||
|
"--preview=echo {}"
|
||||||
|
--preview-window=down:3:hidden:wrap
|
||||||
|
"--bind=ctrl-/:toggle-preview"
|
||||||
|
"--bind=ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort"
|
||||||
|
|
||||||
|
--tac
|
||||||
|
"-n2..,.."
|
||||||
|
--tiebreak=index
|
||||||
|
"--query=${LBUFFER}"
|
||||||
|
"+m"
|
||||||
|
"--bind=ctrl-r:reload(atuin search $atuin_opts)"
|
||||||
|
)
|
||||||
|
|
||||||
|
selected=$(atuin search ${atuin_opts} | fzf "${fzf_opts[@]}")
|
||||||
|
local ret=$?
|
||||||
|
if [ -n "$selected" ]; then
|
||||||
|
# the += lets it insert at current pos instead of replacing
|
||||||
|
LBUFFER+="${selected}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
zle reset-prompt
|
||||||
|
return $ret
|
||||||
|
}
|
||||||
|
|
||||||
|
atuin-setup
|
||||||
|
setup-completions atuin "$(mise-which atuin)" atuin gen-completions --shell zsh
|
||||||
|
fi
|
||||||
1
zshrc
1
zshrc
@@ -309,6 +309,7 @@ if [[ "$OSTYPE" == "linux"* ]]; then source "$DOTZSH/linux.zsh"; fi
|
|||||||
# Utils
|
# Utils
|
||||||
source "$DOTZSH/1password.zsh"
|
source "$DOTZSH/1password.zsh"
|
||||||
source "$DOTZSH/ansi.zsh"
|
source "$DOTZSH/ansi.zsh"
|
||||||
|
source "$DOTZSH/atuin.zsh"
|
||||||
source "$DOTZSH/copilot.zsh"
|
source "$DOTZSH/copilot.zsh"
|
||||||
source "$DOTZSH/emacs.zsh"
|
source "$DOTZSH/emacs.zsh"
|
||||||
source "$DOTZSH/cursor.zsh"
|
source "$DOTZSH/cursor.zsh"
|
||||||
|
|||||||
Reference in New Issue
Block a user