Guest User

Untitled

a guest
Jan 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. diff --git a/window-copy.c b/window-copy.c
  2. index b49be33..9537ad5 100644
  3. --- a/window-copy.c
  4. +++ b/window-copy.c
  5. @@ -23,6 +23,7 @@
  6.  
  7. #include "tmux.h"
  8.  
  9. +void to_pasteboard(char *buf);
  10. struct screen *window_copy_init(struct window_pane *);
  11. void window_copy_free(struct window_pane *);
  12. void window_copy_resize(struct window_pane *, u_int, u_int);
  13. @@ -143,6 +144,18 @@ struct window_copy_mode_data {
  14. char jumpchar;
  15. };
  16.  
  17. +
  18. +void to_pasteboard(char *buf)
  19. +{
  20. + /* Copy to pasteboard */
  21. + FILE *fp;
  22. + fp = fopen("/tmp/tmux-buffer", "w");
  23. + fprintf(fp, "%s\0", buf);
  24. + fclose(fp);
  25. + system("reattach-to-user-namespace -l zsh -c \"pbcopy < /tmp/tmux-buffer\"");
  26. +}
  27. +
  28. +
  29. struct screen *
  30. window_copy_init(struct window_pane *wp)
  31. {
  32. @@ -1349,6 +1362,9 @@ window_copy_copy_selection(struct window_pane *wp)
  33. /* Add the buffer to the stack. */
  34. limit = options_get_number(&global_options, "buffer-limit");
  35. paste_add(&global_buffers, buf, off, limit);
  36. +
  37. + /* add by yusukei */
  38. + to_pasteboard(buf);
  39. }
  40.  
  41. void
  42. @@ -1406,6 +1422,9 @@ window_copy_copy_line(struct window_pane *wp,
  43. *buf = xrealloc(*buf, 1, (*off) + 1);
  44. (*buf)[(*off)++] = '\n';
  45. }
  46. +
  47. + /* add by yusukei */
  48. + to_pasteboard(buf);
  49. }
  50.  
  51. void
Add Comment
Please, Sign In to add comment