kutsan / zsh-system-clipboard

System clipboard key bindings for Zsh Line Editor with vi mode. It is similar to what `set clipboard=unnamed` does for vim.
GNU General Public License v3.0
140 stars 16 forks source link

Could not find any available clipboard manager. Make sure you have xclip or xsel installed. #24

Closed hrai closed 5 years ago

hrai commented 5 years ago

I'm getting the following error when I have both xsel and xclip installed. I'm using zsh on Ubuntu 18.xx

ERROR zsh-system-clipboard: Could not find any available clipboard manager. Make sure you have xclip or xsel installed.

kutsan commented 5 years ago

Can you move the source line of script file to the end of your .zshrc? You might happen to mutate $PATH variable after sourcing the plugin. Also, do you get yes after pasting hash xsel && echo 'yes' || echo 'nope' or nope? If still can't solve the problem, could you please try to produce the problem with a naked .zshrc?

hrai commented 5 years ago

I'm using zplugin to load it. I moved the following source lines to the bottom of my .zshrc but no good.


zplugin ice pick"zsh-system-clipboard.plugin.zsh"
zplugin ice pick"zsh-system-clipboard.zsh"
zplugin light kutsan/zsh-system-clipboard

The output of hash xsel && echo 'yes' || echo 'nope' is yes

I haven't tried the naked .zshrc but when I source the file manually in zsh, it loads and works as well.

kutsan commented 5 years ago

I've never used zplugin before, so I'm not sure what goes wrong there. If sourcing manually works then, there shouldn't be a problem.

hrai commented 5 years ago

I ran the script below in my terminal which is similar to the condition that's in the plugin.

if ! hash xsel 2>/dev/null
then
    echo "'xsel' was not found in PATH"
fi

The output was 'xsel' was not found in PATH

Does hash need to be setup properly?

kutsan commented 5 years ago

If you put which hash before loading the plugin what do you get? It needs to be shell built-in.

If problem was all about hash you can probably use this workaround to get it working.

https://github.com/kutsan/zsh-system-clipboard/blob/becd02a76be09f564ba5f5f2bb6f596d22f08274/zsh-system-clipboard.zsh#L59

-} elif (hash xsel 2>/dev/null) {
+} elif (which xsel 2>/dev/null) {

@doronbehar Do you have any idea? I'm stuck.

hrai commented 5 years ago

Yup, changing hash to which did the trick. I don't think it's specific to the zsh plugin manager I'm using.

I switched to bash and ran hash xsel and I got nothing. It looks like it's a shell issue/feature?

doronbehar commented 5 years ago

Pardon me for taking so much time to respond, I've had a distribution re-installation which has taken me some time to overcome.

Usually, I use in my scripts type <command> 2>&1 > /dev/null to test for availability of commands and not hash. Maybe we can switch to that? @hrai could you test this for us please?

hrai commented 5 years ago

I ran the following command


if ! type xsel 2>/dev/null
then
    echo "'xsel' was not found in PATH"
else
    echo "xsel was found in PATH"
fi

The output was as follows:

xsel is /usr/bin/xsel
xsel was found in PATH
doronbehar commented 5 years ago

@kutsan it seems rather clear that @hrai has xsel installed however it seems that when zplugin is loaded it doesn't have the builtin command hash. I don't want to install zplugin just to test if type might work. I've pushed a commit that replaces every usage of hash to type. @hrai could you please make sure you have the latest version of zsh-system-clipboard and test again with zplugin?

kutsan commented 5 years ago

@doronbehar Both hash and type seem equal, so if this going to fix our problem, I think it's okay. I just wonder why hash turned out like that though. Also, thank you so much again.

hrai commented 5 years ago

That fixed it. Thanks @kutsan, @doronbehar

hrai commented 5 years ago

I think this line should move further down as it is being used after this dissociation of.

https://github.com/kutsan/zsh-system-clipboard/blob/4e0c4edf35264e502111f98dd0404e09b264df67/zsh-system-clipboard.zsh#L93

doronbehar commented 5 years ago

Correct, thanks! Fixed in commit: https://github.com/kutsan/zsh-system-clipboard/commit/447735132be3e6d4d8d7e8f2757d9c1d3504124b