dotfiles/modules/common/shell/fish/functions/search-and-edit.fish

22 lines
685 B
Fish
Raw Permalink Normal View History

2022-06-20 19:49:25 +00:00
set vimfile ( \
2022-06-20 19:20:20 +00:00
rg \
--color=always \
--line-number \
--no-heading \
--smart-case \
2022-06-20 19:49:25 +00:00
--iglob "!/Library/**" \
--iglob "!/System/**" \
2022-06-20 19:20:20 +00:00
--iglob "!Users/$HOME/Library/*" \
2022-06-20 19:49:25 +00:00
".*" \
2022-06-20 19:20:20 +00:00
| fzf --ansi \
2022-06-20 19:49:25 +00:00
--height "80%" \
2022-06-20 19:20:20 +00:00
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--delimiter : \
--preview 'bat --color=always {1} --highlight-line {2}' \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'
)
2022-07-22 13:49:21 +00:00
and set line_number (echo $vimfile | tr -d '\r' | cut -d':' -f2)
2022-06-20 19:49:25 +00:00
and set vimfile (echo $vimfile | tr -d '\r' | cut -d':' -f1)
2022-07-22 13:49:21 +00:00
and commandline -r "vim +$line_number $vimfile"
2022-06-20 19:20:20 +00:00
and commandline -f execute