-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
interactiveutil: clipboard for FreeBSD #23151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,30 +134,60 @@ if Sys.isapple() | |
| end | ||
| clipboard() = read(`pbpaste`, String) | ||
|
|
||
| elseif Sys.islinux() | ||
| elseif Sys.islinux() || Sys.KERNEL === :FreeBSD | ||
| _clipboardcmd = nothing | ||
| const _clipboardcmds = if Sys.islinux() | ||
| Dict( | ||
| :copy => Dict( | ||
| :xsel => `xsel --nodetach --input --clipboard`, | ||
| :xclip => `xclip -silent -in -selection clipboard`, | ||
| ), | ||
| :paste => Dict( | ||
| :xsel => `xsel --nodetach --output --clipboard`, | ||
| :xclip => `xclip -quiet -out -selection clipboard`, | ||
| ) | ||
| ) | ||
| elseif Sys.KERNEL === :FreeBSD | ||
| Dict( | ||
| :copy => Dict( | ||
| :xsel => `xsel -c`, | ||
| :xclip => `xclip -silent -in -selection clipboard`, | ||
| ), | ||
| :paste => Dict( | ||
| :xsel => `xsel -p`, | ||
| :xclip => `xclip -quiet -out -selection clipboard`, | ||
| ) | ||
| ) | ||
| end | ||
| function clipboardcmd() | ||
| global _clipboardcmd | ||
| _clipboardcmd !== nothing && return _clipboardcmd | ||
| for cmd in (:xclip, :xsel) | ||
| success(pipeline(`which $cmd`, DevNull)) && return _clipboardcmd = cmd | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pre-existing, but this'll give a pretty misleading error message if
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or... we can implement a simple version of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I generally do is if I know the program I'm looking for, usually there's a safe no-op flag like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| end | ||
| error("no clipboard command found, please install xsel or xclip") | ||
| pkgs = @static if Sys.islinux() | ||
| "xsel or xclip" | ||
| elseif Sys.KERNEL === :FreeBSD | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems works... is it expected? julia> @static if true
42
elseif false
24
end
42
julia> @static if false
42
elseif true
24
end
24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but the elseif condition is getting evaluated at run time, I believe
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. support of |
||
| "x11/xsel or x11/xclip" | ||
| end | ||
| error("no clipboard command found, please install $pkgs") | ||
| end | ||
| function clipboard(x) | ||
| c = clipboardcmd() | ||
| cmd = c == :xsel ? `xsel --nodetach --input --clipboard` : | ||
| c == :xclip ? `xclip -silent -in -selection clipboard` : | ||
| cmd = get(_clipboardcmds[:copy], c, nothing) | ||
| if cmd === nothing | ||
| error("unexpected clipboard command: $c") | ||
| end | ||
| open(pipeline(cmd, stderr=STDERR), "w") do io | ||
| print(io, x) | ||
| end | ||
| end | ||
| function clipboard() | ||
| c = clipboardcmd() | ||
| cmd = c == :xsel ? `xsel --nodetach --output --clipboard` : | ||
| c == :xclip ? `xclip -quiet -out -selection clipboard` : | ||
| cmd = get(_clipboardcmds[:paste], c, nothing) | ||
| if cmd === nothing | ||
| error("unexpected clipboard command: $c") | ||
| end | ||
| read(pipeline(cmd, stderr=STDERR), String) | ||
| end | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the only difference is in the options passed to xsel, I think it might be cleaner to just separate that part, i.e something like