Last active
November 21, 2020 13:41
-
-
Save salkin-mada/b73129f1d287e83dbd97c7e7e42d5a8f to your computer and use it in GitHub Desktop.
skim file content and edit with nvim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function skimcode() { | |
local cmd='rg -S -n --color=always "{}"' | |
local pcmd='export LINE_NR=$(echo {} | awk -F: '"'"'{print $2}'"'"') && echo {} | sed "s/:.*//" | xargs -d "\n" bat -f -H $LINE_NR' | |
sk --ansi -i -c $cmd --preview $pcmd \ | |
--bind 'ctrl-e:execute[export LINE_NR=$(echo {} | awk -F: '"'"'{print $2}'"'"') && nvim +$LINE_NR $(echo {} | sed "s/:.*//")]' \ | |
--bind 'enter:execute(echo {} | sed "s/:.*//")+abort' | |
} | |
alias skc='skimcode' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment