Last active
June 25, 2021 04:17
-
-
Save haxpor/351fa1c4cdfe894d94d59ebb1dcd43cc to your computer and use it in GitHub Desktop.
Work with terminal application to open target file via vim
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
#!/bin/bash | |
# From https://pastebin.com/XSuXNJZs by StingyKarmaWhore and u/yramagicman (upstream https://www.reddit.com/r/godot/comments/b7ad4u/open_terminalvim_from_godot/eqtavz1/) | |
# Modifed by haxpor: auto read from external changes, getting rid of line, and properly target an existing file on server | |
[ -n "$1" ] && server=$1 | |
[ -n "$2" ] && file=$2 | |
serverlist=`echo $(vim --serverlist)` | |
echo ${serverlist,,} | |
if [[ ${serverlist,,} == *"${server,,}"* ]]; then | |
vim +'set autoread|au CursorHold * checktime' --servername $server --remote-tab-silent $file | |
else | |
vim +'set autoread|au CursorHold * checktime' --servername $server $file | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment