mirror of
https://github.com/alexpasmantier/television.git
synced 2025-07-29 14:21:43 +00:00
78 lines
44 KiB
HTML
78 lines
44 KiB
HTML
<!doctype html>
|
||
<html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-Users/shell-integration" data-has-hydrated="false">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="generator" content="Docusaurus v3.8.1">
|
||
<title data-rh="true">Shell Integration | Television</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:image" content="https://alexpasmantier.github.io/television/img/tv-social.png"><meta data-rh="true" name="twitter:image" content="https://alexpasmantier.github.io/television/img/tv-social.png"><meta data-rh="true" property="og:url" content="https://alexpasmantier.github.io/television/docs/Users/shell-integration"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Shell Integration | Television"><meta data-rh="true" name="description" content="Television can integrate with your shell to provide smart autocompletion based on the commands you start typing."><meta data-rh="true" property="og:description" content="Television can integrate with your shell to provide smart autocompletion based on the commands you start typing."><link data-rh="true" rel="icon" href="/television/img/tv-icon-150.png"><link data-rh="true" rel="canonical" href="https://alexpasmantier.github.io/television/docs/Users/shell-integration"><link data-rh="true" rel="alternate" href="https://alexpasmantier.github.io/television/docs/Users/shell-integration" hreflang="en"><link data-rh="true" rel="alternate" href="https://alexpasmantier.github.io/television/docs/Users/shell-integration" hreflang="x-default"><script data-rh="true" type="application/ld+json">{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Shell Integration","item":"https://alexpasmantier.github.io/television/docs/Users/shell-integration"}]}</script><link rel="stylesheet" href="/television/assets/css/styles.cc1a39b4.css">
|
||
<script src="/television/assets/js/runtime~main.36d23f4d.js" defer="defer"></script>
|
||
<script src="/television/assets/js/main.1e6bd98c.js" defer="defer"></script>
|
||
</head>
|
||
<body class="navigation-with-keyboard">
|
||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><defs>
|
||
<symbol id="theme-svg-external-link" viewBox="0 0 24 24"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"/></symbol>
|
||
</defs></svg>
|
||
<script>!function(){var t="dark";var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme")}catch(t){}}();document.documentElement.setAttribute("data-theme",e||t),document.documentElement.setAttribute("data-theme-choice",e||t)}(),function(){try{const c=new URLSearchParams(window.location.search).entries();for(var[t,e]of c)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><link rel="preload" as="image" href="/television/img/tv-icon-80.png"><div role="region" aria-label="Skip to main content"><a class="skipToContent_nod4" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="theme-layout-navbar navbar navbar--fixed-top"><div class="navbar__inner"><div class="theme-layout-navbar-left navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/television/"><div class="navbar__logo"><img src="/television/img/tv-icon-80.png" alt="Television Logo" class="themedComponent_rgZj themedComponent--light_hdxy"><img src="/television/img/tv-icon-80.png" alt="Television Logo" class="themedComponent_rgZj themedComponent--dark_Iwy7"></div><b class="navbar__title text--truncate">Television</b></a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/television/docs/Users/installation">docs</a><a href="https://github.com/alexpasmantier/television/releases" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">releases<svg width="13.5" height="13.5" aria-hidden="true" class="iconExternalLink_dOts"><use href="#theme-svg-external-link"></use></svg></a><a href="https://crates.io/crates/television" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">crates.io<svg width="13.5" height="13.5" aria-hidden="true" class="iconExternalLink_dOts"><use href="#theme-svg-external-link"></use></svg></a></div><div class="theme-layout-navbar-right navbar__items navbar__items--right"><a href="https://github.com/alexpasmantier/television" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">GitHub<svg width="13.5" height="13.5" aria-hidden="true" class="iconExternalLink_dOts"><use href="#theme-svg-external-link"></use></svg></a><div class="navbarSearchContainer_VxOy"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="theme-layout-main main-wrapper mainWrapper_HR2q"><div class="docsWrapper_uElw"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_IzB1" type="button"></button><div class="docRoot_MWdD"><aside class="theme-doc-sidebar-container docSidebarContainer_AJtF"><div class="sidebarViewport_usFm"><div class="sidebar_HC93"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_BnDX"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" role="button" aria-expanded="true" href="/television/docs/Users/installation">Users</a></div><ul class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/installation">Installation</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/quickstart">Quickstart</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/configuration">Configuration</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/keybindings">Keybindings</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/television/docs/Users/shell-integration">Shell Integration</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/search-patterns">Search Patterns</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/channels">Channels</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/themes">Themes</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/cli">CLI Reference</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/community-channels-unix">🍿 Community Channels (unix)</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/community-channels-windows">🍿 Community Channels (windows)</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/terminal_emulators">Terminal Emulators</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/television/docs/Users/showcase">Showcase</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/television/docs/Developers/ARCHITECTURE">Developers</a></div></li></ul></nav><button type="button" title="Collapse sidebar" aria-label="Collapse sidebar" class="button button--secondary button--outline collapseSidebarButton_I1Io"><svg width="20" height="20" aria-hidden="true" class="collapseSidebarButtonIcon_KwG0"><g fill="#7a7a7a"><path d="M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0"></path><path d="M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0"></path></g></svg></button></div></div></aside><main class="docMainContainer_yFTf"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_QLDD"><div class="docItemContainer_Hqnr"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_eD4m" aria-label="Breadcrumbs"><ul class="breadcrumbs"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/television/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_YhwE"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Users</span></li><li class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link">Shell Integration</span></li></ul></nav><div class="tocCollapsible_Qf8d theme-doc-toc-mobile tocMobile_mt20"><button type="button" class="clean-btn tocCollapsibleButton_Hr9f">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>Shell Integration</h1></header>
|
||
<p>Television can integrate with your shell to provide smart autocompletion based on the commands you start typing.</p>
|
||
<p><img decoding="async" loading="lazy" src="https://github.com/user-attachments/assets/6292db26-8fcf-4874-ac9d-c9baedc70ff1" alt="tv-shell-integration" class="img__hwa"></p>
|
||
<h2 class="anchor anchorWithStickyNavbar_Fogf" id="keybindings">Keybindings<a href="#keybindings" class="hash-link" aria-label="Direct link to Keybindings" title="Direct link to Keybindings"></a></h2>
|
||
<ul>
|
||
<li><kbd>Ctrl</kbd>-<kbd>R</kbd>: shell history</li>
|
||
<li><kbd>Ctrl</kbd>-<kbd>T</kbd>: smart autocompletion for the current prompt command</li>
|
||
</ul>
|
||
<h2 class="anchor anchorWithStickyNavbar_Fogf" id="enabling-shell-integration">Enabling shell integration<a href="#enabling-shell-integration" class="hash-link" aria-label="Direct link to Enabling shell integration" title="Direct link to Enabling shell integration"></a></h2>
|
||
<h3 class="anchor anchorWithStickyNavbar_Fogf" id="zsh">Zsh<a href="#zsh" class="hash-link" aria-label="Direct link to Zsh" title="Direct link to Zsh"></a></h3>
|
||
<p>To enable shell integration for zsh, run:</p>
|
||
<div class="language-bash codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-bash codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token builtin class-name" style="color:rgb(189, 147, 249)">echo</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'eval "$(tv init zsh)"'</span><span class="token plain"> </span><span class="token operator">>></span><span class="token plain"> ~/.zshrc</span><br></span></code></pre></div></div>
|
||
<p>And then restart your shell or run:</p>
|
||
<div class="language-bash codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-bash codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token builtin class-name" style="color:rgb(189, 147, 249)">source</span><span class="token plain"> ~/.zshrc</span><br></span></code></pre></div></div>
|
||
<h3 class="anchor anchorWithStickyNavbar_Fogf" id="bash">Bash<a href="#bash" class="hash-link" aria-label="Direct link to Bash" title="Direct link to Bash"></a></h3>
|
||
<p>To enable shell integration for bash, run:</p>
|
||
<div class="language-bash codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-bash codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token builtin class-name" style="color:rgb(189, 147, 249)">echo</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'eval "$(tv init bash)"'</span><span class="token plain"> </span><span class="token operator">>></span><span class="token plain"> ~/.bashrc</span><br></span></code></pre></div></div>
|
||
<p>And then restart your shell or run:</p>
|
||
<div class="language-bash codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-bash codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token builtin class-name" style="color:rgb(189, 147, 249)">source</span><span class="token plain"> ~/.bashrc</span><br></span></code></pre></div></div>
|
||
<h3 class="anchor anchorWithStickyNavbar_Fogf" id="fish">Fish<a href="#fish" class="hash-link" aria-label="Direct link to Fish" title="Direct link to Fish"></a></h3>
|
||
<p>To enable shell integration for fish, add:</p>
|
||
<div class="language-bash codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-bash codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token plain">tv init fish </span><span class="token operator">|</span><span class="token plain"> </span><span class="token builtin class-name" style="color:rgb(189, 147, 249)">source</span><br></span></code></pre></div></div>
|
||
<p>to your <code>is-interactive</code> block in your <code>~/.config/fish/config.fish</code> file and then restart your shell.</p>
|
||
<h3 class="anchor anchorWithStickyNavbar_Fogf" id="nushell">Nushell<a href="#nushell" class="hash-link" aria-label="Direct link to Nushell" title="Direct link to Nushell"></a></h3>
|
||
<p>To enable shell integration for nu, add this to your <code>~/.config/nushell/config.nu</code> file:</p>
|
||
<div class="language-nu codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-nu codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token plain">mkdir ($nu.data-dir | path join "vendor/autoload")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">tv init nu | save -f ($nu.data-dir | path join "vendor/autoload/tv.nu")</span><br></span></code></pre></div></div>
|
||
<h2 class="anchor anchorWithStickyNavbar_Fogf" id="configuring-autocompletion">Configuring autocompletion<a href="#configuring-autocompletion" class="hash-link" aria-label="Direct link to Configuring autocompletion" title="Direct link to Configuring autocompletion"></a></h2>
|
||
<p>Shell integration works by setting a dedicated shell keybinding that launches <code>tv</code> with the current prompt buffer so that <code>tv</code> may guess which channel (builtin or cable) is the most appropriate.</p>
|
||
<p>Which channel gets effectively chosen for different commands can be tweaked in the <code>shell_integration</code> section of the <a href="https://github.com/alexpasmantier/television/wiki/Configuration-file" target="_blank" rel="noopener noreferrer">configuration file</a>:</p>
|
||
<div class="language-toml codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-toml codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token punctuation" style="color:rgb(248, 248, 242)">[</span><span class="token table class-name">shell_integration.channel_triggers</span><span class="token punctuation" style="color:rgb(248, 248, 242)">]</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token key property">"env"</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">[</span><span class="token string" style="color:rgb(255, 121, 198)">"export"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">"unset"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">]</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token key property">"dirs"</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">[</span><span class="token string" style="color:rgb(255, 121, 198)">"cd"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">"ls"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">"rmdir"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">]</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token key property">"files"</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">[</span><span class="token string" style="color:rgb(255, 121, 198)">"mv"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">"cp"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">"vim"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">]</span><br></span></code></pre></div></div>
|
||
<p>Each key is a channel name and each value is a set of commands that should trigger that channel.</p>
|
||
<p>Example: say you want the following prompts to trigger the following channels when pressing <kbd>CTRL-T</kbd>`:</p>
|
||
<ul>
|
||
<li><code>git checkout</code> should trigger the <code>git-branches</code> channel</li>
|
||
<li><code>ls</code> should trigger the <code>dirs</code> channel</li>
|
||
<li><code>cat</code> and <code>nano</code> should trigger the <code>files</code> channel</li>
|
||
</ul>
|
||
<p>You would add the following to your configuration file:</p>
|
||
<div class="language-toml codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-toml codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token punctuation" style="color:rgb(248, 248, 242)">[</span><span class="token table class-name">shell_integration.channel_triggers</span><span class="token punctuation" style="color:rgb(248, 248, 242)">]</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token key property">"git-branches"</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">[</span><span class="token string" style="color:rgb(255, 121, 198)">"git checkout"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">]</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token key property">"dirs"</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">[</span><span class="token string" style="color:rgb(255, 121, 198)">"ls"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">]</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token key property">"files"</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">[</span><span class="token string" style="color:rgb(255, 121, 198)">"cat"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">"nano"</span><span class="token punctuation" style="color:rgb(248, 248, 242)">]</span><br></span></code></pre></div></div>
|
||
<h2 class="anchor anchorWithStickyNavbar_Fogf" id="customizing-shell-integration-scripts">Customizing shell integration scripts<a href="#customizing-shell-integration-scripts" class="hash-link" aria-label="Direct link to Customizing shell integration scripts" title="Direct link to Customizing shell integration scripts"></a></h2>
|
||
<h3 class="anchor anchorWithStickyNavbar_Fogf" id="setting-up-the-files">Setting up the files<a href="#setting-up-the-files" class="hash-link" aria-label="Direct link to Setting up the files" title="Direct link to Setting up the files"></a></h3>
|
||
<p>To customize the default behavior of the shell integration scripts you can save them locally and source that file instead:</p>
|
||
<p>Run the following command to make sure the destination directory exists, you can also store them wherever you like</p>
|
||
<div class="language-shell codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-shell codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token function" style="color:rgb(80, 250, 123)">mkdir</span><span class="token plain"> </span><span class="token parameter variable" style="color:rgb(189, 147, 249);font-style:italic">-p</span><span class="token plain"> ~/.config/television/shell</span><br></span></code></pre></div></div>
|
||
<p><em>Note:</em> Remember to remove the line added in <a href="https://github.com/alexpasmantier/television/wiki/Shell-Autocompletion#enabling-shell-integration" target="_blank" rel="noopener noreferrer">Enabling Shell Integration</a> to avoid sourcing the file twice.</p>
|
||
<h4 class="anchor anchorWithStickyNavbar_Fogf" id="zsh-1">Zsh<a href="#zsh-1" class="hash-link" aria-label="Direct link to Zsh" title="Direct link to Zsh"></a></h4>
|
||
<div class="language-shell codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-shell codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token plain">tv init </span><span class="token function" style="color:rgb(80, 250, 123)">zsh</span><span class="token plain"> </span><span class="token operator">></span><span class="token plain"> ~/.config/television/shell/integration.zsh</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token builtin class-name" style="color:rgb(189, 147, 249)">echo</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'source $HOME/.config/television/shell/integration.zsh'</span><span class="token plain"> </span><span class="token operator">>></span><span class="token plain"> ~/.zshrc</span><br></span></code></pre></div></div>
|
||
<h4 class="anchor anchorWithStickyNavbar_Fogf" id="bash-1">Bash<a href="#bash-1" class="hash-link" aria-label="Direct link to Bash" title="Direct link to Bash"></a></h4>
|
||
<div class="language-shell codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-shell codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token plain">tv init </span><span class="token function" style="color:rgb(80, 250, 123)">bash</span><span class="token plain"> </span><span class="token operator">></span><span class="token plain"> ~/.config/television/shell/integration.bash</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token builtin class-name" style="color:rgb(189, 147, 249)">echo</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">'source $HOME/.config/television/shell/integration.bash'</span><span class="token plain"> </span><span class="token operator">>></span><span class="token plain"> ~/.bashrc</span><br></span></code></pre></div></div>
|
||
<h4 class="anchor anchorWithStickyNavbar_Fogf" id="fish-1">Fish<a href="#fish-1" class="hash-link" aria-label="Direct link to Fish" title="Direct link to Fish"></a></h4>
|
||
<div class="language-shell codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-shell codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token plain">tv init fish </span><span class="token operator">></span><span class="token plain"> ~/.config/television/shell/integration.fish</span><br></span></code></pre></div></div>
|
||
<p>Then add to your <code>is-interactive</code> block in your <code>~/.config/fish/config.fish</code> file.</p>
|
||
<div class="language-fish codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-fish codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token plain">source $HOME/.config/television/shell/integration.fish</span><br></span></code></pre></div></div>
|
||
<p>For all shells you'll have to restart it (or similar) to integrate the changes.</p>
|
||
<h3 class="anchor anchorWithStickyNavbar_Fogf" id="recipes">Recipes<a href="#recipes" class="hash-link" aria-label="Direct link to Recipes" title="Direct link to Recipes"></a></h3>
|
||
<h4 class="anchor anchorWithStickyNavbar_Fogf" id="automatically-executing-selection">Automatically executing selection<a href="#automatically-executing-selection" class="hash-link" aria-label="Direct link to Automatically executing selection" title="Direct link to Automatically executing selection"></a></h4>
|
||
<p>Edit the <code>~/.config/television/shell/integration.zsh</code> file and add the following:</p>
|
||
<div class="language-zsh codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-zsh codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token plain">_tv_search() {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> emulate -L zsh</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> zle -I</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> local current_prompt</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> current_prompt=$LBUFFER</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> local output</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> output=$(tv --autocomplete-prompt "$current_prompt" $*)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> zle reset-prompt</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> if [[ -n $output ]]; then</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> RBUFFER=""</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> LBUFFER=$current_prompt$output</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> # uncomment this to automatically accept the line</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> # (i.e. run the command without having to press enter twice)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> # zle accept-line</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> fi</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">}</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">zle -N tv-search _tv_search</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">bindkey '^T' tv-search</span><br></span></code></pre></div></div>
|
||
<p>Note: Uncommenting <code>zle accept-line</code> below will automatically execute the command when accepting a suggestion</p>
|
||
<h4 class="anchor anchorWithStickyNavbar_Fogf" id="open-history-channel-with-the-most-up-to-date-version-of-the-history-file">Open history channel with the most up to date version of the history file<a href="#open-history-channel-with-the-most-up-to-date-version-of-the-history-file" class="hash-link" aria-label="Direct link to Open history channel with the most up to date version of the history file" title="Direct link to Open history channel with the most up to date version of the history file"></a></h4>
|
||
<p>Edit the <code>~/.config/television/shell/integration.bash</code> file and replace the <code>tv_shell_history</code> function with the following (or rename to keep the default implementation):</p>
|
||
<div class="language-bash codeBlockContainer_MbdR theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_WPSJ"><pre tabindex="0" class="prism-code language-bash codeBlock_ke8T thin-scrollbar" style="color:#F8F8F2;background-color:#282A36"><code class="codeBlockLines_oe7S"><span class="token-line" style="color:#F8F8F2"><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">function</span><span class="token plain"> </span><span class="token function-name function" style="color:rgb(80, 250, 123)">tv_shell_history</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token builtin class-name" style="color:rgb(189, 147, 249)">local</span><span class="token plain"> </span><span class="token assign-left variable" style="color:rgb(189, 147, 249);font-style:italic">current_prompt</span><span class="token operator">=</span><span class="token string" style="color:rgb(255, 121, 198)">"</span><span class="token string variable" style="color:rgb(189, 147, 249);font-style:italic">${READLINE_LINE</span><span class="token string variable operator" style="color:rgb(189, 147, 249);font-style:italic">:</span><span class="token string variable" style="color:rgb(189, 147, 249);font-style:italic">0</span><span class="token string variable operator" style="color:rgb(189, 147, 249);font-style:italic">:</span><span class="token string variable" style="color:rgb(189, 147, 249);font-style:italic">$READLINE_POINT}</span><span class="token string" style="color:rgb(255, 121, 198)">"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token builtin class-name" style="color:rgb(189, 147, 249)">local</span><span class="token plain"> </span><span class="token assign-left variable" style="color:rgb(189, 147, 249);font-style:italic">output</span><span class="token operator">=</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic">$(</span><span class="token variable function" style="color:rgb(80, 250, 123);font-style:italic">history</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic"> </span><span class="token variable parameter variable" style="color:rgb(189, 147, 249);font-style:italic">-n</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic"> </span><span class="token variable operator" style="color:rgb(189, 147, 249);font-style:italic">&&</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic"> </span><span class="token variable function" style="color:rgb(80, 250, 123);font-style:italic">history</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic"> </span><span class="token variable parameter variable" style="color:rgb(189, 147, 249);font-style:italic">-a</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic"> </span><span class="token variable operator" style="color:rgb(189, 147, 249);font-style:italic">&&</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic"> tv bash-history </span><span class="token variable parameter variable" style="color:rgb(189, 147, 249);font-style:italic">--input</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic"> </span><span class="token variable string" style="color:rgb(255, 121, 198);font-style:italic">"</span><span class="token variable string variable" style="color:rgb(189, 147, 249);font-style:italic">$current_prompt</span><span class="token variable string" style="color:rgb(255, 121, 198);font-style:italic">"</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">[</span><span class="token punctuation" style="color:rgb(248, 248, 242)">[</span><span class="token plain"> </span><span class="token parameter variable" style="color:rgb(189, 147, 249);font-style:italic">-n</span><span class="token plain"> </span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic">$output</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">]</span><span class="token punctuation" style="color:rgb(248, 248, 242)">]</span><span class="token punctuation" style="color:rgb(248, 248, 242)">;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">then</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token assign-left variable" style="color:rgb(189, 147, 249);font-style:italic">READLINE_LINE</span><span class="token operator">=</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic">$output</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token assign-left variable" style="color:rgb(189, 147, 249);font-style:italic">READLINE_POINT</span><span class="token operator">=</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic">${</span><span class="token variable operator" style="color:rgb(189, 147, 249);font-style:italic">#</span><span class="token variable" style="color:rgb(189, 147, 249);font-style:italic">READLINE_LINE}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">fi</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token punctuation" style="color:rgb(248, 248, 242)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token comment" style="color:rgb(98, 114, 164)"># history -n to read the current file, in case other sessions wrote some commands</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token comment" style="color:rgb(98, 114, 164)"># history -a to commit the current one</span><br></span></code></pre></div></div>
|
||
<p><strong>WARNING:</strong> committing the current history to file could have unintended consequences as a default, for example if the user was planning to run <code>history -c</code> to clear the current session (perhaps some commands have sensitive information)</p></div></article><nav class="docusaurus-mt-lg pagination-nav" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/television/docs/Users/keybindings"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Keybindings</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/television/docs/Users/search-patterns"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Search Patterns</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_sLnf thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#keybindings" class="table-of-contents__link toc-highlight">Keybindings</a></li><li><a href="#enabling-shell-integration" class="table-of-contents__link toc-highlight">Enabling shell integration</a><ul><li><a href="#zsh" class="table-of-contents__link toc-highlight">Zsh</a></li><li><a href="#bash" class="table-of-contents__link toc-highlight">Bash</a></li><li><a href="#fish" class="table-of-contents__link toc-highlight">Fish</a></li><li><a href="#nushell" class="table-of-contents__link toc-highlight">Nushell</a></li></ul></li><li><a href="#configuring-autocompletion" class="table-of-contents__link toc-highlight">Configuring autocompletion</a></li><li><a href="#customizing-shell-integration-scripts" class="table-of-contents__link toc-highlight">Customizing shell integration scripts</a><ul><li><a href="#setting-up-the-files" class="table-of-contents__link toc-highlight">Setting up the files</a></li><li><a href="#recipes" class="table-of-contents__link toc-highlight">Recipes</a></li></ul></li></ul></div></div></div></div></main></div></div></div><footer class="theme-layout-footer footer"><div class="container container-fluid"><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2025 alexpasmantier</div></div></div></footer></div>
|
||
</body>
|
||
</html> |