Home

Awesome

rebase-editor

Simple terminal based sequence editor for git interactive rebase. Written in Node.js, published to npm, uses terminal-kit.

Build Status Coverage Status

rebase-editor

VERSION 2.0 IS OUT :sparkles: :camel: :boom:</br> New features: Select multiple lines, and undo changes, update-ref, rebase-merges!</br> Check the changelog for details.

Install

 npm install -g rebase-editor
 git config --global sequence.editor rebase-editor

NOTE: Also works with Yarn: yarn global add rebase-editor

Usage

The terminal prints out the standard interactive rebase file that git creates, plus some extra command info in the comments. When using the standard commands, the current lines action changes to the corresponding action:

Commands:

NOTE: x, exec command is not supported

Supported extra commands are:

To use a different editor for one time only you can use the GIT_SEQUENCE_EDITOR environment variable (replace vi with your favorite editor):

GIT_SEQUENCE_EDITOR="vi" git rebase -i master

Command line arguments

The editor accepts the following command line arguments:

  git config --global sequence.editor "rebase-editor -s -c -m '> ' -k ~/.rebase-editor-keybindings.json --"

NOTE: When using command line arguments the command should end with -- to separate custom arguments from the filename of the rebase file

Custom key bindings

The keybindings must be a file that can be required, either JSON or a node module that exports a simple object. The specials keys that are supported are defined by terminal-kit.

Default key bindings

{
  "UP": "up",
  "DOWN": "down",
  "LEFT": "moveUp",
  "CTRL_UP": "moveUp",
  "RIGHT": "moveDown",
  "CTRL_DOWN": "moveDown",
  "END": "end",
  "HOME": "home",
  "PAGE_DOWN": "pageDown",
  "PAGE_UP": "pageUp",
  "SHIFT_UP": "selectUp",
  "SHIFT_DOWN": "selectDown",
  "SHIFT_LEFT": "selectUp",
  "SHIFT_RIGHT": "selectDown",
  "SHIFT_PAGE_DOWN": "selectPageDown",
  "SHIFT_PAGE_UP": "selectPageUp",
  "SHIFT_HOME": "selectHome",
  "SHIFT_END": "selectEnd",
  "p": "pick",
  "r": "reword",
  "e": "edit",
  "s": "squash",
  "f": "fixup",
  "d": "drop",
  "BACKSPACE": "drop",
  "DELETE": "drop",
  "z": "undo",
  "CTRL_Z": "undo",
  "Z": "redo",
  "CTRL_SHIFT_Z": "redo",
  "q": "quit",
  "ENTER": "quit",
  "CTRL_C": "abort",
  "ESCAPE": "abort"
}

A note on key bindings for Mac

Not all key combinations work on Mac by default. Most notably, no modifier keys work with UP/DOWN (Like SHIFT, CTRL, ALT, META/CMD). Fn works kind of but it translates to PAGE_UP/DOWN. Therefor I decided to use the LEFT/RIGHT combinations as a fallback for Mac. You can however configure your terminal manually. See #8 for a guide how to do that.

Likewise CMD-Z, CMD-SHIFT-Z does not work either(CMD doesn't work at all really). So I went with simply z,Z for undo redo.

Does it work on...

PlatformSupport
MacYes
LinuxYes
WindowsYes, but not Git Bash (#7)

Made a mistake?

git reflog is your friend: git-reflog

Uninstall

npm remove -g rebase-editor
git config --global --unset sequence.editor

Yarn: yarn global remove rebase-editor

Development

Testing

npm test or npm run tdd

For debugging I have a test file I have been using.

node index.js example

For debugging using git:

GIT_SEQUENCE_EDITOR="./index.js" git rebase -i master

Changelog

v1.0.0

Initial version

v2.0.0

Complete rewrite with new architecture and test driven implementation.

New features:

Breaking changes:

v2.0.5

New features

v2.0.6, v2.0.7

New features

v2.0.8

New features

v2.0.9

Bugfix

TODO

Or not.. I have never found use for this function anyways, and I'm not sure how I would like the workflow and keymapping to work.

Contributions

Contributions and comments are welcome, just make an issue and/or pull req.

To get started just clone the repo and run npm install

To test manually using an example file in the repo: ./index.js example

To test manually using git: GIT_SEQUENCE_EDITOR=./index.js git rebase -i HEAD^^^

Make sure to run the test npm test and check the testing coverage npm run cover before you create a pr. I do have full test coverage and would like to keep it like that.

Credits

Thanks to Node.js and the wonderful terminal-kit project. Also thanks to @perlun and @real-yfprojects for contributing.

See also

There is also git-interactive-rebase-tool, a similar tool written in Rust.