Merge pull request #348 from luanpotter/q_command_close_tab

implement :q to close tab
jh-changes
Shin'ya Ueoka 6 years ago committed by GitHub
commit b0dddc9fa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      README.md
  2. 9
      src/background/actions/command.js

@ -85,6 +85,10 @@ 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.
#### `:q` command
Close the current tab.
#### `:winopen` command
Open a URL or search keywords by search engine in new window.

@ -19,6 +19,12 @@ const tabopenCommand = (url) => {
return browser.tabs.create({ url: url });
};
const tabcloseCommand = () => {
return browser.tabs.query({ active: true }).then((tabList) => {
return browser.tabs.remove(tabList.map(tab => tab.id));
});
};
const winopenCommand = (url) => {
return browser.windows.create({ url });
};
@ -93,6 +99,9 @@ const exec = (tab, line, settings) => {
});
case 'set':
return setCommand(args);
case 'q':
case 'quit':
return tabcloseCommand();
case '':
return Promise.resolve();
}