Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Consider a problem of searching several wikis at one command. Here's a possible solution. If one'd add the following to the .pentadactylrc:

javascript <<EOF
    dactyl.searchWikis = function (selection) {
        let parsedSelection = selection.replace(/^\s*/, "" ).replace(/\s*$/, "" ).replace(/\s+/g, "+" );
        dactyl.execute( ":tabopen" + selection);
        dactyl.execute( ":tabopen" + selection);

:command wikiSearch -nargs=* -js dactyl.searchWikis(<args>)

That should've solved it - but the problem is - that this way Pentadactyl doesn't see the JS code. I.e. new command wikiSearch doesn't appear. Can You fix it?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

I believe you need to add your function on the userContext, rather than on dactyl.


javascript <<EOF
    userContext.searchWikis = function (selection) {
        commands.execute("tabopen" + selection);
        commands.execute("tabopen" + selection);

I took the parsedSelection line out, as selection doesn't appear to come in as a string.

Also try removing the angle-brackets from <args>:

command wikiSearch -nargs=* -js userContext.searchWikis(args)
share|improve this answer
I wanted to award You - but did something wrong. I'll award You at the end of the bounty. – Adobe Apr 6 '12 at 7:39
@Adobe that's how bounties work. you start a bounty, you can award the amount after 2 days of starting the bounty. How does the bounty system work? – Sathya Apr 6 '12 at 8:14
@Adobe Thanks, glad it helped. Pentadactyl is a fantastic piece of software. – ngm Apr 6 '12 at 19:53

Your Answer


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.