r/commandline

YouTube search and play in 20 lines of bash

YouTube search and play in 20 lines of bash

I was searching for YouTube TUI and stumble upon YT-X. But I don't need all the features and only need to search and play a video. So I wrote a simple 20 lines bash script.

#!/usr/bin/env bash
#
# `ytfp`: Search YouTube video using `fzf` and play it in `mpv`
# Require `fzf`, `yt-dlp`, `chafa`, `mpv`
#

SEARCH_VID() {
  yt-dlp "https://www.youtube.com/results?search_query=$1" \
    --flat-playlist --playlist-items 1:20 --print \
    $'%(thumbnails.0.url)s\t%(title)s\t%(channel)s\t%(view_count)s\t%(url)s' \
    | grep --extended-regexp --invert-match 'playlist|channel'
}
RENDER_VID_INFO() {
  curl --silent "$1" | chafa --format=sixels --size=x14 --clear
  echo "Title   : $2"
  echo "Channel : $3"
  echo "Views   : $4"
}
export -f SEARCH_VID RENDER_VID_INFO

fzf --preview-window down --layout reverse --disabled --with-shell 'bash -c' \
  --bind 'start:reload:SEARCH_VID fzf' \
  --bind 'change:reload:sleep 0.3; SEARCH_VID {q} || true' \
  --delimiter '\t' --with-nth 2 \
  --preview 'RENDER_VID_INFO {1} {2} {3} {4}' \
  --bind 'enter:execute-silent(mpv --fullscreen {5})'
u/SupermarketAntique32 — 4 hours ago
Image 1 — Gloomberb - open-source finance terminal
Image 2 — Gloomberb - open-source finance terminal
Image 3 — Gloomberb - open-source finance terminal
Image 4 — Gloomberb - open-source finance terminal
🔥 Hot ▲ 62 r/commandline

Gloomberb - open-source finance terminal

Hi,

I built this for fun over the past few days, wanted to try my hand at making a TUI.

Github: https://github.com/vincelwt/gloomberb

It's inspired by Bloomberg terminal but everything is extendable with plugins.

It's far from being complete, but I think it's off to a good start.

The biggest challenge has been building the charts, requiring to dive deep into Kitty graphics (if you have a Kitty-compatible terminal it'll look better!).

Btw OpenTUI (by the makers of Opencode) has been a super helpful to build the TUI layout.

It also supports placing trades (though I only added support for IBKR since that's what I use).

Contributions are welcome.

Let me know what you think!

u/tim_toum — 11 hours ago
essh: a Rust SSH client with a real TUI
🔥 Hot ▲ 60 r/CLI+2 crossposts

essh: a Rust SSH client with a real TUI

I’ve been working on essh, a pure-Rust SSH client with:

TUI dashboard

Concurrent sessions

Password/key/agent auth

Host monitoring

Connection diagnostics

It’s meant to make terminal-based server work feel more like a real operational workspace instead of one disconnected shell at a time.

Install:

cargo install essh

Repo:

https://github.com/matthart1983/essh

Would love feedback from Rust/Linux/infra folks.

u/Potential-Access-595 — 19 hours ago
resterm - TUI API client with new Explain tab

resterm - TUI API client with new Explain tab

Hello,

Some time ago I posted about my pet project which is a TUI API client called resterm. For the last couple of weeks, I’ve been working on a new feature which adds a new Explain tab. Basically, you can press ‘g + x’ on a given request to see how the request would look before actually sending it, or just send a request and you will get a kind of summary report with all the merged variables, mutated state, and explanation. The idea is to be able to see how the request will look with all the mutated state before or after sending it.

Nothing very fancy but something I think would be useful.

repo: https://github.com/unkn0wn-root/resterm

u/unknown_r00t — 19 hours ago
testx — auto-detecting test runner that replaces "cargo test", "pytest", "go test", "npx jest", etc. with one command
▲ 7 r/rust+1 crossposts

testx — auto-detecting test runner that replaces "cargo test", "pytest", "go test", "npx jest", etc. with one command

Instead of remembering the test command for each project, just run testx. It scans project files to detect the language and framework, then runs the appropriate test command with structured output.

Works with 11 languages out of the box. Also does CI sharding, watch mode, retries, and can output JSON/JUnit/TAP.

cargo install testx-cli

https://github.com/whoisdinanath/testx

u/AmpsAnd01s — 1 day ago
Week