How to reload Google Chrome tab from terminal?

后端 未结 8 2094
心在旅途
心在旅途 2021-02-02 17:57

Is there a way to reload a Google Chrome tab in Ubuntu using just the terminal. I don\'t want to just open a new window, but to actually refresh a tab!

Extra que

8条回答
  •  我在风中等你
    2021-02-02 18:38

    Solution: chromix-too

    Chromix-Too is a tool to send many types of commands to an existing Chrome session via command line, include tab reloading, given a tab identifier. As described here it is composed of three components: an extension for Google Chrome, a server and the chromix-too utility.

    How to install chromix-too

    1. Install the extension on your Chrome browser.

    2. If not already installed, install the npm package manager. A general way to install it on Unix systems is by executing (with root permissions)

      curl -L https://www.npmjs.com/install.sh | sh
      

      The npm tool can usually be installed using other well-known package managers, for example in Ubuntu you should be able to do

      sudo apt-get install npm
      
    3. Install the chromix-toopackage via npm

      sudo npm install -g chromix-too
      

    How to reload a tab from terminal

    1. First of all, start the server:

      chromix-too-server
      
    2. Now, using the chromix-too tool you can list all tabs with the corresponding identifiers in order to be able select the right tab.

      chromix-too ls
      

      The result will be something like

      35 The foo bar website
      136 https://another.website.foo/
      142 https://another.one.bar/
      

      As you can see, the first column shows a unique numeric identifier and the second column shows the tab title.

    3. Now suppose you want to reload the second tab in the list, that is the one with identifier 136. You can do this by typing

      chromix-too reload 136
      

    Alternative tab selection

    If you cannot use the numeric identifier to select a tab, there are several other ways. For example you can select tabs based on their titles or you can select pinned or unpinned tabs. See this link for help about tab selection and about the usage of Chromix-Too in general. As you can see in the tutorial, it is even possible to force a total reload without using the browser cache.

    Benefits of this approach with respect to other approaches

    The main benefit of using this approach with respect to other solutions shown in the other answers (including my previous answer( is that you can select and reload tabs in a very precise way (for example by using unique IDs) and without having to send keystrokes to the GUI and to focus windows, which may be uncomfortable. For example, if you are using your computer to type some text, the other scripts shown in the previous answers would change the focus and you may end up typing on browser windows accidentally. This can be avoided using this solution.

提交回复
热议问题