Skip to content
/ smarky Public

A command bookmarks tool made with SQLite. Oversimplified version of pindexis/marker. Useful if you don't want to write script files left and right.

License

Notifications You must be signed in to change notification settings

d3adb5/smarky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smarky

A shell bookmarker similar to marker, but written purely in POSIX sh and using fzf for fuzzy matching.

SQLite is used for the index file. Something better probably exists.

Batteries (ZSH widget) included.

Installation

If you're on Arch and you're okay with using the AUR, the smarky-git package puts smarky in /usr/bin and the Zsh widgets in /usr/share/smarky/widgets. It's written and maintained by the one person who uses it: me, the author.

Alternatively, you can clone the repository somewhere and ensure smarky is in your $PATH:

git clone https://github.com/d3adb5/smarky
PATH="$PATH:$(pwd)/smarky"

smarky depends on sqlite3, and optionally on fzf and bat. fzf is necessary if you're using the widgets, and bat is optionally used for syntax highlighting in the preview windows.

Usage

You can get usage information by invoking smarky directly, but the main script itself is a very simple CRUD:

smarky is just a CRUD

This is by design. You can use it directly if you like, but you're encouraged to just pipe it around. The project's focus is on possible applications of it, two of which are the ZLE widgets present in this repository.

If you choose to use the widgets as they are in this repository, the binding to retrieve commands from smarky is Ctrl-J by default. You can get the binding and the widget in your shell configuration by adding the following to your .zshrc:

source path/to/the/smarky/repo/zsh/widgets.zsh

This is what it looks like in action:

smarky ZLE widget

Templated Bookmarks

On top of just storing your commands, smarky comes with another ZLE widget that allows you to jump to the next "template" field. Fields are simply parts of the command wrapped in double curly braces, like such:

socat {{ protocol }}-listen:{{ port }},fork,reuseaddr {{ protocol }}:{{ remote ip addr }}:{{ port }}

You can store something like this, or text that is even more complicated, place it in the command line from smarky by pressing Ctrl + J, then jump to the first field with Ctrl + G, pressing the same combination for the next field, and the next, and so on:

smarky templated commands

Index file (SQLite database)

When picking the database file to be used by the sqlite3 command, smarky has the following precedence:

  1. The SMARKY_INDEX environment variable, if set.
  2. The path $XDG_DATA_DIR/smarky-index.db, if XDG_DATA_DIR is set.
  3. The path $HOME/.local/share/smarky-index.db.

For example, if you wish to use the file /tmp/example.db for the smarky index, you can invoke smarky like this:

SMARKY_INDEX=/tmp/example.db smarky list

Text editor (and the EDITOR variable)

When creating or updating bookmarks with smarky, smarky will invoke the text editor $EDITOR for you to compose the command to store in its index. When EDITOR is not set, smarky will attempt to use nano.

About

A command bookmarks tool made with SQLite. Oversimplified version of pindexis/marker. Useful if you don't want to write script files left and right.

Topics

Resources

License

Stars

Watchers

Forks

Languages