View on GitHub

Marker

Bookmark your terminal commands.

Download this project as a .zip file Download this project as a tar.gz file

marker

Do you heavily use Ctrl+R(search through history) to search for commands that you frequently use?
Marker lets you easily bookmark these commands and quickly retrieve them without going through Shell Aliases/Functions/Multiple Ctrl-R...
It offers the following features:

command-template

Usage

Simplicity is key, Three keyboard shortcuts let you take most of Marker:

ScreenShot

Requirements

Installation

How It Works:

Marker is a composed of shell script, and a python tool:
The shell code acts as a wrapper around that python tool, it's responsible for managing the user input in the command-line(adding/removing text, moving the cursor around etc...).
The python utility in the other hand(called marker) contains the app logic. It manages the bookmarked data, do the matching, and present a UI selector if it's called in interactive mode. It doesn't depend on the Shell script, so it can be called separately as a command line utility(marker --help)

The communication between the shell script and the python commandline tool is done via a temporary file. For example, here's how things work when Ctrl+space is pressed:

You can take a look at bin/marker.sh for more details. Most magic happens there.

Limitation with Bash (and shells that use Readline):

Bash uses an external library(Readline) to process the user input in the command-line(including keyboard bindings). This separation makes it hard to script and extend the command-line when certain keys are pressed. For example, It's not possible to invoke shell functions intuitively when a user press a keyboard shortcut and manipulate the command-line from those functions(in contrast with zshell where the input processor zle is integrated within the shell).

A couple of hacks were made to make Marker work with Bash, notably triggering shell-expand-line to evaluate a shell function with the current written string as an argument. This shell function will then executes some logic and dynamically bind a certain sequence of characters to a temporary keyboard shortcut which will be executed finally by the original shortcut(ie ctrl-Space)(bin/marker.sh contains more details).

Sadly, hacks come with a cost: It's not possible to use the keyboard shortcuts Ctrl-k and Ctrl-t with commands that contain single quotes (') because single quotes are used to enclose the user input. So you probably should use double quotes with escaping instead(see here for difference between single and double quotes)

License

MIT