Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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.

share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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