Cobbling Together My Perfect Writing App

Using a hodgepodge of tools has allowed me to “build” my ideal writing app.

The Command Line is Not Dead

I’ve looked around for the perfect writing app for a long time. This search has taken me to many different writing apps, but I was never satisfied with any of them.

One major feature that I’ve desired in every app is a fast way to search the contents of an entire folder of files. That’s no small feat. Right now, I have over 1000 files that I search through regularly. Most apps I’ve tried fail hard when trying to do this. Even when trying to find a single file that I know the name of, most applications stutter.

Thankfully, this is not the case everywhere. With the command line and a few applications that I’ve really grown to love, I can finally search files quickly. I just had to give up the entire idea of a graphical interface.

Background

My world changed when I switched to the text editor vim. Because I didn’t just switch applications, I switched mindsets. I started obeying the UNIX philosophy. Unfortunately that concept is gibberish to most people. In oversimplified terms, the UNIX philosophy states that programs should do one thing and do it well.

There’s no real analog for this in real life because you have physical space to account for. While you don’t really want a drill to do ten actions, it’s extremely useful to have both sides of a claw hammer.

With software it comes down to this:

vim is great at editing files.
fzf is great at finding files.
ag is great at searching for things in files.

Finding Files

The first app1 that I found to be super useful is called fzf. Created to be the ultimate fuzzy finder, I’ve started to really rely on fzf in multiple places of my workflow.

On its own, fzf doesn’t look like much. Honestly, that’s its beauty. By creating my own glue, I can put fzf where I need it.

Moving around the Command Line

If I’m in folder “A” and I want to jump into folder “B” very quickly, fzf and another utility fasd make that process simple. All I do is type z and then part of the directory’s name like z drafts. If there’s multiple matches for my “search,” I’m popped into fzf so I can fuzzy find for what I actually meant. Really, anytime I need a directory or file for a command I can use fzf‘s keyboard shortcut to find what I need2.

Highly customized workflows

A great example of “piping” commands together is something I built for work.

I download reports for my job regularly. These are .csv files, or comma separated values, that have horrid names that always start with “http”. So here’s what I did every time I needed to make a new report:

  1. Export the report file from the website to my Downloads folder
  2. Move the downloaded file to my Reports directory
  3. Rename the file to something short that I’ll sort of remember later
  4. Run a Python script that cleans the report and makes it human readable
  5. Open the report to view the information

So before I would have to run four or five commands to get the report into its final state. That wasn’t okay. I knew that this situation was perfect for automation. One command is all I need now. I supply a file name to the “program” and it uses our friend fzf to help move the file rename it and then run the Python script. Here’s a slightly modified version of my command:

myreport() {
    mv ~/Downloads/$(fzf -q "http" -1) ~/my/reports/directory/$1 &&
    python ~/my/reports/directory/$1.csv
}

This works great because fzf searches my downloads folder and if it only finds one match for “http” it selects it, otherwise it’ll give me a list to choose from. The file is then given my supplied name and moved to the proper directory where Python can do its thing. Yes, I still have to download the report and open it at the end, but it is so much faster and less error prone now that the in-between steps are automated.

vim

Probably where fzf sees the most action is in vim. This tight integration gives vim super powers for searching. I can look through my directory’s contents, vim‘s open files, search history, recently opened files and so much more that I rarely touch.

What I use frequently is mapped to keyboard shortcuts like searching currently open files and the directory search so I can quickly jump to files. This has been an invaluable time saver. The other major way I search in vim is in conjunctions with ag which takes finding things to a whole other level.

Finding That One File With That One Word

grep is a very popular command for finding things. It’s very common to run something like cat logfile | grep some_error_message to pull out errors from a document. What I didn’t realize is that grep is slow. So many people have improved upon it. The particular utility I use is called ag or the_silver_searcher3.

Since moving from Sublime Text[sublime-text] for my daily writing tasks, I’ve missed a true “find in everything”. ag is a vast improvement for what Sublime offers. It’s fast and versatile and just like fzf, ag can glued together with other applications to create unique, specific workflows.

In vim especially using fzf.vim’s command :Ag <search term> I can easily sort through all of the results with fuzzy finding. That’s fuzzy finding in fuzzy finding in fuzzy finding.

My New Text Editor

I always knew that I wouldn’t be satisfied with what a single app would provide for me with writing. I knew that the UNIX philosiphy of finding the perfect tool for each link in the chain made the most. But for some reason, I didn’t try making my own version of text editing workflow until recently. This is really the only way I’ll truly be happy editing text. Without a GUI and making my own workflows from scratch. For all those that actually use the command line out there, I hope this post has given you some ideas of where your workflows could improve.


  1. Calling these apps still feels weird to me. What should I say instead, utilities? 
  2. CTRL-T ALL THE THINGS] 
  3. Technically, ag isn’t mimicking grep but instead, a program called ack. But I’m simplifying here. 
Permalink