Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 1.02 KB | None | 0 0
  1.  
  2. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  3. " for screen use
  4. " opened in another screen? lets not play where's waldo anymore!
  5. " this will politely tell me which screen's window it is open in so that I may
  6. " go close it if I want, but still provide me the normal options
  7. "
  8. augroup NoSimultaneousEdits
  9.     autocmd!
  10.     autocmd SwapExists * :call JoshLeeMadeThis()
  11. augroup END
  12.  
  13. function! JoshLeeMadeThis ()
  14.   let fname = expand("%:p")
  15.   let my_command = "/usr/sbin/lsof | grep '" . fname . ".swp' | grep " . $USER . " | sed -n 's/^vim\\? \\+\\([0-9]\\+\\).*$/\\1/p' "
  16.   let result = substitute(system(my_command), '\n','','')
  17.   if result
  18.     let my_cmd2 = "cat /proc/" . result . "/environ | xargs -0 echo | sed -n 's/.*WINDOW=\\([0-9]*\\).*/\\1/p' "
  19.     let res2 = substitute(system(my_cmd2), '\n','','')
  20.     if res2
  21.       echo 'This file is already opened in window: ' . res2
  22.     endif
  23.   endif
  24. endfunction
  25.  
  26. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement