Skip to content

Phantas0s/gocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

91 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

gocket

Logo of Gocket

travis CLI Go Report Card Codacy Badge Hits-of-Code License Tweet

A simple CLI (or TUI) for Pocket.

  • Read your Pocket goodies from your comfy shell.
  • Archive or delete multiple entries easily.
  • Use a TUI or pipe the pages' URLs (or titles) to any CLI you want.
  • Search through your Pocket list.
  • Works on Linux, macOS (not tested), and Windows (not tested).

screenshot of gocket tui

Gocket is in early version. Its interface might change. See the CHANGELOG

Installation

General

You can simply grab the latest binary file and download the version you need, depending on your OS.

Linux script

If you use a Linux-based OS, here's a simple way to download gocket and move it to /usr/local/bin. You can then call it wherever you want.

curl -L https://raw.githubusercontent.com/Phantas0s/gocket/master/install/linux.sh | bash

Manual installation

  • You need the last version of Golang installed.
  • You need to clone this repository and build the binary in the root directory with the command go build.

Authorization

You need to authorize gocket to access your Pocket account. It's very easy:

Steps

  1. Go to Gocket apps and create an application
  2. Authorize the application to add, modify, and retrieve if you want to use the full set of gocket's feature
  3. You need to pass the consumer key to gocket each time you use it (-k option) or you can use a config file:
    1. Create the file $XDG_CONFIG_HOME/gocket/config.yml
    2. Create an entry with key as index and the consumer key as value, for example key: 1234-5a6b7c
    3. Your config can be a YAML, TOML, or JSON file
  4. The first time you use pocket, you'll need to confirm your authorization. A webpage will open automatically in your favorite browser to do so
  5. Enjoy!

XDG Home Directory

Running gocket list without any consumer key will display an error message indicating where to create the config file.

The value of $XDG_CONFIG_HOME depends of your OS. Here are the defaults (if you didn't modify it):

  • Unix systems: ~/.config
  • macOS: ~/Library/Application Support
  • Windows: %LOCALAPPDATA%

Commands

Use the option -h for each command to output the help.

List

  • gocket list: list your Pocket pages.
  • gocket list archive: list the archives.

The options for these two commands are almost identical. Here are the difference:

  • Use -a with gocket list to bulk add every listed entry to the archive (with confirmation).
  • Use -a with gocket list archive to bulk add every listed archive to the unread list (with confirmation).

Adding New Pages

  • gocket add <URLs...>: Add the URLs <URLs....> to pocket. You can add multiple URLs separated with spaces.

This command will read the standard input stream (stdin) if no argument is given. For example:

echo "https://thevaluable.dev" | gocket add

If you want to display a message when each URL is successfully added, use the option verbose (-v).

Usage

If you choose to use the TUI, you can select a page and open it with your favorite browser using the ENTER key.

Description Command
Output every page's URLs gocket list
Display every page's URLs in a TUI gocket list --tui
Output the last 5 pages' URLs added gocket list -c 5
Display pages in a TUI and don't ask confirmation for any operation gocket list -c 5 --tui --noconfirm
Filter for type 'video' ('article' or 'image' possible too) gocket list -f "video"
Search for "youtube" in titles and URLs gocket list -s "golang"
Open the last page added with Firefox gocket list -c 1 | xargs firefox
Open the last page added with Lynx gocket list -c 1 | lynx -
Open the oldest page added with Firefox gocket list -c 1 -o "oldest" | xargs firefox
Open the last 5 pages added with Firefox and archive them gocket list -c 5 -a --noconfirm | xargs firefox
Open the last page added with Firefox and delete it gocket list -c 1 -d --noconfirm | xargs firefox
Print only the pages' titles gocket list -c 10 -t | sed 'n;d'

As a bonus for Linux users (might work on macOS too), you can use fzf to fuzzy search the page you want and open it with Firefox:

gocket list -c 5 -t | sed 'N;s#\n# /// #' | fzf | awk -F ' /// ' '{print $2}' | xargs firefox

Option, Configuration, and Environment Variables

You can provide the different options to gocket using:

  1. Command-line options (i.e gocket list --tui)
  2. Environment variables (i.e export GOCKET_TUI=true)
  3. Configuration file (i.e tui: true in $XDG_CONFIG_HOME/gocket/config.yaml|json|toml)

If these options are defined multiple times, the priorities follow the order above (from higher priority to lower).

The names of the environment variables need to be uppercase and prefixed with GOCKET_. Every hyphen - in the option's name needs to be replaced with an underscore _.

TUI Keystrokes

Navigation

 โ†‘ or k: up
 โ†“ or j: down
 PgUp or CTRL+u: One screen up
 PgDn or CTRL+d: One screen down
 Home or g: Top of the list
 End or G: Bottom of the list

Action

 ENTER: Open the selected page with your favorite browser
 d: Delete Pocket entry
 a: Add (if list archive) or archive (if list unread)

Sponsorship

Consider sponsoring my work if you want to see new, fresh, and crunchy little CLIs (and TUIs) all over your system.

Building Your Mouseless Development Environment

Switching between a keyboard and mouse costs cognitive energy. My book will help you set up a Linux-based development environment that keeps your hands on your keyboard. Take the brain power you've been using to juggle input devices and focus it where it belongs: on the things you create.

You'll learn how to write your own installation scripts too!

Acknowledgements

  • Thanks to the project go-pocket, it gave me the basic data structures and other ideas.
  • Thanks to MariaLetta for the awesome and beautiful Gopher pack! I used it for my logo on top.
  • Thanks to Lukasz Adam for his free and amazing illustrations I use basically everywhere.

Licence

Apache Licence 2.0