Created
September 4, 2014 02:51
-
-
Save doloopwhile/b74600367198c765bc37 to your computer and use it in GitHub Desktop.
A script to open file in gvim (suport "/path/to/file:42" format)
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
#!/bin/bash | |
# | |
# open-gvim.sh | |
# | |
# - Open a file with gvim | |
# - If there is running gvim open file in there. | |
# - Open "path with line number" (like "/path/to/file:42" printed in grep and etc.) | |
if [ "$#" -eq 0 ]; then | |
if vim --serverlist | grep -q GVIM; then | |
vim -g --servername GVIM --remote-expr 'foreground()' 2>/dev/null | |
else | |
vim -g --servername GVIM 2>/dev/null &! | |
fi | |
else | |
for f in "$@"; do | |
vim -g --servername GVIM --remote-tab-silent \ | |
$(echo "$f" | sed -e "s|\(.*\):\([[:digit:]]\+\)|+\2 \1|") \ | |
2>/dev/null &! | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment