Skip to content

Instantly share code, notes, and snippets.

@troyp
Created May 14, 2015 04:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troyp/9f993eccb80bd074188d to your computer and use it in GitHub Desktop.
Save troyp/9f993eccb80bd074188d to your computer and use it in GitHub Desktop.
Pentadactyl ex file defining commands to go back/forward in a duplicated tab (like middle-clicking the navigation buttons)
" Pentadactyl ex file: add to .pentadactylrc or source with :source command
" Defines commands to go back/forward in a duplicated tab (equivalent to middle-clicking the navigation buttons)
" Example keybindings: gh and gl (replacing the builtin gh binding):
unmap gh
map -g user -ex gh :backt
map -g user -ex gl :forwardt
command! backt
\ -description "Duplicate tab and go back in the browser history"
\ -js <<EOF
var currT = gBrowser.selectedTab;
var dupT = gBrowser.duplicateTab(currT);
var dupTB = gBrowser.getBrowserForTab(dupT);
var backtListener = function () {
gBrowser.goBack();
dupTB.removeEventListener("DOMContentLoaded", backtListener);
};
dupTB.addEventListener("DOMContentLoaded", backtListener);
gBrowser.selectedTab = dupT;
EOF
command! forwardt
\ -description "Duplicate tab and go forward in the browser history"
\ -js <<EOF
var currT = gBrowser.selectedTab;
var dupT = gBrowser.duplicateTab(currT);
var dupTB = gBrowser.getBrowserForTab(dupT);
var forwardtListener = function () {
gBrowser.goForward();
dupTB.removeEventListener("DOMContentLoaded", forwardtListener);
};
dupTB.addEventListener("DOMContentLoaded", forwardtListener);
gBrowser.selectedTab = dupT;
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment