fzf preview script
This commit is contained in:
parent
3cc07734dc
commit
5eb0864916
14
.config/scripts/preview-file.sh
Executable file
14
.config/scripts/preview-file.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
if [[ -d $1 ]] ; then
|
||||||
|
echo "$(eza --tree --color=always $1 | head -200)"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
filename=$(basename -- "$1")
|
||||||
|
extension="${filename##*.}"
|
||||||
|
|
||||||
|
case "$extension" in
|
||||||
|
png|jpg|webp) echo "$(timg -p quarter -g50x50 $1)" ;;
|
||||||
|
7z|zip|gz) echo "$(7z l $1)" ;;
|
||||||
|
*) echo "$(bat -n --color=always --line-range :500 $1)" ;;
|
||||||
|
esac
|
||||||
|
|
5
.zshrc
5
.zshrc
@ -79,7 +79,7 @@ if command -v fd > /dev/null; then
|
|||||||
}
|
}
|
||||||
|
|
||||||
if command -v bat > /dev/null; then
|
if command -v bat > /dev/null; then
|
||||||
export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always --line-range :500 {}'"
|
export FZF_CTRL_T_OPTS="--preview '~/.config/scripts/preview-file.sh {}'"
|
||||||
fi
|
fi
|
||||||
if command -v eza > /dev/null; then
|
if command -v eza > /dev/null; then
|
||||||
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
|
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
|
||||||
@ -92,7 +92,8 @@ if command -v fd > /dev/null; then
|
|||||||
cd) fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
|
cd) fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
|
||||||
export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;;
|
export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;;
|
||||||
ssh) fzf --preview 'dig {}' "$@" ;;
|
ssh) fzf --preview 'dig {}' "$@" ;;
|
||||||
*) fzf --preview "--preview 'bat -n --color=always --line-range :500 {}'" "$@" ;;
|
timg) fzf --preview 'timg -p quarter -g50x50 {}' "$@" ;;
|
||||||
|
*) fzf --preview "~/.config/scripts/preview-file.sh $@" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user