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).
Gocket is in early version. Its interface might change. See the CHANGELOG
You can simply grab the latest binary file and download the version you need, depending on your OS.
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
- 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
.
You need to authorize gocket to access your Pocket account. It's very easy:
- Go to Gocket apps and create an application
- Authorize the application to add, modify, and retrieve if you want to use the full set of gocket's feature
- You need to pass the consumer key to gocket each time you use it (
-k
option) or you can use a config file:- Create the file
$XDG_CONFIG_HOME/gocket/config.yml
- Create an entry with
key
as index and the consumer key as value, for examplekey: 1234-5a6b7c
- Your config can be a YAML, TOML, or JSON file
- Create the file
- 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
- Enjoy!
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%
Use the option -h
for each command to output the help.
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
withgocket list
to bulk add every listed entry to the archive (with confirmation). - Use
-a
withgocket list archive
to bulk add every listed archive to the unread list (with confirmation).
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
).
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
You can provide the different options to gocket using:
- Command-line options (i.e
gocket list --tui
) - Environment variables (i.e
export GOCKET_TUI=true
) - 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 _
.
โ 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
ENTER: Open the selected page with your favorite browser d: Delete Pocket entry a: Add (if list archive) or archive (if list unread)
Consider sponsoring my work if you want to see new, fresh, and crunchy little CLIs (and TUIs) all over your system.
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!
- 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.