Add alias ff and ffz for fzf and fzf into vim
This commit is contained in:
2
.bashrc
2
.bashrc
@@ -73,6 +73,8 @@ alias markdown_pdf="docker run --rm -v \$PWD:/opt/docs auchida/markdown-pdf mark
|
|||||||
alias vimwiki='vim -c VimwikiIndex -c "cd %:p:h" -c "silent Git pull"'
|
alias vimwiki='vim -c VimwikiIndex -c "cd %:p:h" -c "silent Git pull"'
|
||||||
alias wiki='vim -c VimwikiIndex -c "cd %:p:h" -c "silent Git pull"'
|
alias wiki='vim -c VimwikiIndex -c "cd %:p:h" -c "silent Git pull"'
|
||||||
alias g=goto
|
alias g=goto
|
||||||
|
alias ff="fd | fzf --preview 'my-cli-preview {}'"
|
||||||
|
alias ffv="ff | xargs vim"
|
||||||
|
|
||||||
if [ -f .local/bin/lessfilter ]
|
if [ -f .local/bin/lessfilter ]
|
||||||
then
|
then
|
||||||
|
|||||||
50
.local/bin/my-cli-preview
Executable file
50
.local/bin/my-cli-preview
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
file="$1"
|
||||||
|
|
||||||
|
print_repeated() {
|
||||||
|
local char="$1"
|
||||||
|
local lines="$2"
|
||||||
|
local columns="$3"
|
||||||
|
local linebreak="$4"
|
||||||
|
for i in `seq 1 $lines`
|
||||||
|
do
|
||||||
|
for j in `seq 1 $columns`
|
||||||
|
do
|
||||||
|
echo -n "$char"
|
||||||
|
done
|
||||||
|
echo -en "$linebreak"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
mime="$(file -b --mime-type $file)"
|
||||||
|
type="$(echo $mime | cut -d/ -f1)"
|
||||||
|
|
||||||
|
if [ "$type" = "image" ] || [ "$mime" = "application/pdf" ]
|
||||||
|
then
|
||||||
|
if [ "$TERM" = "xterm-kitty" ] || [ "$TERM" = "xterm-ghostty" ]
|
||||||
|
then
|
||||||
|
exec kitten icat --clear --transfer-mode=memory --stdin=no --place=$(($FZF_PREVIEW_COLUMNS))x$(($FZF_PREVIEW_LINES-1))@$(($COLUMNS/2))x2 "$file"
|
||||||
|
else
|
||||||
|
which viu >/dev/null && exec viu -s -w $FZF_PREVIEW_COLUMNS "$file"
|
||||||
|
if [ "$mime" = "image/svg+xml" ]
|
||||||
|
then
|
||||||
|
exec batcat --color=always -pp "$file"
|
||||||
|
else
|
||||||
|
print_repeated "╱" $(($FZF_PREVIEW_LINES/2-2)) $FZF_PREVIEW_COLUMNS "\n"
|
||||||
|
print_repeated "╱" 1 $(($FZF_PREVIEW_COLUMNS/2-15)) ""
|
||||||
|
print_repeated " " 1 30 ""
|
||||||
|
print_repeated "╱" 1 $(($FZF_PREVIEW_COLUMNS/2-15)) "\n"
|
||||||
|
print_repeated "╱" 1 $(($FZF_PREVIEW_COLUMNS/2-15)) ""
|
||||||
|
echo -n " Binary cannot be previewed "
|
||||||
|
print_repeated "╱" 1 $(($FZF_PREVIEW_COLUMNS/2-15)) "\n"
|
||||||
|
print_repeated "╱" 1 $(($FZF_PREVIEW_COLUMNS/2-15)) ""
|
||||||
|
print_repeated " " 1 30 ""
|
||||||
|
print_repeated "╱" 1 $(($FZF_PREVIEW_COLUMNS/2-15)) "\n"
|
||||||
|
print_repeated "╱" $(($FZF_PREVIEW_LINES/2-1)) $FZF_PREVIEW_COLUMNS "\n"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
kitten icat --clear --transfer-mode=memory --stdin=no
|
||||||
|
kitten icat --clear --transfer-mode=memory --stdin=no
|
||||||
|
exec batcat --color=always -pp "$file"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user