Skip to content
Louis Thevenet edited this page Jan 11, 2025 · 15 revisions

Tired of broadcast television? Want to watch your favorite shows on demand? television has you covered with cable channels. Cable channels are channels that are not built-in to television but are instead provided by the community.

Installing cable channels is as simple as creating provider files in your configuration folder.

A provider file is a *channels.toml file that contains cable channel prototypes defined as follows:

my-custom-channels.toml

[[cable_channel]]
name = "git-log"
source_command = 'git log --oneline --date=short --pretty="format:%h %s %an %cd" "$@"'
preview_command = 'git show -p --stat --pretty=fuller --color=always {0}'

[[cable_channel]]
name = "dotfiles"
source_command = 'fd -t f . $HOME/.config'
preview_command = ':files:'

This would add two new cable channels to television:

  • a git-log channel, using the specified source_command to get its entries and using the preview_command to generate previews
  • a dotfiles channel, using the specified source_command to get its entries and using tv's builtin files previewer

These cable channels are accessible:

  • through the cli tv my-dotfiles or tv git-log
  • using the remote control mode as shown below
Cable channels

Cable channel prototypes spec

name = String
source_command = String
preview_command = Option<String>
preview_delimiter = Option<String>

Tip

preview_command may be:

  • a shell command that produces an output given the selected entry (or a segment of it)
  • a reference to a builtin previewer formatted as :previewer: where previewer is one of the following:
    • files (syntax highlighted content)
    • env (environment variable values)
    • basic (the full entry string)

Tip

Deciding which part of the source command output to pass to the previewer:

By default, each line of the source command can be passed to the previewer using {}.

If you wish to pass only a part of the output to the previewer, you may do so by specifying the preview_delimiter to use as a separator and refering to the desired part using the corresponding index.

Example:

[[cable_channel]]
name = "Disney channel"
source_command = 'echo "one:two:three:four" && echo "five:six:seven:eight"'
preview_command = 'echo {2}'
preview_delimiter = ':'
# which will pass "three" and "seven" to the preview command

Cable Channels Guide

What follows is a list of cable channels you may pick and choose from for your own use.

Note

This list is maintained by the community, so feel free to contribute your own ideas too! ๐Ÿ˜Š

๐Ÿฟ Git

logs

[[cable_channel]]
name = "git-log"
source_command = 'git log --oneline --date=short --pretty="format:%h %s %an %cd" "$@"'
preview_command = 'git show -p --stat --pretty=fuller --color=always {0}'
Cable channels

branches

[[cable_channel]]
name = "git-branch"
source_command = 'git --no-pager branch --all --format="%(refname:short)"'
preview_command = 'git show -p --stat --pretty=fuller --color=always {0}'
branches

diff

[[cable_channel]]
name = "git-diff"
source_command = "git diff --name-only"
preview_command = "git diff --color=always {0}"

files

[[cable_channel]]
name = "git-files"
source_command = 'git ls-files'
preview_command = 'bat -n --color=always {}'

reflog

[[cable_channel]]
name = "git-reflog"
source_command = 'git reflog'
preview_command = 'git show -p --stat --pretty=fuller --color=always {0}'

๐Ÿฟ Shell history

zsh

[[cable_channel]]
name = "zsh-history"
source_command = "tail -r $HOME/.zsh_history | cut -d\";\" -f 2-"

bash

[[cable_channel]]
name = "bash-history"
source_command = "tail -r $HOME/.bash_history"

fish

[[cable_channel]]
name = "fish-history"
source_command = "fish -c 'history'"

๐Ÿฟ files

dotfiles

[[cable_channel]]
name = "dotfiles"
source_command = "fd -t f . $HOME/.config"
preview_command = ":files:"

๐Ÿฟ Docker

images

[[cable_channel]]
name = "docker-images"
source_command = 'docker image list --format "{{.ID}} {{.Repository}}\t{{.Tag}}\t{{.Size}}"'
preview_command = 'docker image inspect {0} | jq -C'

๐Ÿฟ S3

buckets

[[cable_channel]]
name = "s3-buckets"
source_command = 'aws s3 ls | cut -d " " -f 3'
preview_command = 'aws s3 ls s3://{0}'

๐Ÿฟ Homebrew

brew list

[[cable_channel]]
name = "Brew list"
source_command = 'brew list --versions'
preview_command = 'brew info {0}'
Screenshot 2024-12-07 at 14 20 25

๐Ÿฟ Tmux

sessions

[[cable_channel]]
name = "tmux list-sessions"
source_command = 'tmux list-sessions'
preview_command = 'tmux list-windows -t {0}'

To select a session to attach to tmux attach -t $(tmux list-sessions | tv --preview 'tmux list-windows -t {0}' | cut -d':' -f1)