3

I am trying to map a key in Zathura that copies the path of the currently opened path to the clipboard. I did this in my zathurarc

map <C-c> feedkeys ":exec xclip -i -selection clipboard `realpath $FILE`<Return>"

But, when I press Ctrl+C it doesn't do a thing. What am I doing wrong here?

2
  • 1
    man 5 zathurarc doesn't list a feedkeys function in the list of functions available for mapping. There is an exec function, however. Maybe map <C-c> exec "xclip -i -selection clipboard `realpath $FILE`"?
    – muru
    Jun 12 '19 at 5:29
  • Zathura seems to lack good documentation. Though feedkeys is not there in the man, it just works in the config file. This doesn't work. The problem is mainly xclip works like this echo $FILE | xclip -i -selection clipboard. But, I can't work with this also. @muru Jun 13 '19 at 5:49
0

I used a shell script zathura-copy-path (make sure it is available via PATH, and executable)

#!/bin/bash
echo $1 | xclip -i -selection c

In zathurarc I added

map <C-o> feedkeys ":exec zathura-copy-path $FILE<Return>"

Works for me. Also worked just fine with pdf filenames with spaces. Looks like you almost had it, just that zathuras command line isn't sophisticated enough for parsing like a shell.

0

This will do.

:map <C-o> feedkeys ":exec sh -c \"echo $FILE | xclip -i -sel clip\"<Return>"

Zathura exec adds quote on each words to escape the commands. This breaks the pipe and following xclip command. Using shell sh -c to group them together avoid this hassle.

1
  • 1
    Welcome to the site, and thank you for your contribution. You may want to add some explanation on why you think that helps with the OPs problem (and by that way, what you think the OPs problem actually ist).
    – AdminBee
    Jan 19 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.