<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>docs/config/lua/config/exit_behavior.md - fork/wezterm @ termwiz-0.23.0</title>
<meta name="description" content="docs/config/lua/config/exit_behavior.md in fork/wezterm at termwiz-0.23.0.">
<meta property="og:title" content="docs/config/lua/config/exit_behavior.md - fork/wezterm @ termwiz-0.23.0">
<meta property="og:description" content="docs/config/lua/config/exit_behavior.md in fork/wezterm at termwiz-0.23.0.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="termwiz-0.23.0" data-tip="958804c8ac16b750954b3bcaaf847e7498cd2205">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/wezterm</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/wezterm</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">Wez Furlong</span><span class="commit-message" data-commit="84f7fb9f3b0deb192d45ee36257e5f329584b1fc">docs: add tags to a number of pages</span><span class="snapshot-sha sha" data-commit="84f7fb9f3b0deb192d45ee36257e5f329584b1fc">84f7fb9f3</span><time datetime="2023-04-08T07:48:40-07:00" title="2023-04-08 07:48:40 -0700">2023-04-08</time></p>
<header class="topbar"><details class="switcher"><summary>termwiz-0.23.0</summary><div class="menu"><strong>branches</strong><a href="/fork/wezterm/ref/main/">main</a><strong>tags</strong><a href="/fork/wezterm/ref/termiz-0.23.1/">termiz-0.23.1</a><a href="/fork/wezterm/ref/termiz-0.23.2/">termiz-0.23.2</a><a href="/fork/wezterm/ref/termiz-0.23.3/">termiz-0.23.3</a><a class="current" href="/fork/wezterm/ref/termwiz-0.23.0/">termwiz-0.23.0</a><a href="/fork/wezterm/ref/termwiz-0.23.1/">termwiz-0.23.1</a><a href="/fork/wezterm/ref/termwiz-0.23.2/">termwiz-0.23.2</a><a href="/fork/wezterm/ref/termwiz-0.23.3/">termwiz-0.23.3</a><a href="/fork/wezterm/ref/vtparse-0.7.0/">vtparse-0.7.0</a><a class="all" href="/fork/wezterm/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/wezterm/">wezterm</a> / <a href="/fork/wezterm/ref/termwiz-0.23.0/tree/docs/">docs</a> / <a href="/fork/wezterm/ref/termwiz-0.23.0/tree/docs/config/">config</a> / <a href="/fork/wezterm/ref/termwiz-0.23.0/tree/docs/config/lua/">lua</a> / <a href="/fork/wezterm/ref/termwiz-0.23.0/tree/docs/config/lua/config/">config</a> / <span class="cur">exit_behavior.md</span></nav>
<span class="view-stats"><span>1.4 KiB</span><span>41 lines</span></span><span class="actions"><a class="raw" href="/fork/wezterm/raw/49126b7140fe83ab6919439501297e245e220501/docs/config/lua/config/exit_behavior.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><hr />
<p>tags:</p>
<ul>
<li>exit_behavior</li>
</ul>
<hr />
<h2><code>exit_behavior = "CloseOnCleanExit"</code></h2>
<p>{{since('20210314-114017-04b7cedd')}}</p>
<p>Controls the behavior when the shell program spawned by the terminal exits.
There are three possible values:</p>
<ul>
<li><code>"Close"</code> - close the corresponding pane as soon as the program exits.</li>
<li><code>"Hold"</code> - keep the pane open after the program exits. The pane must be manually closed via <a href="/fork/wezterm/ref/termwiz-0.23.0/blob/docs/config/lua/keyassignment/CloseCurrentPane.md">CloseCurrentPane</a>, <a href="/fork/wezterm/ref/termwiz-0.23.0/blob/docs/config/lua/keyassignment/CloseCurrentTab.md">CloseCurrentTab</a> or closing the window.</li>
<li><code>"CloseOnCleanExit"</code> - if the shell program exited with a successful status, behave like <code>"Close"</code>, otherwise, behave like <code>"Hold"</code>.  This is the default setting.</li>
</ul>
<pre class="language-lua"><a-v>console</a-v><a-p>.</a-p><a-v>exit_behavior</a-v> = <a-s>&#39;Hold&#39;</a-s></pre>
<p>Note that most unix shells will exit with the status of the last command that
it ran if you don't specify an exit status.</p>
<p>For example, if you interrupt a command and then use <code>exit</code> (with no arguments), or
CTRL-D to send EOF to the shell, the shell will return an unsuccessful exit
status.  The same thing holds if you were to run:</p>
<pre class="language-bash"><a-o>$</a-o><a-f> </a-f><a-pr>false</a-pr>
<a-o>$</a-o><a-f> </a-f><a-pr>exit</a-pr></pre>
<p>With the default <code>exit_behavior="CloseOnCleanExit"</code> setting, that will cause
the pane to remain open.</p>
<p>See also: <a href="/fork/wezterm/ref/termwiz-0.23.0/blob/docs/config/lua/config/clean_exit_codes.md">clean_exit_codes</a> for fine tuning what is
considered to be a clean exit status.</p>
<p>{{since('20220624-141144-bd1b7c5d')}}</p>
<p>The default is now <code>"Close"</code>.</p>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>---</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"><a-pr>tags</a-pr><a-p>:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">  <a-p>-</a-p> <a-s>exit_behavior</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"><a-p>---</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text"><a-p>##</a-p> <a-tt>`exit_behavior = &quot;CloseOnCleanExit&quot;`</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text">{{since(&#39;20210314-114017-04b7cedd&#39;)}}</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text">Controls the behavior when the shell program spawned by the terminal exits.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text">There are three possible values:</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text"><a-p>* </a-p>`&quot;Close&quot;` - close the corresponding pane as soon as the program exits.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"><a-p>* </a-p>`&quot;Hold&quot;` - keep the pane open after the program exits. The pane must be manually closed via [CloseCurrentPane](../keyassignment/CloseCurrentPane.md), [CloseCurrentTab](../keyassignment/CloseCurrentTab.md) or closing the window.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text"><a-p>* </a-p>`&quot;CloseOnCleanExit&quot;` - if the shell program exited with a successful status, behave like `&quot;Close&quot;`, otherwise, behave like `&quot;Hold&quot;`.  This is the default setting.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"><a-p>```</a-p><a-tl>lua</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"><a-p>console.</a-p><a-v>exit_behavior</a-v><a-p> = </a-p><a-s>&#39;Hold&#39;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text"><a-p>Note that most unix shells will exit with the status of the last command that</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"><a-p>it ran if you don&#39;t specify an exit status.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"><a-p>For example, if you interrupt a command and then use `exit` (with no arguments), or</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text"><a-p>CTRL-D to send EOF to the shell, the shell will return an unsuccessful exit</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text"><a-p>status.  The same thing holds if you were to run:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text"><a-p>```</a-p><a-tl>console</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text"><a-p>$ false</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text"><a-p>$ exit</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text">With the default `exit_behavior=&quot;CloseOnCleanExit&quot;` setting, that will cause</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L33" href="#L33">33</a><span class="code-text">the pane to remain open.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L34" href="#L34">34</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L35" href="#L35">35</a><span class="code-text">See also: [clean_exit_codes](clean_exit_codes.md) for fine tuning what is</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L36" href="#L36">36</a><span class="code-text">considered to be a clean exit status.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L37" href="#L37">37</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L38" href="#L38">38</a><span class="code-text">{{since(&#39;20220624-141144-bd1b7c5d&#39;)}}</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L39" href="#L39">39</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L40" href="#L40">40</a><span class="code-text">The default is now `&quot;Close&quot;`.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L41" href="#L41">41</a><span class="code-text"></span></span></pre></div></div>
</main>
</body>
</html>
