Created
July 25, 2021 15:06
-
-
Save ajitid/31bee3a7845093c29fb009f5b66caeb6 to your computer and use it in GitHub Desktop.
automate vim using neovim-remote
This file contains hidden or 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 jqdoprocessoneach | |
# https://stackoverflow.com/a/965106/7683365 | |
set -l old_file_path $argv[1] | |
set -l new_filename $argv[2]"."(echo $argv[1] | sed 's/.*\.//') | |
echo $old_file_path | |
# echo $new_filename | |
# sleep 1 | |
nvr --remote-send '<cmd>e '$old_file_path'<cr>' | |
sleep 1 | |
nvr --remote-send '<cmd>TSLspRenameFile<cr>' | |
nvr --remote-send '<c-w><c-w><c-w>' | |
nvr --remote-send $new_filename'<cr>' | |
sleep 3 | |
nvr --remote-send '<cmd>wa<cr>' | |
sleep 1 | |
end | |
function jqdo | |
if [ "$argv[1]" = "" ] | |
echo 'please give a filename to process' | |
return 1 | |
end | |
# take [["oldfilepath", "newfilenamewithoutextension"], ...] to | |
# ``` | |
# oldfilepath | |
# newfilenamewithoutextension | |
# ... | |
# ``` | |
cat $argv[1] | jq '.[] | map(.) | .[0],.[1]' | sed -e 's/^"//' -e 's/"$//' | xargs -n 2 -P 1 fish -c 'source s.fish; jqdoprocessoneach $argv' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run it, I used,
source s.fish
followed byjqdo a.json
. This script is renaming TS files using LSP to make sure its references are updated too.Example
a.json
: