xplr/en/message.html

746 lines
52 KiB
HTML

<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Message - xplr book</title>
<!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="A hackable, minimal, fast TUI file explorer">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css">
<link rel="stylesheet" href="tomorrow-night.css">
<link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="quickstart.html"><strong aria-hidden="true">2.</strong> Quickstart</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="install.html"><strong aria-hidden="true">2.1.</strong> Install</a></li><li class="chapter-item expanded "><a href="post-install.html"><strong aria-hidden="true">2.2.</strong> Post Install</a></li></ol></li><li class="chapter-item expanded "><a href="configuration.html"><strong aria-hidden="true">3.</strong> Configuration</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="general-config.html"><strong aria-hidden="true">3.1.</strong> General Config</a></li><li class="chapter-item expanded "><a href="modes.html"><strong aria-hidden="true">3.2.</strong> Modes</a></li><li class="chapter-item expanded "><a href="message.html" class="active"><strong aria-hidden="true">3.3.</strong> Message</a></li><li class="chapter-item expanded "><a href="layouts.html"><strong aria-hidden="true">3.4.</strong> Layouts</a></li><li class="chapter-item expanded "><a href="node_types.html"><strong aria-hidden="true">3.5.</strong> Node Types</a></li><li class="chapter-item expanded "><a href="style.html"><strong aria-hidden="true">3.6.</strong> Style</a></li><li class="chapter-item expanded "><a href="sorting.html"><strong aria-hidden="true">3.7.</strong> Sorting</a></li><li class="chapter-item expanded "><a href="filtering.html"><strong aria-hidden="true">3.8.</strong> Filtering</a></li></ol></li><li class="chapter-item expanded "><a href="default-key-bindings.html"><strong aria-hidden="true">4.</strong> Default Key Bindings</a></li><li class="chapter-item expanded "><a href="plugin.html"><strong aria-hidden="true">5.</strong> Plugin</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="installing-plugins.html"><strong aria-hidden="true">5.1.</strong> Installing Plugins</a></li><li class="chapter-item expanded "><a href="writing-plugins.html"><strong aria-hidden="true">5.2.</strong> Writing Plugins</a></li><li class="chapter-item expanded "><a href="awesome-plugins.html"><strong aria-hidden="true">5.3.</strong> Awesome Plugins</a></li></ol></li><li class="chapter-item expanded "><a href="integration.html"><strong aria-hidden="true">6.</strong> Integration</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="awesome-integrations.html"><strong aria-hidden="true">6.1.</strong> Awesome Integrations</a></li></ol></li><li class="chapter-item expanded "><a href="todo.html"><strong aria-hidden="true">7.</strong> TODO</a></li><li class="chapter-item expanded "><a href="alternatives.html"><strong aria-hidden="true">8.</strong> Alternatives</a></li><li class="chapter-item expanded "><a href="upgrade-guide.html"><strong aria-hidden="true">9.</strong> Upgrade Guide</a></li><li class="chapter-item expanded "><a href="community.html"><strong aria-hidden="true">10.</strong> Community</a></li><li class="chapter-item expanded "><a href="contribute.html"><strong aria-hidden="true">11.</strong> Contribute</a></li></ol> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">xplr book</h1>
<div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
<a href="https://github.com/sayanarijit/xplr" title="Git repository" aria-label="Git repository">
<i id="git-repository-button" class="fa fa-github"></i>
</a>
<a href="https://github.com/sayanarijit/xplr/edit/main/docs/en/src/message.md" title="Suggest an edit" aria-label="Suggest an edit">
<i id="git-edit-button" class="fa fa-edit"></i>
</a>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1 id="message"><a class="header" href="#message">Message</a></h1>
<p>You can think of xplr as a server. Just like web servers listen to HTTP
requests, xplr listens to <a href="#full-list-of-messages">messages</a>.</p>
<p>You can send these messages to an xplr session in the following ways:</p>
<ul>
<li>Via <a href="modes.html#key-bindings">key bindings</a></li>
<li>Via <a href="#lua-function-calls">Lua function calls</a></li>
<li>Via shell command using the <a href="#input-pipe">input pipe</a></li>
</ul>
<h2 id="format"><a class="header" href="#format">Format</a></h2>
<p>To send messages using the <a href="modes.html#key-bindings">key bindings</a> or
<a href="#lua-function-calls">Lua function calls</a>, messages are represented in
<a href="https://www.lua.org/">Lua</a> syntax. For example:</p>
<ul>
<li>&quot;Quit&quot;</li>
<li>{ FocusPath = &quot;/path/to/file&quot; }</li>
<li>{ Call = { command = &quot;bash&quot;, args = { &quot;-c&quot;, &quot;read -p test&quot; } } }</li>
</ul>
<p>However, to send messages using the <a href="#input-pipe">input pipe</a>, they need to be
represented using
<a href="http://yaml.org/">YAML</a> (or <a href="https://www.json.org">JSON</a>) syntax. For example:</p>
<ul>
<li>Quit</li>
<li>FocusPath: &quot;/path/to/file&quot;</li>
<li>Call: { command: bash, args: [&quot;-c&quot;, &quot;read -p test&quot;] }</li>
</ul>
<h2 id="full-list-of-messages"><a class="header" href="#full-list-of-messages">Full List of Messages</a></h2>
<h3 id="explorepwd"><a class="header" href="#explorepwd">&quot;ExplorePwd&quot;</a></h3>
<p><strong>YAML:</strong> <code>ExplorePwd</code></p>
<p>Explore the present working directory and register the filtered nodes.
This operation is expensive. So, try to avoid using it too often.</p>
<h3 id="explorepwdasync"><a class="header" href="#explorepwdasync">&quot;ExplorePwdAsync&quot;</a></h3>
<p><strong>YAML:</strong> <code>ExplorePwdAsync</code></p>
<p>Explore the present working directory and register the filtered nodes asynchronously.
This operation happens asynchronously. That means, the xplr directory buffers won't be updated
immediately. Hence, it needs to be used with care and probably with special checks in place.
To explore <code>$PWD</code> synchronously, use <code>ExplorePwd</code> instead.</p>
<h3 id="exploreparentsasync"><a class="header" href="#exploreparentsasync">&quot;ExploreParentsAsync&quot;</a></h3>
<p><strong>YAML:</strong> <code>ExploreParentsAsync</code></p>
<p>Explore the present working directory along with its parents and register the filtered nodes.
This operation happens asynchronously. That means, the xplr directory buffers won't be updated
immediately. Hence, it needs to be used with care and probably with special checks in place.
To explore just the <code>$PWD</code> synchronously, use <code>ExplorePwd</code> instead.</p>
<h3 id="refresh"><a class="header" href="#refresh">&quot;Refresh&quot;</a></h3>
<p><strong>YAML:</strong> <code>Refresh</code></p>
<p>Refresh the UI.
But it will not re-explore the directory if the working directory is the same.
If there is some change in the working directory and you want to re-explore it,
use the <code>Explore</code> message instead.
Also, it will not clear the screen. Use <code>ClearScreen</code> for that.</p>
<h3 id="clearscreen"><a class="header" href="#clearscreen">&quot;ClearScreen&quot;</a></h3>
<p><strong>YAML:</strong> <code>ClearScreen</code></p>
<p>Clears the screen.</p>
<h3 id="focusnext"><a class="header" href="#focusnext">&quot;FocusNext&quot;</a></h3>
<p><strong>YAML:</strong> <code>FocusNext</code></p>
<p>Focus next node.</p>
<h3 id="-focusnextbyrelativeindex--int-"><a class="header" href="#-focusnextbyrelativeindex--int-">{ FocusNextByRelativeIndex = int }</a></h3>
<p><strong>YAML:</strong> <code>FocusNextByRelativeIndex: int</code></p>
<p>Focus on the <code>n</code>th node relative to the current focus where <code>n</code> is a given value.</p>
<p><strong>YAML Example:</strong> <code>FocusNextByRelativeIndex: 2</code></p>
<p><strong>Lua Example:</strong> <code>{ FocusNextByRelativeIndex = 2 }</code></p>
<h3 id="focusnextbyrelativeindexfrominput"><a class="header" href="#focusnextbyrelativeindexfrominput">&quot;FocusNextByRelativeIndexFromInput&quot;</a></h3>
<p><strong>YAML:</strong> <code>FocusNextByRelativeIndexFromInput</code></p>
<p>Focus on the <code>n</code>th node relative to the current focus where <code>n</code> is read from
the input buffer.</p>
<h3 id="focusprevious"><a class="header" href="#focusprevious">&quot;FocusPrevious&quot;</a></h3>
<p><strong>YAML:</strong> <code>FocusPrevious</code></p>
<p>Focus on the previous item.</p>
<h3 id="-focuspreviousbyrelativeindex--int-"><a class="header" href="#-focuspreviousbyrelativeindex--int-">{ FocusPreviousByRelativeIndex = int }</a></h3>
<p><strong>YAML:</strong> <code>FocusPreviousByRelativeIndex: int</code></p>
<p>Focus on the <code>-n</code>th node relative to the current focus where <code>n</code> is a given value.</p>
<p><strong>YAML Example:</strong> <code>FocusPreviousByRelativeIndex: 2</code></p>
<p><strong>Lua Example:</strong> <code>{ FocusPreviousByRelativeIndex = 2 }</code></p>
<h3 id="focuspreviousbyrelativeindexfrominput"><a class="header" href="#focuspreviousbyrelativeindexfrominput">&quot;FocusPreviousByRelativeIndexFromInput&quot;</a></h3>
<p><strong>YAML:</strong> <code>FocusPreviousByRelativeIndexFromInput</code></p>
<p>Focus on the <code>-n</code>th node relative to the current focus where <code>n</code> is read from
the input buffer.</p>
<h3 id="focusfirst"><a class="header" href="#focusfirst">&quot;FocusFirst&quot;</a></h3>
<p><strong>YAML:</strong> <code>FocusFirst</code></p>
<p>Focus on the first node.</p>
<h3 id="focuslast"><a class="header" href="#focuslast">&quot;FocusLast&quot;</a></h3>
<p><strong>YAML:</strong> <code>FocusLast</code></p>
<p>Focus on the last node.</p>
<h3 id="-focuspath--string-"><a class="header" href="#-focuspath--string-">{ FocusPath = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>FocusPath: string</code></p>
<p>Focus on the given path.</p>
<p><strong>YAML Example:</strong> <code>FocusPath: /path/to/file</code></p>
<p><strong>Lua Example:</strong> <code>{ FocusPath = &quot;/path/to/file&quot; }</code></p>
<h3 id="focuspathfrominput"><a class="header" href="#focuspathfrominput">&quot;FocusPathFromInput&quot;</a></h3>
<p><strong>YAML:</strong> <code>FocusPathFromInput</code></p>
<p>Focus on the path read from input buffer.</p>
<h3 id="-focusbyindex--int-"><a class="header" href="#-focusbyindex--int-">{ FocusByIndex = int }</a></h3>
<p><strong>YAML:</strong> <code>FocusByIndex: int</code></p>
<p>Focus on the absolute <code>n</code>th node where <code>n</code> is a given value.</p>
<p><strong>YAML Example:</strong> <code>FocusByIndex: 2</code></p>
<p><strong>Lua Example:</strong> <code>{ FocusByIndex = 2 }</code></p>
<h3 id="focusbyindexfrominput"><a class="header" href="#focusbyindexfrominput">&quot;FocusByIndexFromInput&quot;</a></h3>
<p><strong>YAML:</strong> <code>FocusByIndexFromInput</code></p>
<p>Focus on the absolute <code>n</code>th node where <code>n</code> is read from the input buffer.</p>
<h3 id="-focusbyfilename--string-"><a class="header" href="#-focusbyfilename--string-">{ FocusByFileName = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>FocusByFileName: string</code></p>
<p>Focus on the file by name from the present working directory.</p>
<p><strong>YAML Example:</strong> <code>FocusByFileName: filename.ext</code></p>
<p><strong>Lua Example:</strong> <code>{ FocusByFileName = &quot;filename.ext&quot; }</code></p>
<h3 id="-changedirectory--string-"><a class="header" href="#-changedirectory--string-">{ ChangeDirectory = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>ChangeDirectory: string</code></p>
<p>Change the present working directory ($PWD)</p>
<p><strong>YAML Example:</strong> <code>ChangeDirectory: /path/to/directory</code></p>
<p><strong>Lua Example:</strong> <code>{ ChangeDirectory = &quot;/path/to/directory&quot; }</code></p>
<h3 id="enter"><a class="header" href="#enter">&quot;Enter&quot;</a></h3>
<p><strong>YAML:</strong> <code>Enter</code></p>
<p>Enter into the currently focused path if it's a directory.</p>
<h3 id="back"><a class="header" href="#back">&quot;Back&quot;</a></h3>
<p><strong>YAML:</strong> <code>Back</code></p>
<p>Go back to the parent directory.</p>
<h3 id="lastvisitedpath"><a class="header" href="#lastvisitedpath">&quot;LastVisitedPath&quot;</a></h3>
<p><strong>YAML:</strong> <code>LastVisitedPath</code></p>
<p>Go to the last path visited.</p>
<h3 id="nextvisitedpath"><a class="header" href="#nextvisitedpath">&quot;NextVisitedPath&quot;</a></h3>
<p><strong>YAML:</strong> <code>NextVisitedPath</code></p>
<p>Go to the next path visited.</p>
<h3 id="followsymlink"><a class="header" href="#followsymlink">&quot;FollowSymlink&quot;</a></h3>
<p><strong>YAML:</strong> <code>FollowSymlink</code></p>
<p>Follow the symlink under focus to its actual location.</p>
<h3 id="-bufferinput--string-"><a class="header" href="#-bufferinput--string-">{ BufferInput = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>BufferInput(String)</code></p>
<p>Append/buffer the given string into the input buffer.</p>
<p><strong>YAML Example:</strong> <code>BufferInput: foo</code></p>
<p><strong>Lua Example:</strong> <code>{ BufferInput = &quot;foo&quot; }</code></p>
<h3 id="bufferinputfromkey"><a class="header" href="#bufferinputfromkey">&quot;BufferInputFromKey&quot;</a></h3>
<p><strong>YAML:</strong> <code>BufferInputFromKey</code></p>
<p>Append/buffer the characted read from a keyboard input into the
input buffer.</p>
<h3 id="-setinputbuffer--string-"><a class="header" href="#-setinputbuffer--string-">{ SetInputBuffer = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>SetInputBuffer: string</code></p>
<p>Set/rewrite the input buffer with the given string.
When the input buffer is not-null (even if empty string)
it will show in the UI.</p>
<p><strong>YAML Example:</strong> <code>SetInputBuffer: foo</code></p>
<p><strong>Lua Example:</strong> <code>{ SetInputBuffer = &quot;foo&quot; }</code></p>
<h3 id="removeinputbufferlastcharacter"><a class="header" href="#removeinputbufferlastcharacter">&quot;RemoveInputBufferLastCharacter&quot;</a></h3>
<p><strong>YAML:</strong> <code>RemoveInputBufferLastCharacter</code></p>
<p>Remove input buffer's last character.</p>
<h3 id="removeinputbufferlastword"><a class="header" href="#removeinputbufferlastword">&quot;RemoveInputBufferLastWord&quot;</a></h3>
<p><strong>YAML:</strong> <code>RemoveInputBufferLastWord</code></p>
<p>Remove input buffer's last word.</p>
<h3 id="resetinputbuffer"><a class="header" href="#resetinputbuffer">&quot;ResetInputBuffer&quot;</a></h3>
<p><strong>YAML:</strong> <code>ResetInputBuffer</code></p>
<p>Reset the input buffer back to null. It will not show in the UI.</p>
<h3 id="-switchmode--string-"><a class="header" href="#-switchmode--string-">{ SwitchMode = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>SwitchMode: string</code></p>
<p>Switch input <a href="modes.html">mode</a>.</p>
<blockquote>
<p><strong>NOTE:</strong> To be specific about which mode to switch to, use <code>SwitchModeBuiltin</code> or
<code>SwitchModeCustom</code> instead.</p>
</blockquote>
<p><strong>YAML Example:</strong> <code>SwitchMode: default</code></p>
<p><strong>Lua Example:</strong> <code>{ SwitchMode = &quot;default&quot; }</code></p>
<h3 id="-switchmodebuiltin--string-"><a class="header" href="#-switchmodebuiltin--string-">{ SwitchModeBuiltin = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>SwitchModeBuiltin: string</code></p>
<p>Switch to a <a href="modes.html#builtin">builtin mode</a>.</p>
<p><strong>YAML Example:</strong> <code>SwitchModeBuiltin: default</code></p>
<p><strong>Lua Example:</strong> <code>{ SwitchModeBuiltin = &quot;default&quot; }</code></p>
<h3 id="-switchmodecustom--string-"><a class="header" href="#-switchmodecustom--string-">{ SwitchModeCustom = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>SwitchModeCustom: string</code></p>
<p>Switch to a <a href="modes.html#custom">custom mode</a>.</p>
<p><strong>YAML Example:</strong> <code>SwitchModeCustom: my_custom_mode</code></p>
<p><strong>Lua Example:</strong> <code>{ SwitchModeCustom = &quot;my_custom_mode&quot; }</code></p>
<h3 id="popmode"><a class="header" href="#popmode">&quot;PopMode&quot;</a></h3>
<p><strong>YAML:</strong> <code>PopMode</code></p>
<p>Pop the last mode from the history and switch to it.</p>
<h3 id="-switchlayout--string-"><a class="header" href="#-switchlayout--string-">{ SwitchLayout = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>SwitchLayout: string</code></p>
<p>Switch <a href="layouts.html">layout</a>.</p>
<blockquote>
<p><strong>NOTE:</strong> To be specific about which layout to switch to, use <code>SwitchLayoutBuiltin</code> or
<code>SwitchLayoutCustom</code> instead.</p>
</blockquote>
<p><strong>YAML Example:</strong> <code>SwitchLayout: default</code></p>
<p><strong>Lua Example:</strong> <code>{ SwitchLayout = &quot;default&quot; }</code></p>
<h3 id="-switchlayoutbuiltin--string-"><a class="header" href="#-switchlayoutbuiltin--string-">{ SwitchLayoutBuiltin = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>SwitchLayoutBuiltin: string</code></p>
<p>Switch to a <a href="layouts.html#builtin">builtin layout</a>.</p>
<p><strong>YAML Example:</strong> <code>SwitchLayoutBuiltin: default</code></p>
<p><strong>Lua Example:</strong> <code>{ SwitchLayoutBuiltin = &quot;default&quot; }</code></p>
<h3 id="-switchlayoutcustom--string-"><a class="header" href="#-switchlayoutcustom--string-">{ SwitchLayoutCustom = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>SwitchLayoutCustom: string</code></p>
<p>Switch to a <a href="layouts.html#custom">custom layout</a>.</p>
<p><strong>YAML Example:</strong> <code>SwitchLayoutCustom: my_custom_layout</code></p>
<p><strong>Lua Example:</strong> <code>{ SwitchLayoutCustom = &quot;my_custom_layout&quot; }</code></p>
<h3 id="-call--string-"><a class="header" href="#-call--string-">{ Call = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>Call: string</code></p>
<p>Call a shell command with the given arguments.
Note that the arguments will be shell-escaped.
So to read the variables, the <code>-c</code> option of the shell
can be used.
You may need to pass <code>ExplorePwd</code> depening on the expectation.</p>
<p><strong>YAML Example:</strong> <code>Call: { command: bash, args: [&quot;-c&quot;, &quot;read -p test&quot;] }</code></p>
<p><strong>Lua Example:</strong> <code>{ Call = { command = &quot;bash&quot;, args = { &quot;-c&quot;, &quot;read -p test&quot; } } }</code></p>
<h3 id="-callsilently--string-"><a class="header" href="#-callsilently--string-">{ CallSilently = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>CallSilently: string</code></p>
<p>Like <code>Call</code> but without the flicker. The stdin, stdout
stderr will be piped to null. So it's non-interactive.</p>
<p><strong>YAML Example:</strong> <code>CallSilently: { command: tput, args: [&quot;bell&quot;] }</code></p>
<p><strong>Lua Example:</strong> <code>{ CallSilently = { command = &quot;tput&quot;, args = { &quot;bell&quot; } } }</code></p>
<h3 id="-calllua--string-"><a class="header" href="#-calllua--string-">{ CallLua = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>CallLua: string</code></p>
<p>Call a Lua function.
A <a href="#calllua-argument"><code>CallLuaArg</code></a> object will be passed to the
<a href="#lua-function-calls">function</a> as argument.
The function can optionally return a list of messages for xplr to handle
after the executing the function.</p>
<p><strong>YAML Example:</strong> <code>CallLua: custom.some_custom_funtion</code></p>
<p><strong>Lua Example:</strong> <code>{ CallLua = &quot;custom.some_custom_funtion&quot; }</code></p>
<h3 id="-callluasilently--string-"><a class="header" href="#-callluasilently--string-">{ CallLuaSilently = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>CallLuaSilently: string</code></p>
<p>Like <code>CallLua</code> but without the flicker. The stdin, stdout
stderr will be piped to null. So it's non-interactive.</p>
<p><strong>YAML Example:</strong> <code>CallLuaSilently: custom.some_custom_function</code></p>
<p><strong>Lua Example:</strong> <code>{ CallLuaSilently = &quot;custom.some_custom_function&quot; }</code></p>
<h3 id="-bashexec--string-"><a class="header" href="#-bashexec--string-">{ BashExec = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>BashExec: string</code></p>
<p>An alias to <code>Call: {command: bash, args: [&quot;-c&quot;, &quot;{string}&quot;], silent: false}</code>
where <code>{string}</code> is the given value.</p>
<p><strong>YAML Example:</strong> <code>BashExec: &quot;read -p test&quot;</code></p>
<p><strong>Lua Example:</strong> <code>{ BashExec = &quot;read -p test&quot; }</code></p>
<h3 id="-bashexecsilently--string-"><a class="header" href="#-bashexecsilently--string-">{ BashExecSilently = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>BashExecSilently(String)</code></p>
<p>Like <code>BashExec</code> but without the flicker. The stdin, stdout
stderr will be piped to null. So it's non-interactive.</p>
<p><strong>YAML Example:</strong> <code>BashExecSilently: &quot;tput bell&quot;</code></p>
<p><strong>Lua Example:</strong> <code>{ BashExecSilently = &quot;tput bell&quot; }</code></p>
<h3 id="select"><a class="header" href="#select">&quot;Select&quot;</a></h3>
<p><strong>YAML:</strong> <code>Select</code></p>
<p>Select the focused node.</p>
<h3 id="selectall"><a class="header" href="#selectall">&quot;SelectAll&quot;</a></h3>
<p><strong>YAML:</strong> <code>SelectAll</code></p>
<p>Select all the visible nodes.</p>
<h3 id="-selectpath--string-"><a class="header" href="#-selectpath--string-">{ SelectPath = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>SelectPath: string</code></p>
<p>Select the given path.</p>
<p><strong>YAML Example:</strong> <code>SelectPath: /path/to/file</code></p>
<p><strong>Lua Example:</strong> <code>{ SelectPath = &quot;/path/to/file&quot; }</code></p>
<h3 id="unselect"><a class="header" href="#unselect">&quot;UnSelect&quot;</a></h3>
<p><strong>YAML:</strong> <code>UnSelect</code></p>
<p>Unselect the focused node.</p>
<h3 id="unselectall"><a class="header" href="#unselectall">&quot;UnSelectAll&quot;</a></h3>
<p><strong>YAML:</strong> <code>UnSelectAll</code></p>
<p>Unselect all the visible nodes.</p>
<h3 id="-unselectpath--string-"><a class="header" href="#-unselectpath--string-">{ UnSelectPath = &quot;string)&quot; }</a></h3>
<p><strong>YAML:</strong> <code>UnSelectPath: string</code></p>
<p>UnSelect the given path.</p>
<p><strong>YAML Example:</strong> <code>UnSelectPath: /path/to/file</code></p>
<p><strong>Lua Example:</strong> <code>{ UnSelectPath = &quot;/path/to/file&quot; }</code></p>
<h3 id="toggleselection"><a class="header" href="#toggleselection">&quot;ToggleSelection&quot;</a></h3>
<p><strong>YAML:</strong> <code>ToggleSelection</code></p>
<p>Toggle selection on the focused node.</p>
<h3 id="toggleselectall"><a class="header" href="#toggleselectall">&quot;ToggleSelectAll&quot;</a></h3>
<p><strong>YAML:</strong> <code>ToggleSelectAll</code></p>
<p>Toggle between select all and unselect all.</p>
<h3 id="-toggleselectionbypath--string-"><a class="header" href="#-toggleselectionbypath--string-">{ ToggleSelectionByPath = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>ToggleSelectionByPath: string</code></p>
<p>Toggle selection by file path.</p>
<p><strong>YAML Example:</strong> <code>ToggleSelectionByPath: /path/to/file</code></p>
<p><strong>Lua Example:</strong> <code>{ ToggleSelectionByPath = &quot;/path/to/file&quot; }</code></p>
<h3 id="clearselection"><a class="header" href="#clearselection">&quot;ClearSelection&quot;</a></h3>
<p><strong>YAML:</strong> <code>ClearSelection</code></p>
<p>Clear the selection.</p>
<h3 id="-addnodefilter---filter--a-hreffilteringhtmlfilterfiltera-input--string-"><a class="header" href="#-addnodefilter---filter--a-hreffilteringhtmlfilterfiltera-input--string-">{ AddNodeFilter = { filter = <a href="filtering.html#filter">Filter</a>, input = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>AddNodeFilter: { filter = Filter, input = string }</code></p>
<p>Add a <a href="filtering.html">filter</a> to exclude nodes while exploring directories.</p>
<p><strong>YAML Example:</strong> <code>AddNodeFilter: { filter: RelativePathDoesStartWith, input: foo }</code></p>
<p><strong>Lua Example:</strong> <code>{ AddNodeFilter = { filter = &quot;RelativePathDoesStartWith&quot;, input = &quot;foo&quot; } }</code></p>
<h3 id="-removenodefilter---filter--a-hreffilteringhtmlfilterfiltera-input--string-"><a class="header" href="#-removenodefilter---filter--a-hreffilteringhtmlfilterfiltera-input--string-">{ RemoveNodeFilter = { filter = <a href="filtering.html#filter">Filter</a>, input = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>RemoveNodeFilter: { filter = Filter, input = string</code></p>
<p>Remove an existing <a href="filtering.html">filter</a>.</p>
<p><strong>YAML Example:</strong> <code>RemoveNodeFilter: { filter: RelativePathDoesStartWith, input: foo }</code></p>
<p><strong>Lua Example:</strong> <code>{ RemoveNodeFilter: { filter: &quot;RelativePathDoesStartWith&quot;, input: &quot;foo&quot; } }</code></p>
<h3 id="-togglenodefilter---filter--a-hreffilteringhtmlfilterfiltera-input--string-"><a class="header" href="#-togglenodefilter---filter--a-hreffilteringhtmlfilterfiltera-input--string-">{ ToggleNodeFilter = { filter = <a href="filtering.html#filter">Filter</a>, input = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>ToggleNodeFilter: { filter = Filter, input = string }</code></p>
<p>Remove a <a href="filtering.html">filter</a> if it exists, else, add a it.</p>
<p><strong>YAML Example:</strong> <code>ToggleNodeFilter: { filter: RelativePathDoesStartWith, input: foo }</code></p>
<p><strong>Lua Example:</strong> <code>{ ToggleNodeFilter = { filter = &quot;RelativePathDoesStartWith&quot;, input = &quot;foo&quot; } }</code></p>
<h3 id="-addnodefilterfrominput--a-hreffilteringhtmlfilterfiltera-"><a class="header" href="#-addnodefilterfrominput--a-hreffilteringhtmlfilterfiltera-">{ AddNodeFilterFromInput = <a href="filtering.html#filter">Filter</a> }</a></h3>
<p><strong>YAML:</strong> <code>AddNodeFilterFromInput: Filter</code></p>
<p>Add a node <a href="filtering.html">filter</a> reading the input from the buffer.</p>
<p><strong>YAML Example:</strong> <code>AddNodeFilterFromInput: RelativePathDoesStartWith</code></p>
<p><strong>Lua Example:</strong> <code>{ AddNodeFilterFromInput = &quot;RelativePathDoesStartWith&quot; }</code></p>
<h3 id="-removenodefilterfrominput--a-hreffilteringhtmlfilterfiltera-"><a class="header" href="#-removenodefilterfrominput--a-hreffilteringhtmlfilterfiltera-">{ RemoveNodeFilterFromInput = <a href="filtering.html#filter">Filter</a> }</a></h3>
<p><strong>YAML:</strong> <code>RemoveNodeFilterFromInput: Filter</code></p>
<p>Remove a node <a href="filtering.html">filter</a> reading the input from the buffer.</p>
<p><strong>YAML Example:</strong> <code>RemoveNodeFilterFromInput: RelativePathDoesStartWith</code></p>
<p><strong>Lua Example:</strong> <code>{ RemoveNodeFilterFromInput = &quot;RelativePathDoesStartWith&quot; }</code></p>
<h3 id="removelastnodefilter"><a class="header" href="#removelastnodefilter">&quot;RemoveLastNodeFilter&quot;</a></h3>
<p><strong>YAML:</strong> <code>RemoveLastNodeFilter</code></p>
<p>Remove the last node <a href="filtering.html">filter</a>.</p>
<h3 id="resetnodefilters"><a class="header" href="#resetnodefilters">&quot;ResetNodeFilters&quot;</a></h3>
<p><strong>YAML:</strong> <code>ResetNodeFilters</code></p>
<p>Reset the node <a href="filtering.html">filters</a> back to the default configuration.</p>
<h3 id="clearnodefilters"><a class="header" href="#clearnodefilters">&quot;ClearNodeFilters&quot;</a></h3>
<p><strong>YAML:</strong> <code>ClearNodeFilters</code></p>
<p>Clear all the node <a href="filtering.html">filters</a>.</p>
<h3 id="-addnodesorter---sorter--a-hrefsortinghtmlsortersortera-reverse--bool--"><a class="header" href="#-addnodesorter---sorter--a-hrefsortinghtmlsortersortera-reverse--bool--">{ AddNodeSorter = { sorter = <a href="sorting.html#sorter">Sorter</a>, reverse = bool } }</a></h3>
<p><strong>YAML:</strong> <code>AddNodeSorter: { sorter: Sorter, reverse = bool }</code></p>
<p>Add a <a href="sorting.html#sorter">sorter</a> to sort nodes while exploring directories.</p>
<p><strong>YAML Example:</strong> <code>AddNodeSorter: { sorter: ByRelativePath, reverse: false }</code></p>
<p><strong>YAML Example:</strong> <code>{ AddNodeSorter = { sorter = &quot;ByRelativePath&quot;, reverse = false } }</code></p>
<h3 id="-removenodesorter--a-hrefsortinghtmlsortersortera-"><a class="header" href="#-removenodesorter--a-hrefsortinghtmlsortersortera-">{ RemoveNodeSorter = <a href="sorting.html#sorter">Sorter</a> }</a></h3>
<p><strong>YAML:</strong> <code>RemoveNodeSorter: Sorter</code></p>
<p>Remove an existing <a href="sorting.html#sorter">sorter</a>.</p>
<p><strong>YAML Example:</strong> <code>RemoveNodeSorter: ByRelativePath</code></p>
<p><strong>Lua Example:</strong> <code>{ RemoveNodeSorter = &quot;ByRelativePath&quot; }</code></p>
<h3 id="-reversenodesorter--a-hrefsortinghtmlsortersortera-"><a class="header" href="#-reversenodesorter--a-hrefsortinghtmlsortersortera-">{ ReverseNodeSorter = <a href="sorting.html#sorter">Sorter</a> }</a></h3>
<p><strong>YAML:</strong> <code>ReverseNodeSorter: Sorter</code></p>
<p>Reverse a node <a href="sorting.html#sorter">sorter</a>.</p>
<p><strong>YAML Example:</strong> <code>ReverseNodeSorter: ByRelativePath</code></p>
<p><strong>Lua Example:</strong> <code>{ ReverseNodeSorter = &quot;ByRelativePath&quot; }</code></p>
<h3 id="-togglenodesorter---sorter--a-hrefsortinghtmlsortersortera-reverse--bool--"><a class="header" href="#-togglenodesorter---sorter--a-hrefsortinghtmlsortersortera-reverse--bool--">{ ToggleNodeSorter = { sorter = <a href="sorting.html#sorter">Sorter</a>, reverse = bool } }</a></h3>
<p><strong>YAML:</strong> <code>ToggleNodeSorter: { sorter: Sorter, reverse = bool }</code></p>
<p>Remove a <a href="sorting.html#sorter">sorter</a> if it exists, else, add a it.</p>
<p><strong>YAML Example:</strong> <code>ToggleSorterSorter: {sorter: ByRelativePath, reverse: false }</code></p>
<p><strong>Lua Example:</strong> <code>{ ToggleSorterSorter: { sorter = &quot;ByRelativePath&quot;, reverse = false } }</code></p>
<h3 id="reversenodesorters"><a class="header" href="#reversenodesorters">&quot;ReverseNodeSorters&quot;</a></h3>
<p><strong>YAML:</strong> <code>ReverseNodeSorters</code></p>
<p>Reverse the node <a href="sorting.html#sorter">sorters</a>.</p>
<h3 id="removelastnodesorter"><a class="header" href="#removelastnodesorter">&quot;RemoveLastNodeSorter&quot;</a></h3>
<p><strong>YAML:</strong> <code>RemoveLastNodeSorter</code></p>
<p>Remove the last node <a href="sorting.html#sorter">sorter</a>.</p>
<h3 id="resetnodesorters"><a class="header" href="#resetnodesorters">&quot;ResetNodeSorters&quot;</a></h3>
<p><strong>YAML:</strong> <code>ResetNodeSorters</code></p>
<p>Reset the node <a href="sorting.html#sorter">sorters</a> back to the default configuration.</p>
<h3 id="clearnodesorters"><a class="header" href="#clearnodesorters">&quot;ClearNodeSorters&quot;</a></h3>
<p><strong>YAML:</strong> <code>ClearNodeSorters</code></p>
<p>Clear all the node <a href="sorting.html#sorter">sorters</a>.</p>
<h3 id="enablemouse"><a class="header" href="#enablemouse">&quot;EnableMouse&quot;</a></h3>
<p><strong>YAML:</strong> <code>EnableMouse</code></p>
<p>Enable mouse</p>
<h3 id="disablemouse"><a class="header" href="#disablemouse">&quot;DisableMouse&quot;</a></h3>
<p><strong>YAML:</strong> <code>DisableMouse</code></p>
<p>Disable mouse</p>
<h3 id="togglemouse"><a class="header" href="#togglemouse">&quot;ToggleMouse&quot;</a></h3>
<p><strong>YAML:</strong> <code>ToggleMouse</code></p>
<p>Toggle mouse</p>
<h3 id="-startfifo--string-"><a class="header" href="#-startfifo--string-">{ StartFifo = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>StartFifo: string</code></p>
<p>Start piping the focused path to the given fifo path</p>
<p><strong>YAML Example:</strong> <code>StartFifo: /tmp/xplr.fifo</code></p>
<p><strong>Lua Example:</strong> <code>{ StartFifo = &quot;/tmp/xplr.fifo }</code></p>
<h3 id="stopfifo"><a class="header" href="#stopfifo">&quot;StopFifo&quot;</a></h3>
<p><strong>YAML:</strong> <code>StopFifo</code></p>
<p>Close the active fifo and stop piping.</p>
<h3 id="-togglefifo--string-"><a class="header" href="#-togglefifo--string-">{ ToggleFifo = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>ToggleFifo: string</code></p>
<p>Toggle betwen {Start|Stop}Fifo</p>
<p><strong>YAML Example:</strong> <code>ToggleFifo: /path/to/fifo</code></p>
<p><strong>Lua Example:</strong> <code>{ ToggleFifo = &quot;/path/to/fifo&quot; }</code></p>
<h3 id="-loginfo--string-"><a class="header" href="#-loginfo--string-">{ LogInfo = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>LogInfo: string</code></p>
<p>Log information message.</p>
<p><strong>YAML Example:</strong> <code>LogInfo: launching satellite</code></p>
<p><strong>Lua Example:</strong> <code>{ LogInfo = &quot;launching satellite&quot; }</code></p>
<h3 id="-logsuccess--string-"><a class="header" href="#-logsuccess--string-">{ LogSuccess = &quot;String&quot; }</a></h3>
<p><strong>YAML:</strong> <code>LogSuccess: string</code></p>
<p>Log a success message.</p>
<p><strong>YAML Example:</strong> <code>LogSuccess: satellite reached destination</code>.</p>
<p><strong>Lua Example:</strong> <code>{ LogSuccess = &quot;satellite reached destination&quot; }</code>.</p>
<h3 id="-logwarning--string-"><a class="header" href="#-logwarning--string-">{ LogWarning = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>LogWarning: string</code></p>
<p>Log an warning message.</p>
<p><strong>YAML Example:</strong> <code>LogWarning: satellite is heating</code></p>
<p><strong>Lua Example:</strong> <code>{ LogWarning = &quot;satellite is heating&quot; }</code></p>
<h3 id="-logerror--string-"><a class="header" href="#-logerror--string-">{ LogError = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>LogError: string</code></p>
<p>Log an error message.</p>
<p><strong>YAML Example:</strong> <code>LogError: satellite crashed</code></p>
<p><strong>Lua Example:</strong> <code>{ LogError = &quot;satellite crashed&quot; }</code></p>
<h3 id="quit"><a class="header" href="#quit">&quot;Quit&quot;</a></h3>
<p><strong>YAML:</strong> <code>Quit</code></p>
<p>Quit with returncode zero (success).</p>
<h3 id="printpwdandquit"><a class="header" href="#printpwdandquit">&quot;PrintPwdAndQuit&quot;</a></h3>
<p><strong>YAML:</strong> <code>PrintPwdAndQuit</code></p>
<p>Print $PWD and quit.</p>
<h3 id="printfocuspathandquit"><a class="header" href="#printfocuspathandquit">&quot;PrintFocusPathAndQuit&quot;</a></h3>
<p><strong>YAML:</strong> <code>PrintFocusPathAndQuit</code></p>
<p>Print the path under focus and quit. It can be empty string if there's nothing to focus.</p>
<h3 id="printselectionandquit"><a class="header" href="#printselectionandquit">&quot;PrintSelectionAndQuit&quot;</a></h3>
<p><strong>YAML:</strong> <code>PrintSelectionAndQuit</code></p>
<p>Print the selected paths and quit. It can be empty is no path is selected.</p>
<h3 id="printresultandquit"><a class="header" href="#printresultandquit">&quot;PrintResultAndQuit&quot;</a></h3>
<p><strong>YAML:</strong> <code>PrintResultAndQuit</code></p>
<p>Print the selected paths if it's not empty, else, print the focused node's path.</p>
<h3 id="printappstateandquit"><a class="header" href="#printappstateandquit">&quot;PrintAppStateAndQuit&quot;</a></h3>
<p><strong>YAML:</strong> <code>PrintAppStateAndQuit</code></p>
<p>Print the state of application in YAML format. Helpful for debugging or generating
the default configuration file.</p>
<h3 id="-debug--string-"><a class="header" href="#-debug--string-">{ Debug = &quot;string&quot; }</a></h3>
<p><strong>YAML:</strong> <code>Debug: string</code></p>
<p>Write the application state to a file, without quitting. Also helpful for debugging.</p>
<p><strong>YAML Example:</strong> <code>Debug: /path/to/file</code></p>
<p><strong>Lua Example:</strong> <code>{ Debug = &quot;/path/to/file&quot; }</code></p>
<h3 id="terminate"><a class="header" href="#terminate">&quot;Terminate&quot;</a></h3>
<p><strong>YAML:</strong> <code>Terminate</code></p>
<p>Terminate the application with a non-zero return code.</p>
<h2 id="lua-function-calls"><a class="header" href="#lua-function-calls">Lua Function Calls</a></h2>
<p>xplr allows users to define lua functions using the <code>xplr.fn.custom</code> Lua API.</p>
<p>These functions can be called using messages like <code>CallLua</code>, <code>CallLuaSilently</code>.</p>
<p>When called the function receives a <a href="#calllua-argument">special argument</a> that
contains some useful information. The function can optionally return a list of
messages which will be handled by xplr.</p>
<h3 id="calllua-argument"><a class="header" href="#calllua-argument">CallLua Argument</a></h3>
<p>This is a special argument passed to the lua functions when called using the
<code>CallLua</code>, <code>CallLuaSilently</code> messages.</p>
<p>It contains the following information:</p>
<ul>
<li>version</li>
<li>config</li>
<li>pwd</li>
<li>focused_node</li>
<li>directory_buffer</li>
<li>selection</li>
<li>mode</li>
<li>layout</li>
<li>input_buffer</li>
<li>pid</li>
<li>session_path</li>
<li>explorer_config</li>
<li>history</li>
<li>last_modes</li>
</ul>
<p>TODO: Document each. For now, refer to the
<a href="https://docs.rs/xplr/latest/xplr/app/struct.CallLuaArg.html#fields">rust doc</a>.</p>
<h3 id="example"><a class="header" href="#example">Example:</a></h3>
<pre><code class="language-lua">-- Define the function
xplr.fn.custom.ask_name_and_greet = function(app)
print(&quot;What's your name?&quot;)
local name = io.read()
local greeting = &quot;Hello &quot; .. name .. &quot;!&quot;
local message = greeting .. &quot; You are inside &quot; .. app.pwd
return {
{ LogSuccess = message },
}
end
-- Map the function to a key (space)
xplr.config.modes.builtin.default.key_bindings.on_key.space = {
help = &quot;ask name and greet&quot;,
messages = {
{ CallLua = &quot;custom.ask_name_and_greet&quot; }
}
}
-- Now, when you press &quot;space&quot; in default mode, you will be prompted for your
-- name. Enter your name to receive a nice greeting and to know your location.
</code></pre>
<h2 id="environment-variables-and-pipes"><a class="header" href="#environment-variables-and-pipes">Environment Variables and Pipes</a></h2>
<p>Alternative to <code>CallLua</code>, <code>CallLuaSilently</code> messages that call Lua functions,
there are <code>Call</code>, <code>CallSilently</code>, <code>BashExec</code>, <code>BashExecSilently</code> messages
that call shell commands.</p>
<p>However, unlike the Lua functions, these shell commands have to read the useful
information and send messages via environment variables and temporary files
called &quot;pipe&quot;s. These environment variables and files are only available when
a command is being executed.</p>
<p>Visit the <a href="modes.html#tutorial-adding-a-new-mode"><strong>fzf integration tutorial</strong></a>
for example.</p>
<h3 id="environment-variables"><a class="header" href="#environment-variables">Environment variables</a></h3>
<p>To see the environment variables, invoke the shell by typing <code>:!</code> in default
mode and run the following command:</p>
<pre><code>env | grep ^XPLR_
</code></pre>
<p>You will see something like:</p>
<pre><code>XPLR_FOCUS_INDEX=0
XPLR_MODE=action to
XPLR_PIPE_SELECTION_OUT=/run/user/1000/xplr/session/122278/pipe/selection_out
XPLR_INPUT_BUFFER=
XPLR_PIPE_GLOBAL_HELP_MENU_OUT=/run/user/1000/xplr/session/122278/pipe/global_help_menu_out
XPLR_PID=122278
XPLR_PIPE_MSG_IN=/run/user/1000/xplr/session/122278/pipe/msg_in
XPLR_PIPE_LOGS_OUT=/run/user/1000/xplr/session/122278/pipe/logs_out
XPLR_PIPE_RESULT_OUT=/run/user/1000/xplr/session/122278/pipe/result_out
XPLR_PIPE_HISTORY_OUT=/run/user/1000/xplr/session/122278/pipe/history_out
XPLR_FOCUS_PATH=/home/sayanarijit/Documents/GitHub/xplr/docs/en/book
XPLR_SESSION_PATH=/run/user/1000/xplr/session/122278
XPLR_APP_VERSION=0.14.3
XPLR_PIPE_DIRECTORY_NODES_OUT=/run/user/1000/xplr/session/122278/pipe/directory_nodes_out
</code></pre>
<p>The environment variables starting with <code>XPLR_PIPE_</code> are the temporary files
called &quot;pipe&quot;s.</p>
<h4 id="input-pipe"><a class="header" href="#input-pipe">Input pipe</a></h4>
<p>Current there is only one input pipe.</p>
<ul>
<li><a href="#xplr_pipe_msg_in">XPLR_PIPE_MSG_IN</a></li>
</ul>
<h4 id="output-pipes"><a class="header" href="#output-pipes">Output pipes</a></h4>
<p><code>XPLR_PIPE_*_OUT</code> are the output pipes that contain data which cannot be
exposed directly via environment variables, like multi-line string.</p>
<ul>
<li><a href="#xplr_pipe_selection_out">XPLR_PIPE_SELECTION_OUT</a></li>
<li><a href="#xplr_pipe_global_help_menu_out">XPLR_PIPE_GLOBAL_HELP_MENU_OUT</a></li>
<li><a href="#xplr_pipe_logs_out">XPLR_PIPE_LOGS_OUT</a></li>
<li><a href="#xplr_pipe_result_out">XPLR_PIPE_RESULT_OUT</a></li>
<li><a href="#xplr_pipe_history_out">XPLR_PIPE_HISTORY_OUT</a></li>
<li><a href="#xplr_pipe_directory_nodes_out">XPLR_PIPE_DIRECTORY_NODES_OUT</a></li>
</ul>
<h4 id="xplr_pipe_msg_in"><a class="header" href="#xplr_pipe_msg_in">XPLR_PIPE_MSG_IN</a></h4>
<p>Append new-line delimited messages to this pipe in <a href="https://www.yaml.org">YAML</a>
(or <a href="https://www.json.org">JSON</a>) syntax. These messages will be read and
handled by xplr after the command execution.</p>
<h4 id="xplr_pipe_selection_out"><a class="header" href="#xplr_pipe_selection_out">XPLR_PIPE_SELECTION_OUT</a></h4>
<p>New-line delimited list of selected paths.</p>
<h4 id="xplr_pipe_global_help_menu_out"><a class="header" href="#xplr_pipe_global_help_menu_out">XPLR_PIPE_GLOBAL_HELP_MENU_OUT</a></h4>
<p>The full help menu.</p>
<h4 id="xplr_pipe_logs_out"><a class="header" href="#xplr_pipe_logs_out">XPLR_PIPE_LOGS_OUT</a></h4>
<p>New-line delimited list of logs.</p>
<h4 id="xplr_pipe_result_out"><a class="header" href="#xplr_pipe_result_out">XPLR_PIPE_RESULT_OUT</a></h4>
<p>New-line delimited result (selected paths if any, else the focused path)</p>
<h4 id="xplr_pipe_history_out"><a class="header" href="#xplr_pipe_history_out">XPLR_PIPE_HISTORY_OUT</a></h4>
<p>New-line delimited list of last visited paths (similar to jump list in vim).</p>
<h4 id="xplr_pipe_directory_nodes_out"><a class="header" href="#xplr_pipe_directory_nodes_out">XPLR_PIPE_DIRECTORY_NODES_OUT</a></h4>
<p>New-line delimited list of paths, filtered and sorted as displayed in the
<a href="layouts.html#table">files table</a>.</p>
<h3 id="example-1"><a class="header" href="#example-1">Example:</a></h3>
<pre><code class="language-lua">xplr.config.modes.builtin.default.key_bindings.on_key.space = {
help = &quot;ask name and greet&quot;,
messages = {
{
BashExec = [===[
echo &quot;What's your name?&quot;
read name
greeting=&quot;Hello $name!&quot;
message=&quot;$greeting You are inside $PWD&quot;
echo LogSuccess: '&quot;'$message'&quot;' &gt;&gt; &quot;${XPLR_PIPE_MSG_IN:?}&quot;
]===]
}
}
}
-- Now, when you press &quot;space&quot; in default mode, you will be prompted for your
-- name. Enter your name to receive a nice greeting and to know your location.
</code></pre>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="modes.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="layouts.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="modes.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="layouts.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playground_copyable = true;
</script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>