Vimperator - how to use current page's url as shell command argument

3

1

I need to use current page's url as argument to command that I execute via :!. I don't want to copy it there with mouse or type it.

Is there any way to do this?

My intention here is to send to Emacts this url which should be inserted to command line in Vimperator automatically, and after that I Want to type some text there with description of page/tags.

Jarek

Posted 2011-12-01T22:29:10.930

Reputation: 1 361

Answers

1

This is probably not the best way to achieve this, but it is a workaround that I have used. Autocommands have access to several keywords (see http://vimperator.org/help/vimperator/autocommands.xhtml), among them the keyword "url". So

:au PageLoad * :!echo "<url>" >/tmp/mycurrenturl

installs an autocommand that keeps your URL in a tmpfile where your script can access it.

I would appreciate if someone can post a more elegant solution.

teamchef

Posted 2011-12-01T22:29:10.930

Reputation: 11

1

Using Vimperator 3.4 - in a user-defined command - I use the current buffer's URL like this:

command -nargs=0 <name> :execute "!echo " + content.location.href

This defines the user-command :<name>, which takes no arguments. It calls the Vimperator command :execute which takes a string and executes it as though you were the who typed it. In this case it takes the string "!echo " + content.location.href. The content.location.href evaluates as a JavaScript expression (or something like that) and returns the URL of the page where the command was executed.

Executing :<name> on this page outputs this (after a brief pop-up terminal window - on Windows 7, using Cygwin's Bash as my shell):

http://superuser.com/questions/363654/vimperator-how-to-use-current-pages-url-as-shell-command-argument

Kohányi Róbert

Posted 2011-12-01T22:29:10.930

Reputation: 143