I invite you to upgrade to a paid subscription. Paid subscribers have told me they appreciate me creating the programming projects and would like to see more of them in the future. Hi, this is John with this week’s Coding Challenge. 🙏 Thank you for being a subscriber, I’m honoured to have you as a reader. 🎉 If there is a Coding Challenge you’d like to see, please let me know by replying to this email📧 Coding Challenge #137 - fzfThis challenge is to build your own version of
Underneath the friendly interface there is a surprising amount of interesting engineering: a scoring algorithm that ranks matches the way a human would, a terminal user interface built from raw escape sequences, and a design that is responsive while a huge stream of input. Building your own The Challenge - Building Your Own fzfIn this challenge you’re going to build your own fuzzy finder. It will read a list of items, take over the terminal, and let the user type a query that filters and re-ranks the list on every keystroke. By the end you’ll have a tool you can drop into your own shell aliases and scripts in place of the real Step ZeroIn this introductory step you’re going to set your environment up ready to begin developing and testing your solution. Choose your target platform and programming language. You’ll be reading key presses one at a time and drawing directly to the terminal, so look for a language that lets you put the terminal into raw mode and write escape sequences, either from its standard library or from a small terminal library. Avoid anything that hides the terminal from you completely. Before you write any code, spend time with the real thing. Install
Pay attention to the small details, like what happens to the screen when you quit, what the counter above the prompt shows, and which items float to the top when you type a few letters. You’ll also want some test data. A big list of lines is ideal, so grab a word list and generate a large file of paths to use throughout the challenge:
Keep both files handy, you’ll use the small one for correctness and the large one for performance. Step 1In this step your goal is to build the skeleton of the finder: read items, show them, and let the user pick one. Your tool should read newline-delimited items from standard input and display them in an interactive full-screen list, with a prompt where the user’s query will eventually go. Pressing The finder should draw itself on the alternate screen buffer, so when it exits the user’s original terminal contents and cursor position are exactly as they were before. It should exit with the right status code, because scripts depend on these: Testing: Run your finder against a small list and select an item:
You should get a full screen list of the three items, and after pressing
Selecting an item should report
Step 2In this step your goal is to make the finder filter as the user types. Your finder should accept typed characters into the query and narrow the list to the items that match. A match is a fuzzy match: the query characters must appear in the item in order, but they do not have to be next to each other. So Matching should use smart case by default, which means the query is matched case-insensitively unless it contains an uppercase letter, in which case it becomes case-sensitive. The user should be able to override this with Now that there is a query, the rest of the default key bindings should work too. Finally, add Testing: Filter the word list and watch the results change on every keystroke:
Type
Move up and down with the arrow keys and with the control keys and confirm both work, then check each editing key does what it should. Check that
Step 3In this step your goal is to rank the matches so the best one is at the top. A fuzzy match on its own is not much use when a query matches ten thousand items. Your finder should score every match and sort the results best first. A good score rewards the things a we care about: characters that matched next to each other, characters that matched at the start of a word (after a space, Your finder should support When two items score the same, Have a read of the fzf algorithm notes if you want to see how the original approaches this, but try it yourself first. Testing: Check that the obvious best match wins:
Type the same query into both and confirm
The shortest item should be first. Run it again with Step 4In this step your goal is to make the finder start instantly and stay responsive, no matter how much input is coming. Right now your finder probably reads all of its input before it draws anything. Real To show what is happening, add an info line that displays how many items currently match out of the total number read so far. It should support Two flags change the order items are considered in: The real test of this step is scale. Your finder should stay interactive with an input of at least one million items, filtering and re-sorting on every keystroke with no pause you can feel. Testing: Check that the finder appears before the input has finished:
The interface should appear immediately and the counter should climb while you type. Try a deliberately slow producer:
You should be able to type and move around while new items keep appearing. Then test at scale:
Type a query one character at a time and confirm each keystroke feels instant. Check the info line with
Step 5In this step your goal is to support extended-search mode, which turns the query box into a small search language. Extended-search mode is enabled by default. In it, the query is split on spaces and each term must match, so
Two flags change the rules. Testing: Build a small list you can reason about:
Then check each form of term:
The first should leave only Step 6In this step your goal is to let the user pick more than one item, and to control the query and the output from the command line. Your finder should support Alongside that, add the options that make the finder easy to drive from a script:
Testing: Mark a few items and check they all come out:
Press
The filter run should print matches in the same order the interactive list would show them, without ever clearing the screen. The Step 7In this step your goal is to make your finder a good citizen of the shell. So far your finder always takes over the whole screen. Add The list arrangement should be configurable too, with Then add the features that let it slot into pipelines and key bindings:
Testing: Check the window and layouts:
Your shell prompt and previous output should still be visible above the finder, and the second command should shrink the window when few items match. Then check the rest:
With Step 8In this step your goal is to add the two features that make First, fields. Second, previews. Testing: Search on a single column of a table:
You should be matching and seeing only the command, not the process statistics. Try a different delimiter:
Typing a user name should match, but typing part of a home directory path should not. Then check the previews:
The preview should update as you move the cursor, the window should move where you asked it to, and the Going FurtherOnce you have the core finder working, here are some ideas to take it further:
Share Your Solutions!If you think your solution is an example other developers can learn from please share it, put it on GitHub, GitLab or elsewhere. Then let me know via Bluesky or LinkedIn or just post about it there and tag me. Alternately please add a link to it in the Coding Challenges Shared Solutions Github repo Request for FeedbackI’m writing these challenges to help you develop your skills as a software engineer based on how I’ve approached my own personal learning and development. What works for me, might not be the best way for you - so if you have suggestions for how I can make these challenges more useful to you and others, please get in touch and let me know. All feedback is greatly appreciated. You can reach me on Bluesky, LinkedIn or through SubStack Thanks and happy coding! John Invite your friends and earn rewards
If you enjoy Coding Challenges, share it with your friends and earn rewards when they subscribe.
|
#6636 WWE 2K26 v1.06 + 6 DLCs [Monkey Repack] Genres/Tags: Arcade, Fighting, Sports, 3D Companies: 2K Games, Visual Concepts Languages: ENG/MULTI6 Original Size: 129.2 GB Repack Size: 107.8 GB Download Mirrors (Direct Links) .dlinks {margi… Read on blog or Reader FitGirl Repacks Read on blog or Reader WWE 2K26, v1.06 + 6 DLCs [Monkey Repack] By FitGirl on 28/03/2026 # 66 3 6 WWE 2K2 6 v1.0 6 + 6 DLCs [Monkey ...

Comments
Post a Comment