trimsec turns an expression with various types of contents into commands, and helps you plan your content-consumption via different methods.
trimsec does have batteries included, so you don't need to install any additional tools to use it. However, you can disable some features to your liking if you self-compile.
Development happens on Codeberg and merged onto GitHub for deploying to the release pipeline.
trimsec has two primary functions:
- Fit-checking contents for the remainder of the day, or a specific time-budget, and
- Trimming the content using multipliers and calculating how much time you'll save.
Everything else is cherry-on-top.
To calculate saved time, you run a pattern like this:
ts 1h 2xtrimsec can receive an arbitrary amount of inputs and can output trims based on that:
ts 1h30m 1.5x 3h 2x
ts 1h30m 1.5x 1.2x 3h 2m
ts 3x 2h 2h 2h 1.25x 1h 2x 3.5hNearby durations based on the cursor are combined and checked against their common multipliers. This allows checking a huge number of durations in a matter of seconds. trimsec will daisy-chain these commands and also output how much time you'll save by the end of the day/budget.
You can also explicitly combine two durations like this:
ts 1h30m+2h50m 1.25xNote
You can set your Google Cloud Console API key for the YouTube Data API (v3):
ts key set <API_KEY_HERE>trimsec can also receive YouTube URLs as arguments alongside all the other durations and multipliers:
ts "https://www.youtube.com/watch?v=D4iiKkjGJmU" 1.25xThis leads to an infinite amount of combinations and daisy-chaining that you can do:
ts <URL> 1h30m 1.25x 2h <URL> 2xYouTube playlist URLs are also supported in two formats - distinct, and user-specified:
# signature playlist URL!
ts 1.8x "https://www.youtube.com/playlist?list=PLHXZ9OQGMqxersk8fUxiUMSIx0DBqsKZS"
# or, by putting `all::` before any YouTube URL (i.e. reading "all" videos):
ts 1.8x "all::https://www.youtube.com/watch?v=rdXw7Ps9vxc&list=PLHXZ9OQGMqxersk8fUxiUMSIx0DBqsKZS"You can also prefix the playlist URL with max:<n>:: to only calculate for the first n elements of the playlist. Here we demonstrate this by grabbing the first 5:
ts 1.8x "max:5::https://www.youtube.com/watch?v=rdXw7Ps9vxc&list=PLHXZ9OQGMqxersk8fUxiUMSIx0DBqsKZS"For fit-checking, you may use the patterns mentioned below.
Combination rules explained in 1. Trimming apply here as well, so other combinations of arguments are also possible outside of this collection.
# budget is today
ts 1h24m
ts "https://youtube.com/..."
# fixed budget: 2 hours and 4 minutes
ts 1h24m 2h4m
ts "https://youtube.com/..." 2h4m
# two items, explicit budget of 2h4m
ts 1h24m 15m b2h4m
# multiple args, budget is today
ts <URL> 1h30m 2h <URL> 3h
# multiple args, explicit budget of 15h
ts <URL> 1h30m 2h <URL> 3h b15h
# any youtube URL, budget of 5h
ts "https://youtu.be/..." 5h
# youtube playlist, item-caps, and other content
ts "all::https://youtu.be/..." 3h20m b5h
ts "max:5::https://youtu.be/..." 3h20m b5hRunning ts without any arguments starts interactive mode:
$ ts
trimsec interactive mode
version: 5.0.0 (type "exit" to terminate)
>>> 1h30m 1.5xIn interactive mode, you can run multiple expressions, fit-checks, or explicit commands sequentially in a prompt session without repeatedly calling ts. You can also navigate the history for the commands executed.
Built-in interactive commands:
clear- Clears the terminal screen.exit- Terminates the interactive session.
Warning
Interactive mode is, by default, NOT enabled on user-compiled builds. For more information, see "Compiling".
| Pattern / Syntax | Type | Example | Description |
|---|---|---|---|
<DURATION> |
Duration | 1h24m, 45m, 1m13.5s |
Time duration token |
<DURATION>+<DURATION> |
Combination | 1h30m+2h50m |
Explicitly sums multiple durations |
<SPEED>x |
Multiplier | 1.25x, 2x |
Speed multiplier applied to preceding duration(s) |
b<DURATION> |
Budget | b2h4m, b15h |
Explicit time budget for fit-checks |
-clip |
Clipboard | ts -clip 1.5x |
Reads duration/URL directly from system clipboard |
<URL> |
YouTube Video / Short | https://youtu.be/... |
Fetches duration from YouTube video metadata |
<PLAYLIST_URL> |
YouTube Playlist | https://youtube.com/playlist?list=... |
Fetches cumulative duration of a playlist |
all::<PLAYLIST> |
YouTube Playlist (forced on any URL) | all::https://youtube.com/... |
Attempts to evaluate a URL as a playlist if possible |
max:<n>::<PLAYLIST> |
Item Cap | max:5::https://youtube.com/... |
Caps playlist evaluation to first n items |
--color <MODE> |
Flag | --color=never, --color auto |
Color output mode (always, auto, never) |
trimsec uses the hybrid of a deterministic parser and clap, so explicit commands are also possible just like any typical command-line interface.
Some notable commands are:
ts list <PLAYLIST_URL>- Lists the contents of a YouTube playlist.
A few configuration-related commands are:
ts path- Shows the path to the configuration file.ts cache <subcommand>- Manages the cache.ts cache- Shows the cache path.ts cache clean- Cleans the cache.
ts key <subcommand>(used for Google Cloud Console API configuration for YouTube support)ts key- Shows the configured API key.ts key set <API_KEY>- Sets a new API key.ts key unset- Unsets the configured API key.
These are the most commonly-used ones. For viewing all of the commands, run ts help and see "Commands".
Note
The deterministic parser will most likely have different grammar from clap's logic. For example, setting an item-cap for trimming would look something like ts "max::10::https://youtube.com/...", but for the ts list command, it would look like ts list --max-items 10 "https://youtube.com/....
Note
This is an expanding list as of now.
-
System Clipboard Integration (
-clip): You can pass-clipas an argument to read a duration or YouTube URL directly from your system clipboard:# Reads text from clipboard (e.g., "1h30m" or a YouTube link) and applies 1.5x speed ts -clip 1.5x -
Pipes: Pipes are supported just like any other well-built Unix/Linux command-line interface.
echo "1h2m 1.25x" | ts 2h 3x
The configuration file for trimsec lies in the home directory of the user:
- Linux:
$HOME/.trimsecrc(e.g./home/alice/.trimsecrc) - macOS:
$HOME/.trimsecrc(e.g./Users/hitblast/.trimsecrc) - Windows:
C:\Users\<username>\.trimsecrc
The primary use of the configuration file is to store the API key (see "For YouTube videos/playlists") for Google Cloud Console, and to store configuration options for trimsec itself, which are described below.
trimsec provides partial modifications of its features through the options table.
[options]
default_fit_budget = "2h4m" # overrides the default duration for fit-checks
day_end = "23:00" # (hh:mm:ss) overrides the end of the day
# MUST be in 24h format- Using Homebrew:
brew tap hitblast/tap
brew install hitblast/tap/trimsec- Using
cargo:
cargo install trimsec- Using cargo-binstall:
cargo binstall trimsec- Using mise:
mise use -g cargo:trimsec- Or,
Get platform-based binaries here: https://github.com/hitblast/trimsec/releases
Execute these commands in order:
# Clone the repository
git clone https://github.com/hitblast/trimsec.git
# Navigate to cloned repo and compile.
cd trimsec
cargo build --release
# OPTIONAL
# To enable interactive mode for the build:
cargo build --release --features interactiveThis project is licensed under the MIT License.
