DEV Community

Roflostroy
Roflostroy

Posted on

Building SWISS: My first Open Source project in pure Bash

How I built a pure Bash multi-tool as a first-year CS student

Hi everyone!

I'm a first-year computer science student from Russia. I've been learning Linux and Bash scripting for a while, and I got really tired of constantly googling the syntax and flags for find and chmod.

So I decided to build a tool to solve my own pain: SWISS.

What is SWISS?

SWISS is a terminal multi-tool. It has no external dependencies (just standard Linux utilities) and combines three things into one colorful TUI (Text User Interface) menu:

  1. File Search: By name, extension, time, size, and permissions.
  2. Hex Viewer: View files in hex format (with basic encoding conversion via iconv).
  3. Rights Manager: An interactive chmod guide and manager.

The challenges I faced

Building a TUI in pure Bash is tricky. Here are a few things I struggled with:

  • Handling binary files: Bash's read command can be a bit finicky with null bytes in binary files, so the hex viewer sometimes struggles with large non-text files.
  • The time variable: I ran into a funny bug where I used the same variable for choosing the search type (day or date) and the actual value. It worked, but it was a mess to debug.
  • Localization: Right now, the interface is entirely in Russian. I'm planning to add English support in the next version.

What I learned

  1. Bash is powerful but has limits. It's great for automation and simple menus, but for complex TUI, Python with curses is probably the better choice.
  2. Open source is awesome. I submitted a Pull Request to add SWISS to the awesome-bash list, and it taught me a lot about how the Open Source community works.
  3. Building for yourself is the best motivation. I use SWISS every day, and it actually makes my life easier.

GitHub Link

You can check out the code, download the release, or leave feedback here:

👉 SWISS on GitHub

I would really appreciate any feedback, especially on how to make the code cleaner and more portable!

Top comments (0)