Suggestion for Improving Autocomplete Task Instructions

I’m currently working on the Shell project, specifically the task to implement autocomplete for builtin commands like echo and exit. While the task instructions are straightforward about what needs to be achieved (autocompleting commands on TAB presses), I noticed they don’t mention a key detail that could trip up users - especially those new to terminal programming: the need to enable raw mode to handle TAB key presses manually.

From my experience, the default terminal behavior processes the TAB key for indentation, which prevents a program from capturing it directly. To implement custom autocomplete functionality, we need to enable raw mode (sometimes called uncooked mode) so the shell can read input character-by-character and intercept special keys like TAB. Without this context, users might wonder why their program isn’t responding to TAB presses as expected.

I’d suggest adding a brief note or section to the task description to clarify this requirement.

Here’s an example of what could be included:

To handle TAB key presses for autocomplete, you’ll need to enable raw mode in your shell. In raw mode, your program receives input directly, bypassing the terminal’s default processing. This is essential for capturing special keys like TAB and implementing custom behavior.
2. Entering raw mode | Build Your Own Text Editor
Alternatively, you can skip the low-level work and use third-party libraries like prompt-toolkit (for Python). These libraries handle raw mode and autocomplete for you, making the implementation much simpler.

P.S. Loving the Shell project so far!

2 Likes