Add :bdeletes command
This commit is contained in:
parent
b0dddc9fa7
commit
c4fb6f0131
3 changed files with 12 additions and 1 deletions
|
@ -84,6 +84,8 @@ const exec = (tab, line, settings) => {
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'buffer':
|
case 'buffer':
|
||||||
return bufferCommand(args);
|
return bufferCommand(args);
|
||||||
|
case 'bdeletes':
|
||||||
|
return tabs.closeTabsByKeywords(args.join(' '));
|
||||||
case 'addbookmark':
|
case 'addbookmark':
|
||||||
return addBookmarkCommand(tab, args).then((item) => {
|
return addBookmarkCommand(tab, args).then((item) => {
|
||||||
if (!item) {
|
if (!item) {
|
||||||
|
|
|
@ -88,6 +88,7 @@ const getCompletions = (line, settings) => {
|
||||||
return getOpenCompletions(name, keywords, settings.search);
|
return getOpenCompletions(name, keywords, settings.search);
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'buffer':
|
case 'buffer':
|
||||||
|
case 'bdeletes':
|
||||||
return tabs.getCompletions(keywords).then((gotTabs) => {
|
return tabs.getCompletions(keywords).then((gotTabs) => {
|
||||||
let items = gotTabs.map((tab) => {
|
let items = gotTabs.map((tab) => {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import * as tabCompletions from './completions/tabs';
|
||||||
|
|
||||||
const closeTab = (id) => {
|
const closeTab = (id) => {
|
||||||
return browser.tabs.get(id).then((tab) => {
|
return browser.tabs.get(id).then((tab) => {
|
||||||
if (!tab.pinned) {
|
if (!tab.pinned) {
|
||||||
|
@ -10,6 +12,12 @@ const closeTabForce = (id) => {
|
||||||
return browser.tabs.remove(id);
|
return browser.tabs.remove(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const closeTabsByKeywords = (keyword) => {
|
||||||
|
tabCompletions.getCompletions(keyword).then((tabs) => {
|
||||||
|
browser.tabs.remove(tabs.map(tab => tab.id));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const reopenTab = () => {
|
const reopenTab = () => {
|
||||||
return browser.sessions.getRecentlyClosed({
|
return browser.sessions.getRecentlyClosed({
|
||||||
maxResults: 1
|
maxResults: 1
|
||||||
|
@ -119,7 +127,7 @@ const duplicate = (id) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
closeTab, closeTabForce, reopenTab, selectAt, selectByKeyword,
|
closeTab, closeTabForce, closeTabsByKeywords, reopenTab, selectAt, selectByKeyword,
|
||||||
selectPrevTab, selectNextTab, selectFirstTab,
|
selectPrevTab, selectNextTab, selectFirstTab,
|
||||||
selectLastTab, selectTab, reload, updateTabPinned,
|
selectLastTab, selectTab, reload, updateTabPinned,
|
||||||
toggleTabPinned, duplicate
|
toggleTabPinned, duplicate
|
||||||
|
|
Reference in a new issue