-
Notifications
You must be signed in to change notification settings - Fork 1
/
bin
executable file
·35 lines (31 loc) · 913 Bytes
/
bin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
set -euo pipefail; IFS=$'\n\t'
PREVIEW='
NUM={2}
NUM=${NUM%?}
BEGIN=$((NUM > LINES/2 ? NUM - LINES/2 + 1 : 1))
END=$((BEGIN + LINES - 1))
'
# bat이 없을경우 sed를 bat 대신 사용한다.
if [ -x "$(command -v bat)" ]; then
PREVIEW=$PREVIEW'
bat -ppH$NUM --color=always -r$BEGIN:$END {1}
'
else
PREVIEW=$PREVIEW'
if (( NUM > 1 )); then
sed -n "$((BEGIN)),$((NUM-1))p" {1}
fi
printf "\e[33m"
sed -n "$((NUM))p" {1}
printf "\e[0m"
sed -n "$((NUM+1)),$((END))p" {1}
'
fi
ARGS=$(
SHELL=/bin/bash rg --no-config -nH0 --color=always '\A' -r'🌏🔥🐸🐹😂😍😘 ' |
fzf -m -d'\0|🌏🔥🐸🐹😂😍😘' -n'2..' --with-nth='1,3..' \
--ansi --color=border:0 --layout=reverse --preview="${PREVIEW}" |
rg --no-config -a '\A(.*)\x00(.*):🌏🔥🐸🐹😂😍😘(.*)$' -r'+"tabnew +$2 $1"'
)
eval exec vim ${ARGS} +1tabclose