-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
interactiveutil: clipboard for FreeBSD #23151
Conversation
The xsel implementation is different from Linux's. Ref: http://bsdforge.com/projects/x11/xsel/
c0364a9
to
29e0279
Compare
Nice. We should probably move this into a (standard) package so that it can evolve separate from Julia base. |
base/interactiveutil.jl
Outdated
:xclip => `xclip -quiet -out -selection clipboard`, | ||
) | ||
) | ||
end |
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
xsel_copy = Sys.islinux() ? `xsel --nodetach --input --clipboard` : `xsel -c`
xsel_paste = Sys.islinux() ? `xsel --nodetach --output --clipboard` : `xsel -p`
_clipboardcmds = Dict(:copy => Dict(:xsel => xsel_copy,
:xclip => `xclip -silent -in -selection clipboard`),
:paste => Dict(:xsel => xsel_paste,
:xclip => `xclip -quiet -out -selection clipboard`))
Possible to add a test for this? I'm not sure how we test |
There is a test in |
error("no clipboard command found, please install xsel or xclip") | ||
pkgs = @static if Sys.islinux() | ||
"xsel or xclip" | ||
elseif Sys.KERNEL === :FreeBSD |
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.
I don't think @static
will resolve the elseif
yet
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.
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
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.
but the elseif condition is getting evaluated at run time, I believe
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.
support of elseif
block is added in #24787
`xsel --nodetach --output --clipboard` : `xsel -p`, | ||
:xclip => `xclip -quiet -out -selection clipboard`, | ||
) | ||
) | ||
function clipboardcmd() | ||
global _clipboardcmd | ||
_clipboardcmd !== nothing && return _clipboardcmd | ||
for cmd in (:xclip, :xsel) | ||
success(pipeline(`which $cmd`, DevNull)) && return _clipboardcmd = cmd |
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.
pre-existing, but this'll give a pretty misleading error message if which
isn't installed
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.
Or... we can implement a simple version of which
in Julia?
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.
What I generally do is if I know the program I'm looking for, usually there's a safe no-op flag like -h
or --version
that you can try executing in a try-catch.
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.
-h
works on xclip
. unfortunately, the bsd version xsel
doesn't have any no-op flag.
The
xsel
implementation is different from Linux's.Ref: http://bsdforge.com/projects/x11/xsel/