aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Vitor Brandão <jvbrandaom@gmail.com>2018-05-24 17:14:19 -0300
committerJoão Vitor Brandão <jvbrandaom@gmail.com>2018-05-24 17:14:19 -0300
commit4445309334e309c7ad74ec2011d40c6998fd4653 (patch)
treeca3fcee8c1cb9cceee4216046f27817c498f6684
parent982a54c0aa6d1ae99932a05100bceafad6d3669c (diff)
Adds command to close all tabs
Type :qa or :quitall to close all tabs
-rw-r--r--README.md6
-rw-r--r--src/background/actions/command.js11
2 files changed, 16 insertions, 1 deletions
diff --git a/README.md b/README.md
index a4a7418..23d7e8d 100644
--- a/README.md
+++ b/README.md
@@ -86,10 +86,14 @@ To adjust the search engine default and add/remove search engines, see the [sear
Open a URL or search keywords by search engine in new tab.
-#### `:quit` command
+#### `:quit` or `:q` command
Close the current tab.
+#### `:quitall` or `:qa` command
+
+Close all tabs.
+
#### `:bdelete` command
Close a certain tab.
diff --git a/src/background/actions/command.js b/src/background/actions/command.js
index f1ee5b5..6d83450 100644
--- a/src/background/actions/command.js
+++ b/src/background/actions/command.js
@@ -27,6 +27,14 @@ const tabcloseCommand = () => {
});
};
+const tabcloseAllCommand = () => {
+ return browser.tabs.query({
+ currentWindow: true
+ }).then((tabList) => {
+ return browser.tabs.remove(tabList.map(tab => tab.id));
+ });
+};
+
const winopenCommand = (url) => {
return browser.windows.create({ url });
};
@@ -117,6 +125,9 @@ const exec = (tab, line, settings) => {
case 'q':
case 'quit':
return tabcloseCommand();
+ case 'qa':
+ case 'quitall':
+ return tabcloseAllCommand()
case '':
return Promise.resolve();
}