-
Notifications
You must be signed in to change notification settings - Fork 38
Cable channels
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 specifiedsource_command
to get its entries and using thepreview_command
to generate previews - a
dotfiles
channel, using the specifiedsource_command
to get its entries and using tv's builtinfiles
previewer
These cable channels are accessible:
- through the cli
tv my-dotfiles
ortv git-log
- using the remote control mode as shown below
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:
wherepreviewer
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
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! ๐
[[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 = "git-branch"
source_command = 'git --no-pager branch --all --format="%(refname:short)"'
preview_command = 'git show -p --stat --pretty=fuller --color=always {0}'
[[cable_channel]]
name = "git-diff"
source_command = "git diff --name-only"
preview_command = "git diff --color=always {0}"
[[cable_channel]]
name = "git-files"
source_command = 'git ls-files'
preview_command = 'bat -n --color=always {}'
[[cable_channel]]
name = "git-reflog"
source_command = 'git reflog'
preview_command = 'git show -p --stat --pretty=fuller --color=always {0}'
[[cable_channel]]
name = "zsh-history"
source_command = "tail -r $HOME/.zsh_history | cut -d\";\" -f 2-"
[[cable_channel]]
name = "bash-history"
source_command = "tail -r $HOME/.bash_history"
[[cable_channel]]
name = "fish-history"
source_command = "fish -c 'history'"
[[cable_channel]]
name = "dotfiles"
source_command = "fd -t f . $HOME/.config"
preview_command = ":files:"
[[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'
[[cable_channel]]
name = "s3-buckets"
source_command = 'aws s3 ls | cut -d " " -f 3'
preview_command = 'aws s3 ls s3://{0}'
[[cable_channel]]
name = "Brew list"
source_command = 'brew list --versions'
preview_command = 'brew info {0}'
[[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)