A leading space in command wastes lots of my time

This one doesn’t have a TL;DR

Background

What I did

  • I wrote two specific shell aliases for rspec, re for running specs without error backtraces, ree for with error backtraces

    1
    2
    alias re="DISABLE_SPRING=1 bundle exec rspec --format=progress --no-profile"
    alias ree="DISABLE_SPRING=1 bundle exec rspec --format=progress --no-profile --backtrace"
  • One day, I found it looks better if I change them to this(alignment):

    1
    2
    alias re=" DISABLE_SPRING=1 bundle exec rspec --format=progress --no-profile"
    alias ree="DISABLE_SPRING=1 bundle exec rspec --format=progress --no-profile --backtrace"

  • Later, I forgot the change

  • Somehow, I find the frequently used re command never got remembered by type re and press the up arrow(which acts as searching from history in OMZ)

Trouble shooting

  • I didn’t think too much about what I’v recently changed
  • I thought I screwed up my OMZ environment, so I keep creating new terminal session, didn’t work
  • I thought my history file is too big, so I cleared the history file, didn’t work
  • I put this issue aside for a few days without any solution, suffering from typing/copy-paste the frequently used rspec commands again and again
  • A few days later, I can’t stand it anymore, and at this time, I found that only that rspec related command won’t be remembered by history!(still didn’t connect to previous changes…)
  • Until second day when I tried to optimize my OMZ plugin, I noticed the git history: THERE IS A LEADING SPACE IN MY RSPEC ALIAS!!! because of the code alignment

The reason

The fix

  • Remove the leading space in shell alias, simple enough

Learnings