Skip to content

Instantly share code, notes, and snippets.

@salkin-mada
Last active November 21, 2020 13:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salkin-mada/b73129f1d287e83dbd97c7e7e42d5a8f to your computer and use it in GitHub Desktop.
Save salkin-mada/b73129f1d287e83dbd97c7e7e42d5a8f to your computer and use it in GitHub Desktop.
skim file content and edit with nvim
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