@@ -6,59 +6,84 @@ Clipper is a macOS "launch agent" — or Linux daemon — that runs in t
66
77# At a glance
88
9- # macOS installation (using Homebrew; for non-Homebrew installs see below)
9+ ## macOS installation (using Homebrew; for non-Homebrew installs see below)
10+
1011 brew install clipper # run this outside of a tmux session
1112
12- # Configuration for ~/.tmux.conf:
13+ ## Configuration for ` ~/.tmux.conf `
14+
15+ ### tmux 2.4 and later
1316
14- # tmux >= 2.4: bind "Enter" in copy mode to both copy and forward to Clipper
17+ # Bind "Enter" in copy mode to both copy and forward to Clipper:
1518 bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "nc localhost 8377"
1619
20+ # Or, if you are running on a platform where nc requires the `-N` switch (eg. Ubuntu):
21+ bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "nc -N localhost 8377"
22+
1723 # Or, if you are running Clipper on a UNIX domain socket:
1824 bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "nc -U ~/.clipper.sock"
1925
2026 # Or, if your version of netcat doesn't have socket support and you want to use socat:
2127 bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "socat - UNIX-CLIENT:~/.clipper.sock"
2228
23- # tmux >= 1.8 and < 2.4: bind "Enter" in copy mode to both copy and forward to Clipper
29+ ### tmux >= 1.8 but < 2.4
30+
31+ # Bind "Enter" in copy mode to both copy and forward to Clipper:
2432 bind-key -t vi-copy Enter copy-pipe "nc localhost 8377"
2533
34+ # Or, if you are running on a platform where nc requires the `-N` switch (eg. Ubuntu):
35+ bind-key -t vi-copy Enter copy-pipe "nc -N localhost 8377"
36+
2637 # Or, if you are running Clipper on a UNIX domain socket:
2738 bind-key -t vi-copy Enter copy-pipe "nc -U ~/.clipper.sock"
2839
2940 # Or, if your version of netcat doesn't have socket support and you want to use socat:
3041 bind-key -t vi-copy Enter copy-pipe "socat - UNIX-CLIENT:~/.clipper.sock"
3142
32- # tmux < 1.8: bind <prefix>-y to forward to Clipper
43+ ### tmux < 1.8
44+
45+ # Bind <prefix>-y to forward to Clipper
3346 bind-key y run-shell "tmux save-buffer - | nc localhost 8377"
3447
48+ # Or, if you are running on a platform where nc requires the `-N` switch (eg. Ubuntu):
49+ bind-key y run-shell "tmux save-buffer - | nc -N localhost 8377"
50+
3551 # Or, if you are running Clipper on a UNIX domain socket:
3652 bind-key y run-shell "tmux save-buffer - | nc -U ~/.clipper.sock"
3753
3854 # Or, if your version of netcat doesn't have socket support and you want to use socat:
3955 bind-key y run-shell "tmux save-buffer - | socat - UNIX-CLIENT:~/.clipper.sock"
4056
41- # Configuration for ~/.vimrc:
42- # Bind <leader>y to forward last-yanked text to Clipper
57+ ## Configuration for ` ~/.vimrc `
58+
59+ " Bind <leader>y to forward last-yanked text to Clipper
4360 nnoremap <leader>y :call system('nc localhost 8377', @0)<CR>
4461
45- # Or, if you are running Clipper on a UNIX domain socket:
62+ " Or, if you are running on a platform where nc requires the `-N` switch (eg. Ubuntu):
63+ nnoremap <leader>y :call system('nc -N localhost 8377', @0)<CR>
64+
65+ " Or, if you are running Clipper on a UNIX domain socket:
4666 nnoremap <leader>y :call system('nc -U ~/.clipper.sock', @0)<CR>
4767
48- # Or, if your version of netcat doesn't have socket support and you want to use socat:
68+ " Or, if your version of netcat doesn't have socket support and you want to use socat:
4969 nnoremap <leader>y :call system('socat - UNIX-CLIENT:~/.clipper.sock', @0)<CR>
5070
51- # Configuration for ~/.bash_profile, ~/.zshrc etc:
71+ ## Configuration for ` ~/.bash_profile ` , ` ~/.zshrc ` etc
72+
5273 # Pipe anything into `clip` to forward it to Clipper
5374 alias clip="nc localhost 8377"
5475
76+ " Or, if you are running on a platform where nc requires the `-N` switch (eg. Ubuntu):
77+ alias clip="nc -N localhost 8377"
78+
5579 # Or, if you are running Clipper on a UNIX domain socket:
5680 alias clip="nc -U ~/.clipper.sock"
5781
5882 # Or, if your version of netcat doesn't have socket support and you want to use socat:
5983 alias clip="socat - UNIX-CLIENT:~/.clipper.sock"
6084
61- # Configuration for ~/.ssh/config:
85+ ## Configuration for ` ~/.ssh/config `
86+
6287 # Forward Clipper connection to remote host
6388 Host host.example.org
6489 RemoteForward 8377 localhost:8377
@@ -283,6 +308,10 @@ Now we can use a slight modification of our command from earlier. Assuming we ke
283308
284309 bind-key y run-shell "tmux save-buffer - | nc localhost 8377"
285310
311+ Or, if you are running on a platform where ` nc ` requires the ` -N ` switch (eg. Ubuntu):
312+
313+ bind-key y run-shell "tmux save-buffer - | nc -N localhost 8377"
314+
286315If we instead configured Clipper to listen on a UNIX domain socket at ` ~/.clipper.sock ` , then we could do something like:
287316
288317 bind-key y run-shell "tmux save-buffer - | nc -U ~/.clipper.sock"
@@ -295,6 +324,10 @@ In tmux 1.8 to 2.3, we have access to the new `copy-pipe` command and can use a
295324
296325 bind-key -t vi-copy Enter copy-pipe "nc localhost 8377"
297326
327+ Or, if you are running on a platform where ` nc ` requires the ` -N ` switch (eg. Ubuntu):
328+
329+ bind-key -t vi-copy Enter copy-pipe "nc -N localhost 8377"
330+
298331Or, for a UNIX domain socket at ` ~/.clipper.sock ` :
299332
300333 bind-key -t vi-copy Enter copy-pipe "nc -U ~/.clipper.sock"
@@ -307,6 +340,10 @@ In tmux 2.4 and above, we would use:
307340
308341 bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "nc localhost 8377"
309342
343+ Or, if you are running on a platform where ` nc ` requires the ` -N ` switch (eg. Ubuntu):
344+
345+ bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "nc -N localhost 8377"
346+
310347Or, for a UNIX domain socket at ` ~/.clipper.sock ` :
311348
312349 bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "nc -U ~/.clipper.sock"
@@ -323,6 +360,10 @@ For example, we can add a mapping to our `~/.vimrc` to send the last-yanked text
323360
324361 nnoremap <leader>y :call system('nc localhost 8377', @0)<CR>
325362
363+ Or, if you are running on a platform where ` nc ` requires the ` -N ` switch (eg. Ubuntu):
364+
365+ nnoremap <leader>y :call system('nc -N localhost 8377', @0)<CR>
366+
326367Equivalently, we could do the same for a Clipper daemon listening on a UNIX domain socket at ` ~/.clipper.sock ` with:
327368
328369 nnoremap <leader>y :call system('nc -U ~/.clipper.sock', @0)<CR>
@@ -339,15 +380,19 @@ By setting up an alias like:
339380
340381 alias clip="nc localhost 8377"
341382
342- or (in the case of Clipper listening on a UNIX domain socket at ` ~/.clipper.sock ` ):
383+ Or, if you are running on a platform where ` nc ` requires the ` -N ` switch (eg. Ubuntu):
384+
385+ alias clip="nc -N localhost 8377"
386+
387+ Or (in the case of Clipper listening on a UNIX domain socket at ` ~/.clipper.sock ` ):
343388
344389 alias clip="nc -U ~/.clipper.sock"
345390
346- or , with ` socat ` :
391+ Or , with ` socat ` :
347392
348393 alias clip="socat - UNIX-CLIENT:~/.clipper.sock"
349394
350- you can conveniently get files and other content into your clipboard:
395+ You can conveniently get files and other content into your clipboard:
351396
352397 cat example.txt | clip
353398 ls /etc | clip
0 commit comments