Today I ran hugo new to create a file, and then wanted to edit it. I have fzf set up to let me open files in Vim, but suddenly realized… why doesn’t the file I just created show up as the first option in fzf? Apparently the answer is that it’s really annoying to get a recursive list of files and then sort them by creation date, to the point where [a Reddit post asking my exact question] had no answers.

It took a while to dig around in various different tools’ docs and repos, but I eventually landed on using rg to list files. This does exactly what I wanted, and I’m really happy with it:

FZF_DEFAULT_COMMAND='rg --files --sortr created' fzf --tmux --print0 | xargs -0 -o $EDITOR

Here’s a breakdown: