Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexpasmantier/television
The revolution will (not) be televised
https://github.com/alexpasmantier/television
cli command-line-tool fuzzy fuzzy-matching fuzzy-search rust terminal tui
Last synced: 1 day ago
JSON representation
The revolution will (not) be televised
- Host: GitHub
- URL: https://github.com/alexpasmantier/television
- Owner: alexpasmantier
- License: mit
- Created: 2024-09-15T22:16:18.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-12-10T23:31:16.000Z (1 day ago)
- Last Synced: 2024-12-11T00:27:13.864Z (1 day ago)
- Topics: cli, command-line-tool, fuzzy, fuzzy-matching, fuzzy-search, rust, terminal, tui
- Language: Rust
- Homepage: https://crates.io/crates/television
- Size: 4.94 MB
- Stars: 384
- Watchers: 5
- Forks: 15
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- my-awesome-github-stars - alexpasmantier/television - The revolution will (not) be televised (Rust)
- awesome-ratatui - television - A blazingly fast general purpose fuzzy finder for your terminal. (💻 Apps / 🚀 Productivity and Utilities)
README
# 📺 television
**A blazingly fast general purpose fuzzy finder TUI.**![docs.rs](https://img.shields.io/docsrs/television-channels)
[![Crates.io](https://img.shields.io/crates/v/television.svg)](https://crates.io/crates/television)
![GitHub branch check runs](https://img.shields.io/github/check-runs/alexpasmantier/television/main)
![GitHub License](https://img.shields.io/github/license/alexpasmantier/television)
![Crates.io Total Downloads](https://img.shields.io/crates/d/television)| ![television.png](https://github.com/user-attachments/assets/cffc3556-c9f3-4704-8303-8bddf661d139) |
|:--:|
| *The revolution will (not) be televised.* |## About
`Television` is a blazingly fast general purpose fuzzy finder TUI.It is inspired by the neovim [telescope](https://github.com/nvim-telescope/telescope.nvim) plugin and is designed to be fast, efficient, simple to use and easily extensible. It is built on top of [tokio](https://github.com/tokio-rs/tokio), [ratatui](https://github.com/ratatui/ratatui) and the *nucleo* matcher used by the [helix](https://github.com/helix-editor/helix) editor.
## Installation
Homebrew
```bash
brew install television
```
Arch Linux
```bash
pacman -S television
```
Debian-based (Debian, Ubuntu, Pop!_OS, Linux Mint, etc.)
```bash
curl -LO https://github.com/alexpasmantier/television/releases/download/0.6.2/television_0.6.2-1_amd64.deb
sudo dpkg -i television_0.6.2-1_amd64.deb
```
Conda-forge (cross-platform)
```bash
pixi global install television
```
Binary
From the [latest release](https://github.com/alexpasmantier/television/releases/latest) page:
- Download the latest release asset for your platform (e.g. `tv-vX.X.X-linux-x86_64.tar.gz` if you're on a linux x86 machine)
- Unpack and copy to the relevant location on your system (e.g. `/usr/local/bin` on macos and linux for a global installation)
Cargo
Setup the latest stable Rust toolchain via rustup:
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup update
```
Install `television`:
```bash
cargo install --locked television
```## Usage
```bash
tv [channel] #[default: files] [possible values: env, files, git-repos, text, alias]
```
By default, `television` will launch with the `files` channel on.
| |
|:--:|
| *`tv`'s `files` channel running on the *curl* codebase* |#### Matcher behavior
`television` uses a fuzzy matching algorithm to filter the list of entries. The algorithm that is used depends on the
input pattern that you provide.| Matcher | Pattern |
| --- | :---: |
| Fuzzy | `foo` |
| Substring | `'foo` / `!foo` to negate |
| Prefix | `^foo` / `!^foo` to negate |
| Suffix | `foo$` / `!foo$` to negate |
| Exact | `^foo$` / `!^foo$` to negate |For more information on the matcher behavior, see the
[nucleo-matcher](https://docs.rs/nucleo-matcher/latest/nucleo_matcher/pattern/enum.AtomKind.html) documentation.## Keybindings
Default keybindings are as follows:| Key | Description |
| :---: | ----------- |
| ↑ / ↓ | Navigate through the list of entries |
| Ctrl + u / d | Scroll the preview pane up / down |
| Enter | Select the current entry |
| Ctrl + y | Copy the selected entry to the clipboard |
| Ctrl + r | Toggle remote control mode |
| Ctrl + s | Toggle send to channel mode |
| Ctrl + g | Toggle the help panel |
| Esc | Quit the application |These keybindings are all configurable (see [Configuration](#configuration)).
## 📺 Built-in Channels
The following built-in channels are currently available:
- `Files`: search through files in a directory tree.
- `Text`: search through textual content in a directory tree.
- `GitRepos`: search through git repositories anywhere on the file system.
- `Env`: search through environment variables and their values.
- `Alias`: search through shell aliases and their values.
- `Stdin`: search through lines of text from stdin.## 🍿 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.*You can find a list of available cable channels [on the wiki](https://github.com/alexpasmantier/television/wiki/Cable-channels) and even contribute your own!
### Installing cable channels
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**
```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 = "My dotfiles"
source_command = 'fd -t f . $HOME/.config'
preview_command = 'bat -n --color=always {0}'
```This would add two new cable channels to `television` available using the remote control mode:
![cable channels](./assets/cable_channels.png "Cable channels")
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:**
```toml
[[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
```## Design (high-level)
#### Channels
**Television**'s design is primarily based on the concept of **Channels**.
Channels are just structs that implement the `OnAir` trait.As such, channels can virtually be anything that can respond to a user query and return a result under the form of a list of entries. This means channels can be anything from conventional data sources you might want to search through (like files, git repositories, remote filesystems, environment variables etc.) to more exotic implementations that might inclue a REPL, a calculator, a web browser, search through your spotify library, your email, etc.
**Television** provides a set of built-in **Channels** that can be used out of the box (see [Built-in Channels](#built-in-channels)). The list of available channels
will grow over time as new channels are implemented to satisfy different use cases.#### Transitions
When it makes sense, **Television** allows for transitions between different channels. For example, you might want to
start searching through git repositories, then refine your search to a specific set of files in that shortlist of
repositories and then finally search through the textual content of those files.This can easily be achieved using transitions.
#### Previewers
Entries returned by different channels can be previewed in a separate pane. This is useful when you want to see the
contents of a file, the value of an environment variable, etc. Because entries returned by different channels may
represent different types of data, **Television** allows for channels to declare the type of previewer that should be
used. Television comes with a set of built-in previewers that can be used out of the box and will grow over time.## Recipes
Here are some examples of how you can use `television` to make your life easier, more productive and fun. You may want to add some of these examples as aliases to your shell configuration file so that you can easily access them.**NOTE**: *most of the following examples are meant for macOS. Most of the commands should work on Linux as well, but you may need to adjust them slightly.*
#### CDing into git repo
```bash
cd `tv git-repos`
```
#### Opening file in default editor
```bash
open `tv`
```
##### VSCode:
```bash
code --goto `tv`
```
##### Vim
```bash
vim `tv`
```
at a specific line using the text channel
```bash
tv text | xargs -oI {} sh -c 'vim "$(echo {} | cut -d ":" -f 1)" +$(echo {} | cut -d ":" -f 2)'
```
#### Inspecting the current directory
```bash
ls -1a | tv
```## Terminal Emulators Compatibility
Here is a list of terminal emulators that have currently been tested with `television` and their compatibility status.| Terminal Emulator | Tested Platforms | Compatibility |
| --- | :---: | :---: |
| Alacritty | macOS, Linux | ✅ |
| Kitty | macOS, Linux | ✅ |
| iTerm2 | macOS | ✅ |
| Wezterm | macOS, Linux, Windows | ✅ |
| macOS Terminal | macOS | functional but coloring issues |
| Konsole | Linux | ✅ |
| Terminator | Linux | ✅ |
| Xterm | Linux | ✅ |
| Cmder | Windows | ✖️ |
| Foot | Linux | ✅ |
| Rio | macOS, Linux, Windows | ✅ |
| Warp | macOS | ✅ |
| Hyper | macOS | ✅ |## Configuration
You may wish to customize the behavior of `television` by providing your own configuration file. The configuration file
is a simple TOML file that allows you to customize the behavior of `television` in a number of ways.Here are default locations where `television` expect the configuration files to be located for each platform:
|Platform|Value|
|--------|:-----:|
|Linux|`$HOME/.config/television/config.toml`|
|macOS|`$HOME/Library/Application Support/com.television/config.toml`|
|Windows|`{FOLDERID_LocalAppData}\television\config`|**NOTE**: on either platform, `XDG_CONFIG_HOME` will always take precedence over default locations if set, in which case
television will expect the configuration file to be in `$XDG_CONFIG_HOME/television/config.toml`.You may also override these default paths by setting the `TELEVISION_CONFIG` environment variable to the path of your desired configuration **folder**.
Using a custom configuration file location:
```bash
export TELEVISION_CONFIG=$HOME/.config/television
touch $TELEVISION_CONFIG/config.toml
```#### Default Configuration
The default configuration file can be found in the repository's [./.config/config.toml](./.config/config.toml).## Contributions
Contributions, issues and pull requests are welcome.
See [CONTRIBUTING.md](CONTRIBUTING.md) and [good first issues](https://github.com/alexpasmantier/television/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) for more information.