File tree 1 file changed +21
-2
lines changed
stdlib/InteractiveUtils/src
1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
if Sys. isapple ()
6
6
function clipboard (x)
7
- open (pipeline (` pbcopy` , stderr = stderr ), " w" ) do io
7
+ pbcopy_cmd = ` pbcopy`
8
+
9
+ # OSX shells, especially when run within `tmux` or `screen`, can be
10
+ # disconnected from the global shell namespace, which causes problems
11
+ # with clipboards. Luckily, the `reattach-to-user-namespace` utility
12
+ # dodges these issues quite nicely, so we automatically utilize it if
13
+ # it is installed.
14
+ if Sys. which (" reattach-to-user-namespace" ) != nothing
15
+ pbcopy_cmd = ` reattach-to-user-namespace pbcopy`
16
+ end
17
+
18
+ open (pipeline (pbcopy_cmd, stderr = stderr ), " w" ) do io
8
19
print (io, x)
9
20
end
10
21
end
11
- clipboard () = read (` pbpaste` , String)
22
+ function clipboard ()
23
+ pbpaste_cmd = ` pbpaste`
24
+
25
+ # See above comment in `clipboard(x)`
26
+ if Sys. which (" reattach-to-user-namespace" ) != nothing
27
+ pbcopy_cmd = ` reattach-to-user-namespace pbpaste`
28
+ end
29
+ read (pbpaste_cmd, String)
30
+ end
12
31
13
32
elseif Sys. islinux () || Sys. KERNEL === :FreeBSD
14
33
_clipboardcmd = nothing
You can’t perform that action at this time.
0 commit comments