HexSh
Hexadecimal text file editor written in pure Bash.
release date: 2025-03-23
about
HexSh is a Bash script that, using a minimal set of additional tools (tput, jq - basics), allows editing small files in hexadecimal mode – byte by byte.
There are several ready-made programs of this type, but none of them have been written in Bash so far.
The efficiency and performance of the script are not astonishing, but it is a great example that Bash is suitable not only for displaying characters in the terminal.
There are several ready-made programs of this type, but none of them have been written in Bash so far.
The efficiency and performance of the script are not astonishing, but it is a great example that Bash is suitable not only for displaying characters in the terminal.
features
The script can primarily display file contents in Hex, edit individual bytes, and uniquely allows adding new lines and characters (so you can insert something inside a file fragment without having to overwrite and guess).
It also offers fairly simple navigation between offsets using arrow keys and selected other keys.
Jumping between specific offsets, lines, etc., is also possible.
There is an option to toggle ANSI preview of the edited file; to show or hide the offset number panel, as well as a "fast mode" that enables quicker operation on weaker devices at the cost of display quality.
The script can work on a file given as a parameter or ask for the file path interactively if none is provided. HexSh can save an existing file or create a new one.
It also allows creating new lines, quickly inserting spaces (byte code 20), and deleting characters – if you see "--", it means that byte no longer exists!
These are just some of the script’s features. To discover them all, clone the repository, run the script, and open the help menu by pressing "H".
It also offers fairly simple navigation between offsets using arrow keys and selected other keys.
Jumping between specific offsets, lines, etc., is also possible.
There is an option to toggle ANSI preview of the edited file; to show or hide the offset number panel, as well as a "fast mode" that enables quicker operation on weaker devices at the cost of display quality.
The script can work on a file given as a parameter or ask for the file path interactively if none is provided. HexSh can save an existing file or create a new one.
It also allows creating new lines, quickly inserting spaces (byte code 20), and deleting characters – if you see "--", it means that byte no longer exists!
These are just some of the script’s features. To discover them all, clone the repository, run the script, and open the help menu by pressing "H".
compatibility
Compatibility? Do you have access to Bash? Tput? JQ? These are basic tools on almost all modern Unix systems. You can run the script on Linux, Termux, or MacOS. Anywhere you have access to a terminal with the aforementioned tools.
The script isn't the most efficient - that’s something I have to admit. It’s not suitable for working with files larger than 10MB. I’m working on fixing this - reading files in smaller chunks. But for now, it works anywhere you have a terminal :)
The script isn't the most efficient - that’s something I have to admit. It’s not suitable for working with files larger than 10MB. I’m working on fixing this - reading files in smaller chunks. But for now, it works anywhere you have a terminal :)