diff options
| -rw-r--r-- | fzf/fzfrc | 4 | ||||
| -rwxr-xr-x | scripts/preview | 38 | ||||
| -rw-r--r-- | zsh/zshfzf | 11 |
3 files changed, 53 insertions, 0 deletions
diff --git a/fzf/fzfrc b/fzf/fzfrc new file mode 100644 index 0000000..ae1f599 --- /dev/null +++ b/fzf/fzfrc @@ -0,0 +1,4 @@ +--color='fg:-1,bg:-1,hl:#438566' +--color='fg+:#cfc797,bg+:#003136,hl+:#7ba47d' +--color='info:#908b69,prompt:#732d35,pointer:#e4a44d' +--color='marker:#438566,spinner:#e4a44d,header:#7ba47d' diff --git a/scripts/preview b/scripts/preview new file mode 100755 index 0000000..2528082 --- /dev/null +++ b/scripts/preview @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +path="$1" +lines="$2" + +# TODO: if lines is undefined set to 40 +# TODO: truncate long output to lines + +[ ! -e "$path" ] && { echo "$path not found" ; exit 1; } + +filetype=$(file -b "$path") + +if grep -q "text" <<< "$filetype"; then + filetype="text" +elif grep -q "archive" <<< "$filetpye"; then + filetype="archive" +elif grep -q "ISO" <<< "$filetype" ; then + filetype="iso" +fi + +case $filetype in + "directory") + fd . "$path" + ;; + "text") + bat -p -r ":$lines" --color=always "$path" + ;; + "archive") + echo "archive preview not currently supported" + file -b "$path" + ;; + "iso") + isoinfo -l -i "$path" | head -n "$lines" + ;; + *) + file -b "$path" + ;; +esac diff --git a/zsh/zshfzf b/zsh/zshfzf new file mode 100644 index 0000000..ff6e061 --- /dev/null +++ b/zsh/zshfzf @@ -0,0 +1,11 @@ +source <(fzf --zsh) + +fzf_widget() { + BUFFER=$(fd | fzf --multi --scheme=path\ + --preview 'preview {} $FZF_PREVIEW_LINES' --preview-label='File Preview') + CURSOR=$#BUFFER + zle redisplay +} +zle -N fzf_widget + +bindkey '^f' fzf_widget |
