Created
August 25, 2011 15:06
-
-
Save yusukei/1170871 to your computer and use it in GitHub Desktop.
tmux 1.5 with pasteboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/window-copy.c b/window-copy.c | |
index b49be33..9537ad5 100644 | |
--- a/window-copy.c | |
+++ b/window-copy.c | |
@@ -23,6 +23,7 @@ | |
#include "tmux.h" | |
+void to_pasteboard(char *buf); | |
struct screen *window_copy_init(struct window_pane *); | |
void window_copy_free(struct window_pane *); | |
void window_copy_resize(struct window_pane *, u_int, u_int); | |
@@ -143,6 +144,18 @@ struct window_copy_mode_data { | |
char jumpchar; | |
}; | |
+ | |
+void to_pasteboard(char *buf) | |
+{ | |
+ /* Copy to pasteboard */ | |
+ FILE *fp; | |
+ fp = fopen("/tmp/tmux-buffer", "w"); | |
+ fprintf(fp, "%s\0", buf); | |
+ fclose(fp); | |
+ system("reattach-to-user-namespace -l zsh -c \"pbcopy < /tmp/tmux-buffer\""); | |
+} | |
+ | |
+ | |
struct screen * | |
window_copy_init(struct window_pane *wp) | |
{ | |
@@ -1349,6 +1362,9 @@ window_copy_copy_selection(struct window_pane *wp) | |
/* Add the buffer to the stack. */ | |
limit = options_get_number(&global_options, "buffer-limit"); | |
paste_add(&global_buffers, buf, off, limit); | |
+ | |
+ /* add by yusukei */ | |
+ to_pasteboard(buf); | |
} | |
void | |
@@ -1406,6 +1422,9 @@ window_copy_copy_line(struct window_pane *wp, | |
*buf = xrealloc(*buf, 1, (*off) + 1); | |
(*buf)[(*off)++] = '\n'; | |
} | |
+ | |
+ /* add by yusukei */ | |
+ to_pasteboard(buf); | |
} | |
void |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment