<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>@sikac.hu</title>
 <link href="/atom.xml" rel="self"/>
 <link href="https://sikac.hu/"/>
 <updated>2026-06-11T18:39:55+00:00</updated>
 <id>https://sikac.hu</id>
 <author>
   <name>Prem Sichanugrist</name>
 </author>

 
 <entry>
   <title>How to keep sensitive commands out of .zsh_history</title>
   <link href="https://sikac.hu/how-to-keep-sensitive-commands-out-of-zsh-history"/>
   <updated>2015-11-09T01:49:01+00:00</updated>
   <id>https://sikac.hu/how-to-keep-sensitive-commands-out-of-zsh-history</id>
   <content type="html">&lt;p&gt;By default,
if you enable command history in Zsh,
all commands including those that contain sensitive informations
such as access token or password
will be saved into your command history file after you run them.&lt;/p&gt;

&lt;p&gt;It’s definitely a bad idea to have those information
winded up in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zsh_history&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;However,
there is a way you can tell Zsh to not putting a command in your history file
by setting this option in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zshrc&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-zsh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;setopt HIST_IGNORE_SPACE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After that,
Zsh will not store any command that starts with a space in a history file.&lt;/p&gt;

&lt;p&gt;So, instead of running this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ curl -u &quot;LOLNOPE:x-oauth-basic&quot; -i https://api.github.com/...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;add an empty space before your command like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$  curl -u &quot;LOLNOPE:x-oauth-basic&quot; -i https://api.github.com/...
  ^--------- notice an empty space here
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that this most recent command &lt;em&gt;will&lt;/em&gt; temporary stay in the command history
in your current session
so you can go back to reuse or edit it by using the UP arrow,
and it will automatically disappear
after you run another command in the same session.&lt;/p&gt;

&lt;p&gt;You can read more about this in &lt;a href=&quot;https://zsh.sourceforge.io/Doc/Release/Options.html&quot;&gt;Zsh documentation&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 

</feed>
