Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " for screen use
- " opened in another screen? lets not play where's waldo anymore!
- " this will politely tell me which screen's window it is open in so that I may
- " go close it if I want, but still provide me the normal options
- "
- augroup NoSimultaneousEdits
- autocmd!
- autocmd SwapExists * :call JoshLeeMadeThis()
- augroup END
- function! JoshLeeMadeThis ()
- let fname = expand("%:p")
- let my_command = "/usr/sbin/lsof | grep '" . fname . ".swp' | grep " . $USER . " | sed -n 's/^vim\\? \\+\\([0-9]\\+\\).*$/\\1/p' "
- let result = substitute(system(my_command), '\n','','')
- if result
- let my_cmd2 = "cat /proc/" . result . "/environ | xargs -0 echo | sed -n 's/.*WINDOW=\\([0-9]*\\).*/\\1/p' "
- let res2 = substitute(system(my_cmd2), '\n','','')
- if res2
- echo 'This file is already opened in window: ' . res2
- endif
- endif
- endfunction
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement