<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: NaN</title>
    <description>The latest articles on DEV Community by NaN (@nan72).</description>
    <link>https://dev.to/nan72</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1104772%2F5e154439-a646-46c6-8b63-5d12674b3391.jpeg</url>
      <title>DEV Community: NaN</title>
      <link>https://dev.to/nan72</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nan72"/>
    <language>en</language>
    <item>
      <title>The Curious Case of the Duplicating GPG_TTY and the Hidden .zprofile Culprit (and Why My Terminal Was So Slow!)</title>
      <dc:creator>NaN</dc:creator>
      <pubDate>Wed, 14 Jan 2026 15:07:38 +0000</pubDate>
      <link>https://dev.to/nan72/the-curious-case-of-the-duplicating-gpgtty-and-the-hidden-zprofile-culprit-and-why-my-terminal-2j0o</link>
      <guid>https://dev.to/nan72/the-curious-case-of-the-duplicating-gpgtty-and-the-hidden-zprofile-culprit-and-why-my-terminal-2j0o</guid>
      <description>&lt;p&gt;&lt;em&gt;Image by &lt;a href="https://pixabay.com/users/joffi-1229850/" rel="noopener noreferrer"&gt;joffi&lt;/a&gt; from &lt;a href="https://pixabay.com/" rel="noopener noreferrer"&gt;Pixabay&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every now and then, a seemingly small configuration quirk can turn into a head-scratching mystery, especially in the world of dotfiles. I recently found myself in such a predicament: the line &lt;code&gt;export GPG_TTY=$(tty)&lt;/code&gt; kept magically reappearing in my &lt;code&gt;.zshrc&lt;/code&gt; file every time I opened a new terminal. What started as a minor annoyance quickly became a fascinating dive into shell startup logic, Oh My Zsh plugins, and the often-overlooked nuances of dotfile management, culminating in a significant performance hit to my terminal's startup speed.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Problem: A Frustratingly Sluggish Start (and a Massive Secret in &lt;code&gt;.zshrc&lt;/code&gt;)
&lt;/h1&gt;

&lt;p&gt;It began with a subtle, then increasingly painful, realization: my terminal was taking forever to start. What used to be an instantaneous pop-up was now a sluggish crawl of several seconds. I'd open Cursor, or Terminal.app, or Tabby, and just... wait.&lt;/p&gt;

&lt;p&gt;After days of frustration, I decided to peek under the hood and opened my &lt;code&gt;.zshrc&lt;/code&gt;. To my absolute horror, I found that it had grown to include thousands of identical lines: &lt;code&gt;export GPG_TTY=$(tty)&lt;/code&gt;. Every single one of those redundant lines was being parsed and executed by Zsh every time I opened a new terminal session, turning my snappy startup into a frustrating wait.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;GPG_TTY&lt;/code&gt; environment variable is crucial for GnuPG (GPG) to know which terminal to use for passphrase prompts—essential for signing Git commits. So, while the line itself was important, its relentless duplication (at least 3,000 times!) was definitely not.&lt;/p&gt;

&lt;h1&gt;
  
  
  Initial Suspicions: Oh My Zsh Plugins
&lt;/h1&gt;

&lt;p&gt;My first thought, like many Zsh users, went straight to Oh My Zsh and its myriad of plugins. I knew there was a &lt;code&gt;gpg-agent&lt;/code&gt; plugin, and its &lt;code&gt;README.md&lt;/code&gt; explicitly stated: "Updates the &lt;code&gt;GPG_TTY&lt;/code&gt; environment variable before each shell execution."&lt;/p&gt;

&lt;p&gt;A quick grep confirmed the plugin contained the line export &lt;code&gt;GPG_TTY=$TTY&lt;/code&gt;. This told me the plugin was indeed managing the variable. My initial theory was that the plugin might be flawed, constantly writing to my &lt;code&gt;.zshrc&lt;/code&gt;. But plugins are usually sourced, not designed to write back to the user's main configuration file. This was a critical distinction.&lt;/p&gt;

&lt;p&gt;If the plugin was setting the variable, and I was also seeing it appended to &lt;code&gt;.zshrc&lt;/code&gt;, it suggested a conflict: the plugin was doing its job, but something else was writing the redundant line.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Hunt for the Writer
&lt;/h1&gt;

&lt;p&gt;Knowing that the line was being written (not just sourced) was key. I systematically tried:&lt;/p&gt;

&lt;p&gt;Removing the duplicate line from &lt;code&gt;.zshrc&lt;/code&gt;: It reappeared.&lt;br&gt;
Disabling the &lt;code&gt;gpg-agent&lt;/code&gt; plugin: The line still reappeared in &lt;code&gt;.zshrc&lt;/code&gt;. This was a major clue! If the plugin wasn't the writer, something else was.&lt;br&gt;
Temporarily commenting out source &lt;code&gt;$ZSH/oh-my-zsh.sh&lt;/code&gt; in &lt;code&gt;.zshrc&lt;/code&gt;: Even with Oh My Zsh completely disabled, the line still appeared.&lt;br&gt;
This confirmed the culprit was outside of Oh My Zsh's direct influence, meaning it was likely in another Zsh startup file or a system-level script.&lt;/p&gt;

&lt;p&gt;This narrowed the scope significantly. Zsh processes several startup files in a specific order:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~/.zshenv&lt;/code&gt;&lt;br&gt;
&lt;code&gt;~/.zprofile&lt;/code&gt; (for login shells)&lt;br&gt;
&lt;code&gt;~/.zshrc&lt;/code&gt; (for interactive shells)&lt;br&gt;
&lt;code&gt;~/.zlogin&lt;/code&gt; (for login shells, after .zshrc)&lt;br&gt;
Given the login shell behavior, &lt;code&gt;.zprofile&lt;/code&gt; became a prime suspect.&lt;/p&gt;
&lt;h1&gt;
  
  
  The Aha! Moment: &lt;code&gt;.zprofile&lt;/code&gt; Reveals Its Secrets
&lt;/h1&gt;

&lt;p&gt;Opening my &lt;code&gt;~/.zprofile&lt;/code&gt; file, I immediately spotted it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key&lt;/span&gt;
&lt;span class="c"&gt;# Add GPG key&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; ~/.zshrc &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'\nexport GPG_TTY=$(tty)'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="k"&gt;else &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'\nexport GPG_TTY=$(tty)'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zprofile&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There it was! A script, seemingly taken directly from GitHub's documentation on managing commit signature verification, designed to add &lt;code&gt;export GPG_TTY=$(tty)&lt;/code&gt; to my &lt;code&gt;.zshrc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is where I have to admit my own fault. Looking back at the documentation, it was clear that this command was meant to be run only once as a terminal command to initialize the configuration. Instead, I had mistakenly copied the logic and pasted it directly into my &lt;code&gt;~/.zprofile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The fatal flaw: This script lacked idempotence. It performed no check to see if GPG_TTY was already present in &lt;code&gt;~/.zshrc&lt;/code&gt;. Every time my login shell started and sourced &lt;code&gt;.zprofile&lt;/code&gt;, it dutifully checked if &lt;code&gt;.zshrc&lt;/code&gt; was readable (which it always was) and then unconditionally appended the line. Because &lt;code&gt;.zprofile&lt;/code&gt; runs on every new login session, it was effectively "spamming" my &lt;code&gt;.zshrc&lt;/code&gt; with new exports every time I opened my IDE or logged in.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Fix and the Lesson Learned
&lt;/h1&gt;

&lt;h2&gt;
  
  
  The solution was simple:
&lt;/h2&gt;

&lt;p&gt;I went back to my &lt;code&gt;~/.zshrc&lt;/code&gt; and manually deleted all the thousands of duplicate &lt;code&gt;export GPG_TTY=$(tty)&lt;/code&gt; lines.&lt;br&gt;
Crucially, I then removed the entire &lt;code&gt;if ... else ... fi&lt;/code&gt; block from my &lt;code&gt;~/.zprofile&lt;/code&gt;.&lt;br&gt;
Upon opening a new terminal, my &lt;code&gt;.zshrc&lt;/code&gt; remained pristine, &lt;code&gt;GPG_TTY&lt;/code&gt; was still correctly set (thanks to the Oh My Zsh &lt;code&gt;gpg-agent&lt;/code&gt; plugin), and most importantly, my terminal startup speed was back to being snappy!&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Lessons Learned
&lt;/h2&gt;

&lt;p&gt;Idempotence is king in dotfiles: Any script that modifies a configuration file should first check if the change is actually needed. Without this, you're inviting bloat, confusion, and significant performance degradation.&lt;br&gt;
Understand your shell's startup files: Knowing the order and purpose of &lt;code&gt;.zshenv&lt;/code&gt;, &lt;code&gt;.zprofile&lt;/code&gt;, &lt;code&gt;.zshrc&lt;/code&gt;, etc., is vital for effective troubleshooting.&lt;br&gt;
Third-party documentation can be a double-edged sword: While GitHub's guide intended to be helpful, the specific script provided for Zsh users could lead to issues if executed more than once, especially if it's placed in a file like &lt;code&gt;.zprofile&lt;/code&gt; that runs frequently.&lt;br&gt;
Trust the specialized tools: If you're using a plugin (like Oh My Zsh's &lt;code&gt;gpg-agent&lt;/code&gt;) designed to manage a specific environment variable, it's often best to let it handle the heavy lifting.&lt;br&gt;
This little adventure taught me a lot about the intricacies of my own shell environment. While it was a frustrating few days, the satisfaction of finally solving the mystery and reclaiming my fast terminal startup was well worth it. Keep your dotfiles clean, and always be wary of scripts that append without checking!&lt;/p&gt;

