Skip to content

Instantly share code, notes, and snippets.

@troyp
Last active November 11, 2015 14:27
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/b4b4b75a0ef59a986e94 to your computer and use it in GitHub Desktop.
Save troyp/b4b4b75a0ef59a986e94 to your computer and use it in GitHub Desktop.
Vimperator ex file defining commands to go back/forward in a duplicated tab (like middle-clicking the navigation buttons)
" Vimperator ex file: add to .vimperatorrc 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):
nnoremap gh :backt<CR>
nnoremap gl :forwardt<CR>
command! backt -description "Duplicate tab and go back in the browser history" :js backt();
:js <<EOF
backt = function() {
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 forwardt();
:js <<EOF
forwardt = function() {
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