← Questions

Shell tab completion for file paths

0
FigmaCodingLast asked May 2022

Implement what a shell does when you press Tab. You get the absolute paths of all files, the current directory and the text typed so far. Resolve the typed text against the current directory unless it starts with /. If files start with that prefix, complete to the longest prefix they all share (which may run through several directory names); otherwise return the prefix unchanged. Discuss a trie for repeated completions over a large file tree.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding