television/assets/js/dee5cafc.a3e40c39.js
2025-07-07 15:22:29 +00:00

1 line
10 KiB
JavaScript

"use strict";(self.webpackChunktelevision_website=self.webpackChunktelevision_website||[]).push([[6529],{945:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>l,metadata:()=>i,toc:()=>o});const i=JSON.parse('{"id":"Users/channels","title":"Channels","description":"Quick start","source":"@site/../docs/01-Users/07-channels.md","sourceDirName":"01-Users","slug":"/Users/channels","permalink":"/television/docs/Users/channels","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":7,"frontMatter":{},"sidebar":"docSidebar","previous":{"title":"Search Patterns","permalink":"/television/docs/Users/search-patterns"},"next":{"title":"Themes","permalink":"/television/docs/Users/themes"}}');var t=s(3420),a=s(5404);const l={},r="Channels",c={},o=[{value:"Quick start",id:"quick-start",level:2},{value:"Default location on your system",id:"default-location-on-your-system",level:2},{value:"Community-maintained channels",id:"community-maintained-channels",level:2},{value:"Invocation",id:"invocation",level:2},{value:"Creating your own channels",id:"creating-your-own-channels",level:2},{value:"Templating syntax",id:"templating-syntax",level:2},{value:"Channel specification",id:"channel-specification",level:2},{value:"high-level sections",id:"high-level-sections",level:4},{value:"<code>[metadata]</code>",id:"metadata",level:4},{value:"<code>[source]</code>",id:"source",level:4},{value:"<code>[preview]</code>",id:"preview",level:4},{value:"<code>[ui]</code>",id:"ui",level:4},{value:"<code>[keybindings]</code>",id:"keybindings",level:4}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",...(0,a.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"channels",children:"Channels"})}),"\n",(0,t.jsx)(n.h2,{id:"quick-start",children:"Quick start"}),"\n",(0,t.jsxs)(n.p,{children:["Channels are short configuration recipes that typically dictate what ",(0,t.jsx)(n.code,{children:"tv"})," should search through and what's displayed on the screen along with various other options."]}),"\n",(0,t.jsx)(n.p,{children:"Any given channel consists of a single TOML file."}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Example"}),": the default ",(0,t.jsx)(n.code,{children:"files"})," channel"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-toml",children:'[metadata]\nname = "files"\ndescription = "A channel to select files and directories"\nrequirements = ["fd", "bat"]\n\n[source]\ncommand = "fd -t f"\n\n[preview]\ncommand = "bat -n --color=always \'{}\'"\nenv = { BAT_THEME = "ansi" }\n\n[keybindings]\nshortcut = "f1"\n'})}),"\n",(0,t.jsx)(n.h2,{id:"default-location-on-your-system",children:"Default location on your system"}),"\n",(0,t.jsxs)(n.p,{children:["Channels live in the ",(0,t.jsx)(n.code,{children:"cable"})," directory inside your ",(0,t.jsx)(n.a,{href:"/television/docs/Users/configuration",children:"television configuration directory"}),"."]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Example"}),":"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"/home/user/.config/television\n\u251c\u2500\u2500 config.toml\n\u2514\u2500\u2500 cable\n \xa0\xa0 \u251c\u2500\u2500 files.toml\n \xa0\xa0 \u251c\u2500\u2500 env.toml\n \xa0\xa0 \u251c\u2500\u2500 alias.toml\n \xa0\xa0 \u251c\u2500\u2500 git-repos.toml\n \xa0\xa0 \u2514\u2500\u2500 text.toml\n"})}),"\n",(0,t.jsx)(n.h2,{id:"community-maintained-channels",children:"Community-maintained channels"}),"\n",(0,t.jsx)(n.p,{children:"The repository hosts a list of community-maintained channels which you can get and install to your cable directory using:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"tv update-channels\n"})}),"\n",(0,t.jsx)(n.h2,{id:"invocation",children:"Invocation"}),"\n",(0,t.jsx)(n.p,{children:"Channels may be invoked:"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"directly from the cli:"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"tv files\n"})}),"\n",(0,t.jsxs)(n.ol,{start:"2",children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:["using the remote control:\n",(0,t.jsx)(n.img,{alt:"tv remote",src:s(2206).A+"",width:"2880",height:"1588"})]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"on the fly:"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"tv --source-command 'fd -t f .' --preview-command 'bat -n --color=always {}' --preview-size 70\n"})}),"\n",(0,t.jsx)(n.h2,{id:"creating-your-own-channels",children:"Creating your own channels"}),"\n",(0,t.jsx)(n.p,{children:"Create a new TOML file in your cable directory:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"touch ~/.config/television/cable/my-awesome-channel.toml\n"})}),"\n",(0,t.jsx)(n.p,{children:"Fill out the minimum required fields:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-toml",children:'[metadata]\nname = "my-awesome-channel"\n\n[source]\ncommand = "aws s3 ls my-bucket"\n'})}),"\n",(0,t.jsxs)(n.p,{children:["Launch ",(0,t.jsx)(n.code,{children:"tv"})," with your new channel (or select it via the remote control):"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"tv my-awesome-channel\n"})}),"\n",(0,t.jsx)(n.p,{children:"The complete channel format spec can be found below."}),"\n",(0,t.jsx)(n.h2,{id:"templating-syntax",children:"Templating syntax"}),"\n",(0,t.jsxs)(n.p,{children:["Several channel fields can be formatted dynamically using the syntax described in the ",(0,t.jsx)(n.a,{href:"https://docs.rs/string_pipeline/0.12.0/string_pipeline/",children:"string-pipeline"})," crate."]}),"\n",(0,t.jsx)(n.p,{children:"Here's a quick TLDR if you're feeling lazy:"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Basic transformations:"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'# Extract middle items: "a,b,c,d,e"\n"{split:,:1..3}"\n# Output: "b,c"\n\n# Clean and format names: " john , jane , bob "\n\'{split:,:..|map:{trim|upper|append:!}}\'\n# Output: "JOHN!,JANE!,BOB!"\n\n# Extract numbers and pad with zeros: "item1,thing22,stuff333"\n\'{split:,:..|map:{regex_extract:\\d+|pad:3:0:left}}\'\n# Output: "001,022,333"\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"More niche use-cases:"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'# Filter files, format as list: "app.py,readme.md,test.py,data.json"\n\'{split:,:..|filter:\\.py$|sort|map:{prepend:\u2022 }|join:\\n}\'\n# Output: "\u2022 app.py\\n\u2022 test.py"\n\n# Extract domains from URLs: "https://github.com,https://google.com"\n\'{split:,:..|map:{regex_extract://([^/]+):1|upper}}\'\n# Output: "GITHUB.COM,GOOGLE.COM"\n\n# Debug complex processing: "apple Banana cherry Date"\n"{split: :..|filter:^[A-Z]|sort:desc}"\n# Output: Date,Banana\n'})}),"\n",(0,t.jsx)(n.h2,{id:"channel-specification",children:"Channel specification"}),"\n",(0,t.jsx)(n.h4,{id:"high-level-sections",children:"high-level sections"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-toml",children:"[metadata]\n# general channel information\n\n[source]\n# this defines what we're searching through\n\n[preview]\n# for each result, maybe display a preview\n\n[ui]\n# customize the UI\n\n[keybindings]\n# customize keybindings\n"})}),"\n",(0,t.jsx)(n.h4,{id:"metadata",children:(0,t.jsx)(n.code,{children:"[metadata]"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-toml",children:'[metadata]\nname = "text"\ndescription = "A short description about what my channel does"\nrequirements = ["rg", "bat"] # any binary requirements my channel needs\n'})}),"\n",(0,t.jsx)(n.h4,{id:"source",children:(0,t.jsx)(n.code,{children:"[source]"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-toml",children:'[source]\ncommand = "rg . --no-heading --line-number"\ndisplay = "[{split:\\\\::..2}]\\t{split:\\\\::2}" # what\'s displayed in the UI\noutput = "{split:\\\\::..2}" # what\'s outputed on selection\n'})}),"\n",(0,t.jsx)(n.h4,{id:"preview",children:(0,t.jsx)(n.code,{children:"[preview]"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-toml",children:"[preview]\ncommand = 'bat -n --color=always {split:\\::0}'\nenv = { BAT_THEME = \"ansi\" } # extra envs to use when generating preview\noffset = '{split:\\::1}' # extracts preview offset information from the entry\n"})}),"\n",(0,t.jsx)(n.h4,{id:"ui",children:(0,t.jsx)(n.code,{children:"[ui]"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-toml",children:'[ui]\nui_scale = 80 # use 80% of available screen\nlayout = "portrait"\ninput_bar_position = "bottom"\ninput_header = "Search:"\n\n[ui.preview_panel]\nsize = 40 # 40%\nheader = "{}" # show the currently selected entry\nfooter = "my awesome footer"\nscrollbar = false\n\n[ui.status_bar]\nseparator_open = "<"\nseparator_close = ">"\n\n[ui.help_panel]\nshow_categories = true\n\n[ui.remote_control]\nshow_channel_descriptions = true\nsort_alphabetically = true\n\n[ui.features]\npreview_panel = { enabled = true, visible = true }\nremote_control = { enabled = true, visible = false }\nhelp_panel = { enabled = true, visible = false }\nstatus_bar = { enabled =true, visible = true }\n'})}),"\n",(0,t.jsx)(n.h4,{id:"keybindings",children:(0,t.jsx)(n.code,{children:"[keybindings]"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-toml",children:'[keybindings]\nshortcut = "f1" # `f1` will automatically switch to this channel\n\nquit = ["esc", "ctrl-c"]\nselect_next_entry = "ctrl-j"\nselect_prev_entry = "ctrl-k"\nconfirm_selection = "ctrl-y"\n'})}),"\n",(0,t.jsxs)(n.p,{children:["See ",(0,t.jsx)(n.a,{href:"https://github.com/alexpasmantier/television/blob/main/television/action.rs",children:"actions.rs"})," for a list of available actions."]})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},2206:(e,n,s)=>{s.d(n,{A:()=>i});const i=s.p+"assets/images/tv-files-remote-a91617770467a430cdb6c3f01c0fda3c.png"}}]);