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.


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.


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):


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.