2017-04-25 12:12:39 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../tmp && pwd )"
|
|
|
|
|
|
|
|
SOCKET="$DIR"/file_change.sock
|
|
|
|
|
|
|
|
if [[ -e "$SOCKET" ]]; then
|
2020-12-09 14:29:13 -05:00
|
|
|
if command -v socat &> /dev/null; then
|
2020-10-13 12:03:24 -04:00
|
|
|
echo "$1 $2" | socat - UNIX-CONNECT:$SOCKET >/dev/null 2>/dev/null
|
|
|
|
else
|
|
|
|
echo "$1 $2" | nc -U $SOCKET >/dev/null 2>/dev/null
|
|
|
|
fi
|
2017-04-25 12:12:39 -04:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
rm $SOCKET
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# To enable:
|
|
|
|
#
|
|
|
|
# 1. Install socat
|
|
|
|
# 2. Add VIM_AUTOSPEC=1 to your environment
|
|
|
|
# 3. Add the following to your .vimrc
|
|
|
|
#
|
2019-05-02 23:50:47 -04:00
|
|
|
|
|
|
|
# function! s:notify_file_change_discourse()
|
|
|
|
# let notify = getcwd() . "/bin/notify_file_change"
|
|
|
|
# if ! executable(notify)
|
|
|
|
# let root = rails#app().path()
|
|
|
|
# notify = root . "/bin/notify_file_change"
|
|
|
|
# end
|
2017-04-25 12:12:39 -04:00
|
|
|
# if executable(notify)
|
|
|
|
# if executable('socat')
|
|
|
|
# execute "!" . notify . ' ' . expand("%:p") . " " . line(".")
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# endfunction
|
|
|
|
|
|
|
|
# autocmd BufWritePost * silent! call s:notify_file_change()
|
|
|
|
|
|
|
|
# What this does?
|
|
|
|
#
|
|
|
|
# bin/rake autospec will now automatically try running specs where the actual cursor is located first, then fall back to running spec file
|