Add tabnextmru bound to ctrl+7

This commit is contained in:
Oliver Blanthorn 2024-06-04 16:22:14 +02:00
parent d30d6d9df4
commit 5fa0590529
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
3 changed files with 20 additions and 1 deletions

View file

@ -2627,6 +2627,20 @@ export async function tabprev(increment = 1) {
})
}
/**
* Switch to the previously used tab, ignoring any tabs used within the last 10 seconds. Handy for flicking through previous tabs.
*/
//#background
export async function tabnextmru() {
return browser.tabs.query({ currentWindow: true, hidden: false }).then(tabs => {
tabs.sort((a, b) => b.lastAccessed - a.lastAccessed)
console.log(tabs)
const mru_ish = tabs.findIndex(t => Date.now() - t.lastAccessed - 10000 > 0)
console.log(mru_ish)
return browser.tabs.update(tabs[(mru_ish > -1 ? mru_ish : 1)].id, { active: true })
})
}
/**
* Pushes the current tab to another window. Only works for windows of the same type
* (can't push a non-private tab to a private window or a private tab to

View file

@ -428,6 +428,7 @@ export class default_config {
browsermaps = {
"<C-,>": "escapehatch",
"<C-6>": "tab #",
"<C-7>": "tabnextmru",
// "<CS-6>": "tab #", // banned by e2e tests
}

View file

@ -37,6 +37,10 @@
}
},
"command_4": {
"suggested_key": {
"default": "MacCtrl+7",
"windows": "Alt+7"
},
"description": "Internal use. See `:help bind`. Use `:bind --mode=browser` to change - do not change here."
},
"command_5": {
@ -161,4 +165,4 @@
"omnibox": {
"keyword": "tri"
}
}
}