From dea76cfaab1f8783859719fda7788699ca30e2a0 Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Mon, 10 Jul 2023 12:31:40 +0200 Subject: [PATCH] changes to fzf, batcat --- batcat.zsh | 9 +++++++++ fzf.sh | 17 ----------------- fzf.zsh | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 batcat.zsh delete mode 100644 fzf.sh create mode 100644 fzf.zsh diff --git a/batcat.zsh b/batcat.zsh new file mode 100644 index 0000000..2640bbb --- /dev/null +++ b/batcat.zsh @@ -0,0 +1,9 @@ +alias bathelp='bat --plain --language=help' +unalias help +help() { + "$@" --help 2>&1 | bathelp +} + +batdiff() { + git diff --name-only --relative --diff-filter=d | xargs bat --diff +} diff --git a/fzf.sh b/fzf.sh deleted file mode 100644 index dc97ead..0000000 --- a/fzf.sh +++ /dev/null @@ -1,17 +0,0 @@ -export FZF_COMPLETION_OPTS='--border --info=inline' - -# (EXPERIMENTAL) Advanced customization of fzf options via _fzf_comprun function -# - The first argument to the function is the name of the command. -# - You should make sure to pass the rest of the arguments to fzf. -_fzf_comprun() { - local command=$1 - shift - - case "$command" in - vim) fzf "$@" --preview 'batcat --color=always {}' ;; - cd) fzf "$@" --preview 'tree -C {} | head -200' ;; - export|unset) fzf "$@" --preview "eval 'echo \$'{}" ;; - ssh) fzf "$@" --preview 'dig {}' ;; - *) fzf "$@" ;; - esac -} diff --git a/fzf.zsh b/fzf.zsh new file mode 100644 index 0000000..9ff9b0f --- /dev/null +++ b/fzf.zsh @@ -0,0 +1,18 @@ +export FZF_COMPLETION_OPTS='--border --info=inline' +source /usr/share/doc/fzf/examples/completion.zsh +source /usr/share/doc/fzf/examples/key-bindings.zsh +# (EXPERIMENTAL) Advanced customization of fzf options via _fzf_comprun function +# - The first argument to the function is the name of the command. +# - You should make sure to pass the rest of the arguments to fzf. +_fzf_comprun() { + local command=$1 + shift + + case "$command" in + vim|nvim|nano) fzf "$@" --preview 'batcat --color=always {}' ;; + cd) fzf "$@" --preview 'tree -C {} | head -200' ;; + export|unset) fzf "$@" --preview "eval 'echo \$'{}" ;; + ssh) fzf "$@" --preview 'dig {}' ;; + *) fzf "$@" ;; + esac +}