You are browsing as a guest. Sign up (or log in) to start making projects!

2h 50m 52s logged

WebOS 2 Devlog #3: Building a UNIX Terminal + some other improvements

This was a major update today for WebOS 2.0 as i built a genuinely realistic CLI. It’s looks and acts like a Mac Terminal (cus i use mac). Here is what i implemented:

  • In the terminal, i implemented the following commands: help, clear, pwd, ls, cd, cat, touch, mkdir, rm, echo, whoami, date, history, and nano. This part itseld wasnt so difficult cus I had previously done something similar before but it was still challenging nonetheless.

  • I wanted the CLI to be as realistic as possible so I implemented (with a little bit of help from gemini) a custom AST-style parser. It fully supports logical command chaining (&&, ||, ;), quotation marks usage (both single and double), and file redirection (>, ») straight into the virtual hard drive.

  • Autocomplete: This was probably the hardest thing i tried to build and i am happy with how it turned out. I implemented a zsh-style Tab completion system. Pressing Tab auto-fills the longest common prefix and then shows all the possible options directly beneath your active prompt. This is one of the things I a most proud of because after using it, it was essentially very similar to the mac Terminal. This autocomplete works both for commands and files/folders.

  • Errors and stuff: The terminal behaves exactly like real bash. If you type ls -la (-la is not implemented [yet?]) or cd too many args, it won’t just blindly execute or fail silently (it originally did so i had to change it), but it will spit back the same error message you’d expect to see on a real machine.

  • GUI/CLI Integration: When i was implementing nano, i tried to think of how to implement a CLI editor. But i then realised, i can just connect the nano command to the notepad that I alreadu made. So typing nano test.txt in the terminal now just launches the Notepad app and opens the file for editing.

And I made some other changes to stuff like the file manager but the terminal implementation above is the biggest change.

0
4

Comments 0

No comments yet. Be the first!