In my decade-plus of maintaining my dotfiles, I’ve written a lot of little shell scripts. Here’s a big list of my personal favorites.

  • Evan Hahn
  • e0qdk@reddthat.com
    link
    fedilink
    arrow-up
    6
    ·
    20 hours ago

    Here’s one of mine. I got annoyed at the complexity of other command line spellcheckers I tried and replaced them with this simple python script for when I just want to check if a single word is correct:

    #!/usr/bin/env python3
    
    import sys
    
    try:
      query = sys.argv[1].lower()
    except Exception:
      print("Usage: spellcheck <word>")
      exit(1)
    
    with open("/usr/share/dict/words") as f:
      words = f.readlines()
    
    words = [x.strip().lower() for x in words if len(x.strip()) > 0]
    
    if not query in words:
      print("Not in dictionary -- probably a typo")
      exit(1)
    else:
      print("OK")
      exit(0)