Git Product home page Git Product logo

teehee's Introduction

Teehee - a modal terminal hex editor

AUR version

Inspired by Vim, Kakoune and Hiew.

Installation

Arch Linux users: The package for Arch Linux is available on AUR.

Others: Just run cargo install teehee! If you don't have rust, you can get it from rustup.rs. The application will be available as the executable teehee. More installation options may be coming in the future.

Motivation

Reverse engineers, software engineers and other IT people often need to work with binary files. Hex editors are usually the go-to tool for dealing with binary file formats when a more specialized tool isn't available. Many of the existing hex editors lack support for modal editing, which Vim/Kakoune/Emacs users will miss. Hiew supports it to an extent, but it's non-free software, and its keybinds are unintuitive. Teehee is designed to offer a native-feeling experience to Kakoune and Vim users, while also providing additional hex editing capabilities like coloured marks for regions of data and encryption/compression scripts.

Demo

asciicast

Teehee supports multiple selections, efficient selection modifying commands and various data editing operations.

Design

image

Implemented keybinds

  • hjkl for movement (press shift to extend selection instead)
    ^
    k
< h   l >
    j
    v
  • g[hjkl] for jumping (G[hjkl] to extend selection instead)
    • h: to line start
    • l: to line end
    • k: to file start
    • j: to file end
    • <count>g jumps to offset, <count>G extends to offset
  • <C+e/y> to scroll down/up
  • ; to collapse selections to cursors
  • <a-;> (alt and ;) to swap cursor and selection end
  • <a-s> (alt and s) to split selection to multiple selections of size...
    • b: 1 byte
    • w: 2 bytes (Word)
    • d: 4 bytes (Dword)
    • q: 8 bytes (Qword)
    • o: 16 bytes (Oword)
    • n: delimited by null bytes
    • /: matching a text pattern (? for hex pattern)
  • d to delete selected data from buffer
  • i to enter insert mode at the beginning of selections (I to insert hex instead of ascii)
    • a instead of i to enter append mode instead
    • o instead of i to enter overwrite mode instead
    • c instead of i to delete selection contents, then enter insert mode
    • <c-n> to insert a null byte in ascii mode
    • <c-o> to switch between ascii and hex inserting
  • ( and ) to cycle main selection
  • <space> to keep only main selection, <a-space> to keep all selections but main
  • r<key> to replace a each selected character with the ASCII character given
    • R<digit><digit> instead of r to replace with a single hex character instead
    • r<c-n> to replace with null bytes
  • y to yank/copy selections to register "
  • p to paste register " contents from y/d/c
  • s to collapse selections to those matching a text pattern (S for hex pattern)
  • M to measure length of current main selection (in bytes)
  • u to undo, U to redo
  • : to enter command mode
    • :q to quit
    • :q! to force quit (even if buffer dirty)
    • :w to flush buffer to disk
    • :w <filename> to save buffer to named file
    • :wa to flush all buffers to disk
    • :e <filename> to open a new buffer
    • :db to close a buffer
    • :db! to close a buffer even if dirty
    • :wq to flush buffer, then quit

Entering a pattern:

  • <C-w> to insert a wildcard
  • <C-o> to switch input mode (ascii <-> hex)
  • <esc> to go back to normal mode
  • <enter> to accept pattern
  • arrow keys, <backspace> and <delete> also supported

Counts:

  • The following commands maybe prefixed by a count:
    • Movement (hjkl and HJKL)
    • Selection modification (()<space><a-space>)
    • Jump to offset (g and G)
    • Paste (p)
    • (In split mode) bwdqon
  • Counts are inputted by typing digits 0-9 (in hex mode, 0-f).
  • x switches between hex and decimal mode.
  • Note that a-f may shadow some keys, so switch out of hex mode before running a command.
  • Example: y5p: yank the selection and paste it 5 times.
  • Example: 50l: Move 50 bytes to the right.
  • Example: x500g: Jump to offset 0x500
  • Example: <a-s>x12xb: Split selection into parts of 0x12 bytes.

Releases

Releases are signed with the following PGP key: 9330E5D6861507BEFBF1893347E208E66179DC94. The source code can be found on the GitHub releases page, along with the signature of the source code tgz.

teehee's People

Contributors

gskartwii avatar maximbaz avatar thebesttvarynka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

teehee's Issues

Append at EOF

Currently, appending at EOF is broken, because the following simple_extend refuses to cover the EOF mark:

teehee/src/hex_view.rs

Lines 806 to 810 in 6d4227d

vec![region.to_forward().simple_extend(
Direction::Right,
bytes_per_line,
max_size,
)]

Currently, it functions like insert mode (so there isn't a way to insert anything as the last character of a file). This is going to need some thought.

Allow sending teehee to background

Is your feature request related to a problem? Please describe.
It should be possible to send teehee to the background using Ctrl+Z like NeoVim and Helix allow to.

Additional context
Currently, when pressing Ctrl+Z nothing happens.

Test failure in 0.2.6

Hi there,

I'm running tests as part of AUR package, and it shows one failed test, which I can also reproduce manually ๐Ÿ˜‰

It's mostly FYI, plus a suggestion to perhaps use Github Actions to run tests on main branch?

If you want, this works really well for my other rust project:

name: CI
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    name: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: cargo test --locked

  lint:
    name: lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: cargo fmt -- --check
      - run: cargo clippy -- -Dwarnings

Tag versions using git

Hey, I saw you take good care of updating versions in Cargo.toml, may I ask you to also tag them using git?

It should be as easy as running git tag 0.2.2 and git push --tags on the commit where you bumped the version.

If you use PGP, I can also tell you how to provide signatures, if not - nevermind, it's not a big deal ๐Ÿ™‚

I simply cannot resist packaging this awesome tool for Arch Linux, more people should be able to discover it, and having git tags would allow me to make the package easier, and once it gains more popularity, later move from AUR to community repo.

Many thanks ๐Ÿ™‚ I'll update you with the link to the package, so you can also put it in README if you like.

Support search feature like vim

Is your feature request related to a problem? Please describe.

I just want to open a binary file and search for some bytes in hex format, it would be nice if teehee supports search/search-replace feature like vim does.

Describe the solution you'd like

search/search-replace feature in vim could be a nice reference implementation.

Describe alternatives you've considered
n.a.

Additional context
n.a.

Make repo discoverable

You tagged the repo with hex-editors, while hex-editor is much more widely used, consider updating that ;)

Load file partially

Is your feature request related to a problem? Please describe.
One of my main use-cases for hex editors is fixing issues with partitions.
Partitions can be huge, and it seems that teehee tries to load the edited file fully into
memory, making it basically unusable for that.

Describe the solution you'd like
Idk how hexedit does it exactly, but it opens instantly. I guess it doesn't
read the whole thing into memory.

Describe alternatives you've considered
Going back to hexedit :/

Feature request: undo/redo

Impressive project! I really like it!

One feature that I think would be really useful for such editor is to support undo and redo operations.

I know kakoune has a fancy tree history, but maybe a simple linear history would already be good enough of a start.

Help file, you can quickly query the shortcut key

Is your feature request related to a problem? Please describe.
This tool is not used frequently, but sometimes it is necessary to use it. I hope we can add a help interface to assist us in querying the keyboard shortcuts.

Describe the solution you'd like
For example, pressing the '?' key will display a list of keyboard shortcuts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.