-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelix-commands
executable file
·38 lines (35 loc) · 1.1 KB
/
helix-commands
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
36
37
#!/bin/sh
command="$1"
param="$2"
fullpath=$(echo "$param" | sed "s#~#$HOME#" | sed "s#\(^[^/]\)#$PWD/\\1#")
filename=$(basename $fullpath)
basedir=$(dirname "$fullpath")
line="$3"
col="$4"
case "$command" in
"getfileinfo")
sleep 0.1
zellij action dump-screen /tmp/zdump
cat /tmp/zdump | rg -e "(?:NORMAL|INSERT|SELECT)\s+[a-zA-Z0-9/.~_\-\(\)\[\]]+\s+([a-zA-Z0-9/.~_\-\(\)\[\]]+)\s+(?:\[\+\])?\s+(?:●\s+\d+\s+)?\d+\s+sels?\s+(\d+):(\d+)" -o --replace '$1 $2 $3'
rm /tmp/zdump
;;
"copy")
echo $param | cliphist store
;;
"blame")
zellij run -f -c --name Blame -- tig -C $basedir blame +$line -- $filename
;;
"git")
zellij run -f -c --name LazyGit -- lazygit
;;
"explorer")
zellij run -c -f --name FileManager -- sh -c "HELIX=1 yazi \"$basedir\""
;;
"edit")
zellij action toggle-floating-panes
zellij action write 27
zellij action write-chars ":open $param"
zellij action write 13
zellij action toggle-floating-panes
zellij action write-chars "q"
esac