<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>docs/shell-integration.md - fork/wezterm @ termwiz-0.23.1</title>
<meta name="description" content="docs/shell-integration.md in fork/wezterm at termwiz-0.23.1.">
<meta property="og:title" content="docs/shell-integration.md - fork/wezterm @ termwiz-0.23.1">
<meta property="og:description" content="docs/shell-integration.md in fork/wezterm at termwiz-0.23.1.">
<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.1" data-tip="7053748e4d899e7fc5e202d6f903b052fc78e759">
<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="11c4b11669d9ce23d51afaf286b5383fbdc9794f">s,wez/wezterm,wezterm/wezterm,</span><span class="snapshot-sha sha" data-commit="11c4b11669d9ce23d51afaf286b5383fbdc9794f">11c4b1166</span><time datetime="2025-02-07T13:08:01-07:00" title="2025-02-07 13:08:01 -0700">2025-02-07</time></p>
<header class="topbar"><details class="switcher"><summary>termwiz-0.23.1</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 href="/fork/wezterm/ref/termwiz-0.23.0/">termwiz-0.23.0</a><a class="current" 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.1/tree/docs/">docs</a> / <span class="cur">shell-integration.md</span></nav>
<span class="view-stats"><span>7.5 KiB</span><span>182 lines</span></span><span class="actions"><a class="raw" href="/fork/wezterm/raw/3b61fb49f7369f4f79311df18b2db2c03884e1b6/docs/shell-integration.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"><p>wezterm supports integrating with the shell through the following means:</p>
<ul>
<li><code>OSC 7</code> Escape sequences to advise the terminal of the working directory</li>
<li><code>OSC 133</code> Escape sequence to define Input, Output and Prompt zones</li>
<li><code>OSC 1337</code> Escape sequences to set user vars for tracking additional shell state</li>
</ul>
<p><code>OSC</code> is escape sequence jargon for <em>Operating System Command</em>.</p>
<p>These sequences enable some improved user experiences, such as being able
to spawn new panes, tabs and windows with the same current working directory
as the current pane, <a href="/fork/wezterm/ref/termwiz-0.23.1/blob/docs/config/lua/keyassignment/ScrollToPrompt.md">jumping through the scrollback to the start of an earlier command</a>,
or <a href="/fork/wezterm/ref/termwiz-0.23.1/blob/docs/config/lua/keyassignment/SelectTextAtMouseCursor.md">conveniently selecting the complete output from a command</a>.</p>
<p>In order for these features to be enabled, you will need to configure your
shell program to emit the escape sequences at the appropriate place.</p>
<p>You can find some <a href="https://github.com/wezterm/wezterm/tree/main/assets/shell-integration">examples for various shells in the wezterm
repo</a>.</p>
<p>To use this file to setup shell integration in wezterm with Bash or Zsh, you can
copy the file to your computer and source it via <code>. /path/to/file.sh</code> in your <code>.bashrc</code>
or <code>.zshrc</code>, or you can install it at <code>/etc/profile.d</code> on most unix systems.</p>
<p>Xonsh is supported via a <a href="https://github.com/jnoortheen/xontrib-term-integrations">term-integrations</a> plugin.</p>
<p>Starting with version 20210314-114017-04b7cedd, the Fedora and Debian packages
automatically activate shell integration for Bash and Zsh.
Starting with version 20230320.124340.559cb7b0, the Arch Linux package
also automatically activate it.</p>
<p>If you're on another system, more information on how these escapes work
can be found below.</p>
<p><a href="https://gitlab.freedesktop.org/Per_Bothner/specifications/blob/master/proposals/semantic-prompts.md">Learn more about OSC 133 Semantic Prompt Escapes</a>.</p>
<h2>User Vars</h2>
<p><code>OSC 1337</code> provides a means for setting <em>user vars</em>, which are somewhat similar
to environment variables, except that they are variables associated with a
given pane rather than a process.</p>
<p>Installing the wezterm shell integration will define the following user vars
by default:</p>
<ul>
<li><code>WEZTERM_PROG</code> - the command line being executed by the shell</li>
<li><code>WEZTERM_USER</code> - holds the output from <code>id -un</code>; the current user name</li>
<li><code>WEZTERM_HOST</code> - holds the output from <code>hostname</code>; the hostname that the shell is running on</li>
<li><code>WEZTERM_IN_TMUX</code> - holds <code>1</code> if the shell is running inside tmux, <code>0</code> otherwise</li>
</ul>
<p>If you are a tmux user, you must ensure that you have <code>set -g allow-passthrough on</code> set
in your tmux.conf for user vars to work.</p>
<p>Those vars will be updated each time the prompt is shown and just prior to executing a command.</p>
<p>The shell integration provides a shell function named <code>__wezterm_set_user_var</code> which can be
used to set your own user vars.</p>
<p>Setting a user var will generate events in the window that contains
the corresponding pane:</p>
<ul>
<li><a href="/fork/wezterm/ref/termwiz-0.23.1/blob/docs/config/lua/window-events/user-var-changed.md">user-var-changed</a>, which
allows you to directly take action when a var is set/changed.</li>
<li><a href="/fork/wezterm/ref/termwiz-0.23.1/blob/docs/config/lua/window-events/update-status.md">update-status</a> which allows you to update left/right status items</li>
<li>the title and tab bar area will then update and trigger any associated events as part of that update</li>
</ul>
<p>You can access the complete set of user vars in a given pane by calling
<a href="/fork/wezterm/ref/termwiz-0.23.1/blob/docs/config/lua/pane/get_user_vars.md">pane:get_user_vars()</a>, or by accessing
the <code>user_vars</code> field in a <a href="/fork/wezterm/ref/termwiz-0.23.1/blob/docs/config/lua/PaneInformation.md">PaneInformation</a>
struct.</p>
<p>You may wish to use this information to adjust what is shown in your tab titles
or in the status area.</p>
<h2>OSC 7 Escape sequence to set the working directory</h2>
<p><code>OSC 7</code> means Operating System Command number 7.  This is an escape sequence
that originated in the macOS Terminal application that is used to advise the
terminal of the current working directory.</p>
<p>An application (usually your shell) can be configured to emit this escape
sequence when the current directory changes, or just to emit it each time
it prints the prompt.</p>
<p>The current working directory can be specified as a URL like this:</p>
<pre class="language-bash"><a-f>printf</a-f> <a-s>&quot;\033]7;file://HOSTNAME/CURRENT/DIR\033\\&quot;</a-s></pre>
<p><strong>When the current working directory has been set via OSC 7, spawning
a new tab will use the current working directory of the current tab,
so that you don't have to manually change the directory</strong>.</p>
<p>If you are on a modern Fedora installation, the defaults for bash and
zsh source a <code>vte.sh</code> script that configures the shell to emit this
sequence.  On other systems you will likely need to configure this
for yourself.</p>
<h2>OSC 7 on Windows with cmd.exe</h2>
<p><code>cmd.exe</code> doesn't allow a lot of flexibility in configuring the prompt,
but fortunately it does allow for emitting escape sequences.  You
can use the <code>set_environment_variables</code> configuration to pre-configure
the prompt environment in your <code>.wezterm.lua</code>; this example configures
the use of OSC 7 as well as including the time and current directory in
the visible prompt with green and purple colors, and makes the prompt
span multiple lines:</p>
<pre class="language-lua"><a-v>config</a-v><a-p>.</a-p><a-v>set_environment_variables</a-v> = <a-cr>{</a-cr>
  <a-v>prompt</a-v> = <a-s>&#39;$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m &#39;</a-s><a-p>,</a-p>
<a-cr>}</a-cr></pre>
<h2>OSC 7 on Windows with powershell</h2>
<p>You can configure a custom prompt in powershell by creating/editing your
<a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.1">powershell profile</a>
and defining a function like this:</p>
<pre class="language-powershell"><a-k>function</a-k> <a-f>prompt</a-f> {
    <a-v>$p</a-v> = <a-v>$executionContext</a-v>.<a-pr>SessionState</a-pr>.<a-pr>Path</a-pr>.<a-pr>CurrentLocation</a-pr>
    <a-v>$osc7</a-v> = <a-s>&quot;&quot;</a-s>
    <a-k>if</a-k> (<a-v>$p</a-v>.<a-pr>Provider</a-pr>.<a-pr>Name</a-pr> <a-o>-eq</a-o> <a-s>&quot;FileSystem&quot;</a-s>) {
        <a-v>$ansi_escape</a-v> = [<a-t>char</a-t>]<a-n>27</a-n>
        <a-v>$provider_path</a-v> = <a-v>$p</a-v>.<a-pr>ProviderPath</a-pr> <a-o>-Replace</a-o> <a-s>&quot;\\&quot;</a-s>, <a-s>&quot;/&quot;</a-s>
        <a-v>$osc7</a-v> = <a-s>&quot;</a-s><a-v>$ansi_escape</a-v><a-s>]7;file://</a-s><a-v>${env:COMPUTERNAME}</a-v><a-s>/</a-s><a-v>${provider_path}${ansi_escape}</a-v><a-s>\&quot;</a-s>
    }
    <a-s>&quot;</a-s><a-v>${osc7}</a-v><a-s>PS </a-s><a-v>$p</a-v><a-s>$(</a-s><a-s>&#39;&gt;&#39;</a-s><a-s> </a-s><a-o>*</a-o><a-s> (</a-s><a-v>$nestedPromptLevel</a-v><a-s> </a-s><a-o>+</a-o><a-s> </a-s><a-n>1</a-n><a-s>)) &quot;</a-s>;
}</pre>
<h2>OSC 7 on Windows with powershell (with starship)</h2>
<p>When using <a href="https://starship.rs/">Starship</a>, since it has taken control of the prompt, hooking in to set
OSC 7 can be achieved this way instead:</p>
<pre class="language-powershell"><a-v>$prompt</a-v> = <a-s>&quot;&quot;</a-s>
<a-k>function</a-k> <a-f>Invoke-Starship-PreCommand</a-f> {
    <a-v>$current_location</a-v> = <a-v>$executionContext</a-v>.<a-pr>SessionState</a-pr>.<a-pr>Path</a-pr>.<a-pr>CurrentLocation</a-pr>
    <a-k>if</a-k> (<a-v>$current_location</a-v>.<a-pr>Provider</a-pr>.<a-pr>Name</a-pr> <a-o>-eq</a-o> <a-s>&quot;FileSystem&quot;</a-s>) {
        <a-v>$ansi_escape</a-v> = [<a-t>char</a-t>]<a-n>27</a-n>
        <a-v>$provider_path</a-v> = <a-v>$current_location</a-v>.<a-pr>ProviderPath</a-pr> <a-o>-replace</a-o> <a-s>&quot;\\&quot;</a-s>, <a-s>&quot;/&quot;</a-s>
        <a-v>$prompt</a-v> = <a-s>&quot;</a-s><a-v>$ansi_escape</a-v><a-s>]7;file://</a-s><a-v>${env:COMPUTERNAME}</a-v><a-s>/</a-s><a-v>${provider_path}$ansi_escape</a-v><a-s>\&quot;</a-s>
    }
    <a-v>$host</a-v>.<a-pr>ui</a-pr>.<a-f>Write</a-f>(<a-v>$prompt</a-v>)
}</pre>
<h2>Using Clink on Windows Systems</h2>
<p><a href="https://github.com/chrisant996/clink">Clink</a> brings bash style line editing,
completions and autosuggestions to your Windows cmd.exe experience. If you
haven't installed clink to be the global default on your system, you can
configure wezterm to launch clink by setting the <code>default_prog</code> configuration
in your <code>.wezterm.lua</code>; for example, if you have extracted clink to <code>c:\clink</code>
you might configure this:</p>
<pre class="language-lua"><a-k>local</a-k> <a-v>wezterm</a-v> = <a-f>require</a-f> <a-s>&#39;wezterm&#39;</a-s>
<a-k>local</a-k> <a-v>config</a-v> = <a-cr>{}</a-cr>

<a-v>config</a-v><a-p>.</a-p><a-v>set_environment_variables</a-v> = <a-cr>{}</a-cr>

<a-k>if</a-k> <a-v>wezterm</a-v><a-p>.</a-p><a-v>target_triple</a-v> <a-o>==</a-o> <a-s>&#39;x86_64-pc-windows-msvc&#39;</a-s> <a-k>then</a-k>
  <a-c>-- Use OSC 7 as per the above example</a-c>
  <a-v>config</a-v><a-p>.</a-p><a-v>set_environment_variables</a-v><a-p>[</a-p><a-s>&#39;prompt&#39;</a-s><a-p>]</a-p> =
    <a-s>&#39;$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m &#39;</a-s>
  <a-c>-- use a more ls-like output format for dir</a-c>
  <a-v>config</a-v><a-p>.</a-p><a-v>set_environment_variables</a-v><a-p>[</a-p><a-s>&#39;DIRCMD&#39;</a-s><a-p>]</a-p> = <a-s>&#39;/d&#39;</a-s>
  <a-c>-- And inject clink into the command prompt</a-c>
  <a-v>config</a-v><a-p>.</a-p><a-v>default_prog</a-v> =
    <a-cr>{</a-cr> <a-s>&#39;cmd.exe&#39;</a-s><a-p>,</a-p> <a-s>&#39;/s&#39;</a-s><a-p>,</a-p> <a-s>&#39;/k&#39;</a-s><a-p>,</a-p> <a-s>&#39;c:/clink/clink_x64.exe&#39;</a-s><a-p>,</a-p> <a-s>&#39;inject&#39;</a-s><a-p>,</a-p> <a-s>&#39;-q&#39;</a-s> <a-cr>}</a-cr>
<a-k>end</a-k>

<a-k>return</a-k> <a-v>config</a-v></pre>
<p>Now, rather than just running <code>cmd.exe</code> on its own, this will cause <code>cmd.exe</code>
to self-inject the clink line editor.</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">wezterm supports integrating with the shell through the following means:</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></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>`OSC 7` Escape sequences to advise the terminal of the working directory</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>`OSC 133` Escape sequence to define Input, Output and Prompt zones</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>`OSC 1337` Escape sequences to set user vars for tracking additional shell state</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"><a-p>`OSC` is escape sequence jargon for *Operating System Command*.</a-p></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"><a-p>These sequences enable some improved user experiences, such as being able</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"><a-p>to spawn new panes, tabs and windows with the same current working directory</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text"><a-p>as the current pane, [jumping through the scrollback to the start of an earlier command](config/lua/keyassignment/ScrollToPrompt.md),</a-p></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>or [conveniently selecting the complete output from a command](config/lua/keyassignment/SelectTextAtMouseCursor.md).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"></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>In order for these features to be enabled, you will need to configure your</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"><a-p>shell program to emit the escape sequences at the appropriate place.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"></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>You can find some [examples for various shells in the wezterm</a-p></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>repo](https://github.com/wezterm/wezterm/tree/main/assets/shell-integration).</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>To use this file to setup shell integration in wezterm with Bash or Zsh, you can</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>copy the file to your computer and source it via `. /path/to/file.sh` in your `.bashrc`</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"><a-p>or `.zshrc`, or you can install it at `/etc/profile.d` on most unix systems.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"></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>Xonsh is supported via a [term-integrations](https://github.com/jnoortheen/xontrib-term-integrations) plugin.</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"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text"><a-p>Starting with version 20210314-114017-04b7cedd, the Fedora and Debian packages</a-p></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>automatically activate shell integration for Bash and Zsh.</a-p></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>Starting with version 20230320.124340.559cb7b0, the Arch Linux package</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>also automatically activate it.</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"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text"><a-p>If you&#39;re on another system, more information on how these escapes work</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text"><a-p>can be found below.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L33" href="#L33">33</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L34" href="#L34">34</a><span class="code-text"><a-p>[Learn more about OSC 133 Semantic Prompt Escapes](https://gitlab.freedesktop.org/Per_Bothner/specifications/blob/master/proposals/semantic-prompts.md).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L35" href="#L35">35</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L36" href="#L36">36</a><span class="code-text"><a-p>## </a-p><a-tt>User Vars</a-tt></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"><a-p>`OSC 1337` provides a means for setting *user vars*, which are somewhat similar</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L39" href="#L39">39</a><span class="code-text"><a-p>to environment variables, except that they are variables associated with a</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L40" href="#L40">40</a><span class="code-text"><a-p>given pane rather than a process.</a-p></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 class="code-break">
</span></span><span class="code-line"><a class="ln" id="L42" href="#L42">42</a><span class="code-text"><a-p>Installing the wezterm shell integration will define the following user vars</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L43" href="#L43">43</a><span class="code-text"><a-p>by default:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L44" href="#L44">44</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L45" href="#L45">45</a><span class="code-text"><a-p>* `WEZTERM_PROG` - the command line being executed by the shell</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L46" href="#L46">46</a><span class="code-text"><a-p>* `WEZTERM_USER` - holds the output from `id -un`; the current user name</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L47" href="#L47">47</a><span class="code-text"><a-p>* `WEZTERM_HOST` - holds the output from `hostname`; the hostname that the shell is running on</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L48" href="#L48">48</a><span class="code-text"><a-p>* `WEZTERM_IN_TMUX` - holds `1` if the shell is running inside tmux, `0` otherwise</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L49" href="#L49">49</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L50" href="#L50">50</a><span class="code-text"><a-p>If you are a tmux user, you must ensure that you have `set -g allow-passthrough on` set</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L51" href="#L51">51</a><span class="code-text"><a-p>in your tmux.conf for user vars to work.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L52" href="#L52">52</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L53" href="#L53">53</a><span class="code-text"><a-p>Those vars will be updated each time the prompt is shown and just prior to executing a command.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L54" href="#L54">54</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L55" href="#L55">55</a><span class="code-text"><a-p>The shell integration provides a shell function named `__wezterm_set_user_var` which can be</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L56" href="#L56">56</a><span class="code-text"><a-p>used to set your own user vars.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L57" href="#L57">57</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L58" href="#L58">58</a><span class="code-text"><a-p>Setting a user var will generate events in the window that contains</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L59" href="#L59">59</a><span class="code-text"><a-p>the corresponding pane:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L60" href="#L60">60</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L61" href="#L61">61</a><span class="code-text"><a-p>* [user-var-changed](config/lua/window-events/user-var-changed.md), which</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L62" href="#L62">62</a><span class="code-text"><a-p>  allows you to directly take action when a var is set/changed.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L63" href="#L63">63</a><span class="code-text"><a-p>* [update-status](config/lua/window-events/update-status.md) which allows you to update left/right status items</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L64" href="#L64">64</a><span class="code-text"><a-p>* the title and tab bar area will then update and trigger any associated events as part of that update</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L65" href="#L65">65</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L66" href="#L66">66</a><span class="code-text"><a-p>You can access the complete set of user vars in a given pane by calling</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L67" href="#L67">67</a><span class="code-text"><a-p>[pane:get_user_vars()](config/lua/pane/get_user_vars.md), or by accessing</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L68" href="#L68">68</a><span class="code-text"><a-p>the `user_vars` field in a [PaneInformation](config/lua/PaneInformation.md)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L69" href="#L69">69</a><span class="code-text"><a-p>struct.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L70" href="#L70">70</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L71" href="#L71">71</a><span class="code-text"><a-p>You may wish to use this information to adjust what is shown in your tab titles</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L72" href="#L72">72</a><span class="code-text"><a-p>or in the status area.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L73" href="#L73">73</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L74" href="#L74">74</a><span class="code-text"><a-p>## </a-p><a-tt>OSC 7 Escape sequence to set the working directory</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L75" href="#L75">75</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L76" href="#L76">76</a><span class="code-text"><a-p>`OSC 7` means Operating System Command number 7.  This is an escape sequence</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L77" href="#L77">77</a><span class="code-text"><a-p>that originated in the macOS Terminal application that is used to advise the</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L78" href="#L78">78</a><span class="code-text"><a-p>terminal of the current working directory.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L79" href="#L79">79</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L80" href="#L80">80</a><span class="code-text"><a-p>An application (usually your shell) can be configured to emit this escape</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L81" href="#L81">81</a><span class="code-text"><a-p>sequence when the current directory changes, or just to emit it each time</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L82" href="#L82">82</a><span class="code-text"><a-p>it prints the prompt.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L83" href="#L83">83</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L84" href="#L84">84</a><span class="code-text"><a-p>The current working directory can be specified as a URL like this:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L85" href="#L85">85</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L86" href="#L86">86</a><span class="code-text"><a-p>```</a-p><a-tl>bash</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L87" href="#L87">87</a><span class="code-text"><a-p>printf </a-p><a-s>&quot;\033]7;file://HOSTNAME/CURRENT/DIR\033\\&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L88" href="#L88">88</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L89" href="#L89">89</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L90" href="#L90">90</a><span class="code-text"><a-p>**When the current working directory has been set via OSC 7, spawning</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L91" href="#L91">91</a><span class="code-text"><a-p>a new tab will use the current working directory of the current tab,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L92" href="#L92">92</a><span class="code-text"><a-p>so that you don&#39;t have to manually change the directory**.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L93" href="#L93">93</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L94" href="#L94">94</a><span class="code-text"><a-p>If you are on a modern Fedora installation, the defaults for bash and</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L95" href="#L95">95</a><span class="code-text"><a-p>zsh source a `vte.sh` script that configures the shell to emit this</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L96" href="#L96">96</a><span class="code-text"><a-p>sequence.  On other systems you will likely need to configure this</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L97" href="#L97">97</a><span class="code-text"><a-p>for yourself.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L98" href="#L98">98</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L99" href="#L99">99</a><span class="code-text"><a-p>## </a-p><a-tt>OSC 7 on Windows with cmd.exe</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L100" href="#L100">100</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L101" href="#L101">101</a><span class="code-text"><a-p>`cmd.exe` doesn&#39;t allow a lot of flexibility in configuring the prompt,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L102" href="#L102">102</a><span class="code-text"><a-p>but fortunately it does allow for emitting escape sequences.  You</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L103" href="#L103">103</a><span class="code-text"><a-p>can use the `set_environment_variables` configuration to pre-configure</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L104" href="#L104">104</a><span class="code-text"><a-p>the prompt environment in your `.wezterm.lua`; this example configures</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L105" href="#L105">105</a><span class="code-text"><a-p>the use of OSC 7 as well as including the time and current directory in</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L106" href="#L106">106</a><span class="code-text"><a-p>the visible prompt with green and purple colors, and makes the prompt</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L107" href="#L107">107</a><span class="code-text"><a-p>span multiple lines:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L108" href="#L108">108</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L109" href="#L109">109</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="L110" href="#L110">110</a><span class="code-text"><a-p>config.</a-p><a-v>set_environment_variables</a-v><a-p> = </a-p><a-cr>{</a-cr></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L111" href="#L111">111</a><span class="code-text"><a-p>  </a-p><a-v>prompt</a-v><a-p> = </a-p><a-s>&#39;$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m &#39;</a-s><a-p>,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L112" href="#L112">112</a><span class="code-text"><a-p>}</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L113" href="#L113">113</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L114" href="#L114">114</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L115" href="#L115">115</a><span class="code-text"><a-p>## </a-p><a-tt>OSC 7 on Windows with powershell</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L116" href="#L116">116</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L117" href="#L117">117</a><span class="code-text"><a-p>You can configure a custom prompt in powershell by creating/editing your</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L118" href="#L118">118</a><span class="code-text"><a-p>[powershell profile](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.1)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L119" href="#L119">119</a><span class="code-text"><a-p>and defining a function like this:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L120" href="#L120">120</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L121" href="#L121">121</a><span class="code-text"><a-p>```</a-p><a-tl>powershell</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L122" href="#L122">122</a><span class="code-text"><a-p>function </a-p><a-f>prompt</a-f><a-p> {</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L123" href="#L123">123</a><span class="code-text"><a-p>    </a-p><a-v>$p</a-v><a-p> = </a-p><a-v>$executionContext</a-v><a-p>.</a-p><a-pr>SessionState</a-pr><a-p>.</a-p><a-pr>Path</a-pr><a-p>.</a-p><a-pr>CurrentLocation</a-pr></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L124" href="#L124">124</a><span class="code-text"><a-p>    </a-p><a-v>$osc7</a-v><a-p> = </a-p><a-s>&quot;&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L125" href="#L125">125</a><span class="code-text"><a-p>    </a-p><a-k>if</a-k><a-p> (</a-p><a-v>$p</a-v><a-p>.</a-p><a-pr>Provider</a-pr><a-p>.</a-p><a-pr>Name</a-pr><a-p> </a-p><a-o>-eq</a-o><a-p> </a-p><a-s>&quot;FileSystem&quot;</a-s><a-p>) {</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L126" href="#L126">126</a><span class="code-text"><a-p>        </a-p><a-v>$ansi_escape</a-v><a-p> = [</a-p><a-t>char</a-t><a-p>]</a-p><a-n>27</a-n></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L127" href="#L127">127</a><span class="code-text"><a-p>        </a-p><a-v>$provider_path</a-v><a-p> = </a-p><a-v>$p</a-v><a-p>.</a-p><a-pr>ProviderPath</a-pr><a-p> </a-p><a-o>-Replace</a-o><a-p> </a-p><a-s>&quot;\\&quot;</a-s><a-p>, </a-p><a-s>&quot;/&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L128" href="#L128">128</a><span class="code-text"><a-p>        </a-p><a-v>$osc7</a-v><a-p> = </a-p><a-s>&quot;</a-s><a-v>$ansi_escape</a-v><a-s>]7;file://</a-s><a-v>${env:COMPUTERNAME}</a-v><a-s>/</a-s><a-v>${provider_path}${ansi_escape}</a-v><a-s>\&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L129" href="#L129">129</a><span class="code-text"><a-p>    }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L130" href="#L130">130</a><span class="code-text"><a-p>    </a-p><a-s>&quot;</a-s><a-v>${osc7}</a-v><a-s>PS </a-s><a-v>$p</a-v><a-s>$(&#39;&gt;&#39; </a-s><a-o>*</a-o><a-s> (</a-s><a-v>$nestedPromptLevel</a-v><a-s> </a-s><a-o>+</a-o><a-s> </a-s><a-n>1</a-n><a-s>)) &quot;</a-s><a-p>;</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L131" href="#L131">131</a><span class="code-text"><a-p>}</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L132" href="#L132">132</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L133" href="#L133">133</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L134" href="#L134">134</a><span class="code-text"><a-p>## </a-p><a-tt>OSC 7 on Windows with powershell (with starship)</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L135" href="#L135">135</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L136" href="#L136">136</a><span class="code-text"><a-p>When using [Starship](https://starship.rs/), since it has taken control of the prompt, hooking in to set</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L137" href="#L137">137</a><span class="code-text"><a-p>OSC 7 can be achieved this way instead:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L138" href="#L138">138</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L139" href="#L139">139</a><span class="code-text"><a-p>```</a-p><a-tl>powershell</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L140" href="#L140">140</a><span class="code-text"><a-p>$prompt = </a-p><a-s>&quot;&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L141" href="#L141">141</a><span class="code-text"><a-p>function </a-p><a-f>Invoke-Starship-PreCommand</a-f><a-p> {</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L142" href="#L142">142</a><span class="code-text"><a-p>    </a-p><a-v>$current_location</a-v><a-p> = </a-p><a-v>$executionContext</a-v><a-p>.</a-p><a-pr>SessionState</a-pr><a-p>.</a-p><a-pr>Path</a-pr><a-p>.</a-p><a-pr>CurrentLocation</a-pr></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L143" href="#L143">143</a><span class="code-text"><a-p>    </a-p><a-k>if</a-k><a-p> (</a-p><a-v>$current_location</a-v><a-p>.</a-p><a-pr>Provider</a-pr><a-p>.</a-p><a-pr>Name</a-pr><a-p> </a-p><a-o>-eq</a-o><a-p> </a-p><a-s>&quot;FileSystem&quot;</a-s><a-p>) {</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L144" href="#L144">144</a><span class="code-text"><a-p>        </a-p><a-v>$ansi_escape</a-v><a-p> = [</a-p><a-t>char</a-t><a-p>]</a-p><a-n>27</a-n></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L145" href="#L145">145</a><span class="code-text"><a-p>        </a-p><a-v>$provider_path</a-v><a-p> = </a-p><a-v>$current_location</a-v><a-p>.</a-p><a-pr>ProviderPath</a-pr><a-p> </a-p><a-o>-replace</a-o><a-p> </a-p><a-s>&quot;\\&quot;</a-s><a-p>, </a-p><a-s>&quot;/&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L146" href="#L146">146</a><span class="code-text"><a-p>        </a-p><a-v>$prompt</a-v><a-p> = </a-p><a-s>&quot;</a-s><a-v>$ansi_escape</a-v><a-s>]7;file://</a-s><a-v>${env:COMPUTERNAME}</a-v><a-s>/</a-s><a-v>${provider_path}$ansi_escape</a-v><a-s>\&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L147" href="#L147">147</a><span class="code-text"><a-p>    }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L148" href="#L148">148</a><span class="code-text"><a-p>    </a-p><a-v>$host</a-v><a-p>.</a-p><a-pr>ui</a-pr><a-p>.</a-p><a-f>Write</a-f><a-p>(</a-p><a-v>$prompt</a-v><a-p>)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L149" href="#L149">149</a><span class="code-text"><a-p>}</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L150" href="#L150">150</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L151" href="#L151">151</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L152" href="#L152">152</a><span class="code-text"><a-p>## </a-p><a-tt>Using Clink on Windows Systems</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L153" href="#L153">153</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L154" href="#L154">154</a><span class="code-text"><a-p>[Clink](https://github.com/chrisant996/clink) brings bash style line editing,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L155" href="#L155">155</a><span class="code-text"><a-p>completions and autosuggestions to your Windows cmd.exe experience. If you</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L156" href="#L156">156</a><span class="code-text"><a-p>haven&#39;t installed clink to be the global default on your system, you can</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L157" href="#L157">157</a><span class="code-text"><a-p>configure wezterm to launch clink by setting the `default_prog` configuration</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L158" href="#L158">158</a><span class="code-text"><a-p>in your `.wezterm.lua`; for example, if you have extracted clink to `c:\clink`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L159" href="#L159">159</a><span class="code-text"><a-p>you might configure this:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L160" href="#L160">160</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L161" href="#L161">161</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="L162" href="#L162">162</a><span class="code-text"><a-p>local </a-p><a-v>wezterm</a-v><a-p> = </a-p><a-f>require</a-f><a-p> </a-p><a-s>&#39;wezterm&#39;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L163" href="#L163">163</a><span class="code-text"><a-p>local </a-p><a-v>config</a-v><a-p> = </a-p><a-cr>{}</a-cr></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L164" href="#L164">164</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L165" href="#L165">165</a><span class="code-text"><a-p>config.</a-p><a-v>set_environment_variables</a-v><a-p> = </a-p><a-cr>{}</a-cr></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L166" href="#L166">166</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L167" href="#L167">167</a><span class="code-text"><a-p>if </a-p><a-v>wezterm</a-v><a-p>.</a-p><a-v>target_triple</a-v><a-p> </a-p><a-o>==</a-o><a-p> </a-p><a-s>&#39;x86_64-pc-windows-msvc&#39;</a-s><a-p> </a-p><a-k>then</a-k></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L168" href="#L168">168</a><span class="code-text"><a-p>  </a-p><a-c>-- Use OSC 7 as per the above example</a-c></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L169" href="#L169">169</a><span class="code-text"><a-p>  </a-p><a-v>config</a-v><a-p>.</a-p><a-v>set_environment_variables</a-v><a-p>[</a-p><a-s>&#39;prompt&#39;</a-s><a-p>] =</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L170" href="#L170">170</a><span class="code-text"><a-p>    </a-p><a-s>&#39;$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m &#39;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L171" href="#L171">171</a><span class="code-text"><a-p>  </a-p><a-c>-- use a more ls-like output format for dir</a-c></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L172" href="#L172">172</a><span class="code-text"><a-p>  </a-p><a-v>config</a-v><a-p>.</a-p><a-v>set_environment_variables</a-v><a-p>[</a-p><a-s>&#39;DIRCMD&#39;</a-s><a-p>] = </a-p><a-s>&#39;/d&#39;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L173" href="#L173">173</a><span class="code-text"><a-p>  </a-p><a-c>-- And inject clink into the command prompt</a-c></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L174" href="#L174">174</a><span class="code-text"><a-p>  </a-p><a-v>config</a-v><a-p>.</a-p><a-v>default_prog</a-v><a-p> =</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L175" href="#L175">175</a><span class="code-text"><a-p>    </a-p><a-cr>{</a-cr><a-p> </a-p><a-s>&#39;cmd.exe&#39;</a-s><a-p>, </a-p><a-s>&#39;/s&#39;</a-s><a-p>, </a-p><a-s>&#39;/k&#39;</a-s><a-p>, </a-p><a-s>&#39;c:/clink/clink_x64.exe&#39;</a-s><a-p>, </a-p><a-s>&#39;inject&#39;</a-s><a-p>, </a-p><a-s>&#39;-q&#39;</a-s><a-p> </a-p><a-cr>}</a-cr></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L176" href="#L176">176</a><span class="code-text"><a-p>end</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L177" href="#L177">177</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L178" href="#L178">178</a><span class="code-text"><a-p>return </a-p><a-v>config</a-v></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L179" href="#L179">179</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L180" href="#L180">180</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L181" href="#L181">181</a><span class="code-text">Now, rather than just running `cmd.exe` on its own, this will cause `cmd.exe`</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L182" href="#L182">182</a><span class="code-text">to self-inject the clink line editor.</span></span></pre></div></div>
</main>
</body>
</html>
