在执行tv init shell
命令后,tv
会自动检测当前的shell并生成对应的脚本,脚本可以读取toml
编写的Channel配置文件,然后执行相应的操作。
应该是通过这种方式屏蔽了不同shell的差异,不过这是我猜的
Channels are short configuration recipes that typically dictate what tv should search through and what’s displayed on the screen along with various other options.
tv 引入 Channel 的概念,Channel 可以理解成定义 tv 的搜索范围和显示内容的配置文件,存放在~/.config/television/cable/
目录下
前面运行的tv update-channels
命令会从社区下载一些常用的 Channel。
/home/user/.config/television├── config.toml├── cable│ ├── alias.toml│ ├── aws-buckets.toml│ ├── aws-instances.toml│ ├── bash-history.toml│ ├── dirs.toml│ ├── docker-images.toml│ ├── dotfiles.toml│ ├── env.toml│ ├── files.toml│ ├── fish-history.toml│ ├── git-branch.toml│ ├── git-diff.toml│ ├── git-log.toml│ ├── git-reflog.toml│ ├── git-repos.toml│ ├── nu-history.toml│ ├── text.toml│ └── zsh-history.toml
部分 Channel 需要安装对应的cli工具才能使用,例如bat
, fd
等
可以在config.toml
中添加 Channel 触发器。例如我们希望在输入cd
时触发dirs
Channel,输入cat
或vim
时触发files
Channel,可以在config.toml
中添加如下内容:
[shell_integration.channel_triggers]"dirs" = ["cd"]"files" = ["cat", "vim"]
效果参考下图,输入vim
后按Ctrl-T
即可触发files
Channel,输入cd
后按Ctrl-T
即可触发dirs
Channel。
更多features可以参考Television,文档的前端界面很有新意,内容也十分详细
Television