Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.32 KB | None | 0 0
  1. #!/bin/bash
  2. #Copyright 2011 LeoH. All rights reserved.
  3. #
  4. #Redistribution and use in source and binary forms, with or without
  5. #modification, are permitted provided that the following conditions are
  6. #met:
  7. #
  8. #   1. Redistributions of source code must retain the above copyright
  9. #   notice, this list of conditions and the following disclaimer.
  10. #
  11. #   2. Redistributions in binary form must reproduce the above
  12. #   copyright notice, this list of conditions and the following
  13. #   disclaimer in the documentation and/or other materials provided
  14. #   with the distribution.
  15. #
  16. #THIS SOFTWARE IS PROVIDED BY LeoH ``AS IS'' AND ANY
  17. #EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. #IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19. #PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LeoH OR
  20. #CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. #EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. #PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  23. #PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24. #LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  25. #NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. #SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. #
  28. #The views and conclusions contained in the software and documentation
  29. #are those of the authors and should not be interpreted as representing
  30. #official policies, either expressed or implied, of LeoH.
  31.  
  32. #-config: -----------------
  33. terminal=gnome-terminal
  34. caml=camllight
  35. execkey='ΓΉ'
  36. #---------------------------
  37.  
  38. FIFO=/tmp/vimcaml.fifo.$RANDOM
  39. mkfifo $FIFO || { echo error while generating $FIFO 1>&2; exit 1; }
  40. sleep inf > $FIFO &
  41. sleepPid=$!
  42. tty=$(tty)
  43.  
  44. vimcommand="bash -c \"
  45.     vim -c 'set filetype=ocaml' -c 'map $execkey :!echo -e \\\"\\n\\\" > $tty
  46. ma{V}:!cat > '$FIFO'
  47. u'\'a;
  48.     kill $sleepPid;
  49.     rm $FIFO;
  50. \""
  51. #explanation: the $execkey shortcut will send the current paragraph to camllight
  52. #:!echo -e \\\"\\n\\\" > $tty : prints a new line to camllight for clarity
  53. #ma : mark cursor position
  54. #{V} : select current paragraph
  55. #:!cat > '\"$FIFO\"' : send paragraph to camllight
  56. #u' : paragraph will have been deleted so undo
  57. #\'a : cursor position will have been lost so restore it
  58.  
  59. $terminal -e "$vimcommand"
  60. $caml < $FIFO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement