<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>panda_noir</author_name>
  <author_url>https://blog.hatena.ne.jp/panda_noir/</author_url>
  <blog_title>Panda Noir</blog_title>
  <blog_url>https://www.pandanoir.info/</blog_url>
  <categories>
    <anon>zsh</anon>
  </categories>
  <description>zshのprompt内で%?を指定すると直前の終了ステータスを表示させることができます。 PROMPT='[%n@%m]%?# ' ↑これで[user@host][last_status]#というプロンプトが表示されます。 ただ、これだと正常終了のときにも表示されて煩わしいので、正常終了のときには表示させないようにします。その結果がこちらです。 local user_host='%F{074}[%n@%m]' local last_status='%F{red}$([[ $? -ne 0 &amp;&amp; $? -ne 130 ]] &amp;&amp; echo &quot;[%?]&quot;)' # 異常終了のとき(Ctrl-cを除く…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fwww.pandanoir.info%2Fentry%2F2024%2F06%2F11%2F012941&quot; title=&quot;zshのプロンプトに直前のコマンドの終了ステータスを表示する - Panda Noir&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>https://cdn-ak.f.st-hatena.com/images/fotolife/p/panda_noir/20240611/20240611013055.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2024-06-11 01:29:41</published>
  <title>zshのプロンプトに直前のコマンドの終了ステータスを表示する</title>
  <type>rich</type>
  <url>https://www.pandanoir.info/entry/2024/06/11/012941</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