</description>
      <category>cli</category>
      <category>linux</category>
      <category>performance</category>
      <category>tooling</category>
    </item>
    <item>
      <title>The Neuroscience Behind Fixing Your Sleep Schedule Summarized</title>
      <dc:creator>NaN</dc:creator>
      <pubDate>Wed, 25 Sep 2024 09:47:04 +0000</pubDate>
      <link>https://dev.to/nan72/the-neuroscience-behind-fixing-your-sleep-schedule-summarized-32k0</link>
      <guid>https://dev.to/nan72/the-neuroscience-behind-fixing-your-sleep-schedule-summarized-32k0</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This is my summarization of &lt;a href="https://www.youtube.com/watch?v=cyKEfejsVps&amp;amp;list=WL&amp;amp;index=3" rel="noopener noreferrer"&gt;The Neuroscience Behind Fixing Your Sleep Schedule&lt;/a&gt; published by &lt;a href="https://www.youtube.com/@HealthyGamerGG" rel="noopener noreferrer"&gt;Dr.K or HealthyGamerGG&lt;/a&gt;. The original video provides a lot more information, context, and examples that make you understand more about the subject, I recommend watching the video. This post is just my summarized version for me and other people who might want more concise media, do not like to watch videos, or have not known Dr.K yet.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;TLDR:&lt;/strong&gt; &lt;em&gt;Don't miss your sleeping window, take free time during the day so that your brain can process your emotion, do some work, do some exercise, eat fully, manage your stress, and try to wake up early and at the same time everyday.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  You have a window to fall asleep
&lt;/h2&gt;

&lt;p&gt;It's called &lt;a href="https://www.nigms.nih.gov/education/fact-sheets/Pages/circadian-rhythms.aspx" rel="noopener noreferrer"&gt;Circadian rhythm&lt;/a&gt;, it dictates when it is the easiest to wake up and go to sleep. If you miss that window, it will become increasingly difficult to fall asleep.&lt;/p&gt;

&lt;p&gt;There are two things involved in it.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.ncbi.nlm.nih.gov/books/NBK519049/" rel="noopener noreferrer"&gt;&lt;em&gt;Adenosine&lt;/em&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;This chemical accumulates in your brain throughout the day. It signals the level of fatigue you have and makes you want to go to sleep.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://my.clevelandclinic.org/health/body/24501-frontal-lobe" rel="noopener noreferrer"&gt;&lt;em&gt;The frontal lope&lt;/em&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;It's inside your brain, restraining impulses and controlling behaviors. You can think of it as willpower and it's getting exhausted over time.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There's a window that the fatigue signals in the brain are high and you have enough willpower to restrain impulses which means you're tired enough and you can prevent yourself from doing anything else rather than going asleep.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you wake up at around 8 AM, your sleep window is probably around 9 PM and 10 PM, a 1 to 2-hour window.&lt;/p&gt;
&lt;h2&gt;
  
  
  Emotional flooding
&lt;/h2&gt;

&lt;p&gt;Everything in the modern world suppresses your emotional circuitry. The moment you put your device away (when you go to bed), you experience emotional flooding.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You then try to distract yourself (with some other activities - social media, Shorts, etc), but your emotion is still suppressed, you need more distraction; the loop goes on until your brain is too tired.&lt;/p&gt;

&lt;p&gt;The solution is to give yourself empty times in the day for your brain to take out the trash, to process your emotion. It's recommended to take an hour-long walk without listening to anything, try meditation, or journaling.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to spend your waking hours
&lt;/h2&gt;

&lt;p&gt;Your brain keeps track of all the things you need to work so if you procrastinate all day long, your brain won't let you fall asleep because you still have things to do.&lt;/p&gt;

&lt;p&gt;The solution is to do some kind of work in the day. It doesn't need to be important work, it can be meaningless, it just needs to be some kind of work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Anabolism
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Exercise
&lt;/h3&gt;

&lt;p&gt;Your body builds tissues when you sleep, if you need to develop tissues, you need more sleep (think of a baby or a bodybuilder).&lt;br&gt;
So, doing some exercises will help you sleep better.&lt;/p&gt;

&lt;h3&gt;
  
  
  Learning
&lt;/h3&gt;

&lt;p&gt;Make sure you eat throughout the day. If you don't, your brain will keep you awake because of its lack of nutrients (caloric/nutrient deficit).&lt;/p&gt;

&lt;p&gt;Your dinner should be heavy and rich in carbohydrates which stimulate insulin that makes you sleepy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stress
&lt;/h3&gt;

&lt;p&gt;Stress makes your brain think you are in danger, and as a result, it keeps you awake.&lt;/p&gt;

&lt;p&gt;People commonly think that they need to fix their sleep schedule to fix their lives. However, it's the opposite, fixing your life will as a result fix your sleep schedule.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips and others
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Waking up when you're tired is easier than going to bed when you're not.&lt;/li&gt;
&lt;li&gt;It's not about going to bed on time but about waking up on time or even waking up early.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;You can start waking up between 4 AM and 7 AM. Don't have coffee immediately (you can have that later) and start working immediately. You will have the ability to work better and your brain will think you have done enough work to fall asleep later in the day.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you're tired, don't go to sleep immediately but wait for your natural bedtime.&lt;/li&gt;
&lt;li&gt;Observe dawn and dusk, and have some natural light in your daytime.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Feeling overwhelmed isn't about the total number of tasks that you do. It's about the number of tasks that you CHOOSE to do compared to those that you HAVE to do. The more you CHOOSE to take on, the less overwhelmed you will feel.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>personaldevelopment</category>
    </item>
  </channel>
</rss>
