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.
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.
You can get usage information by invoking smarky
directly, but the main
script itself is a very simple 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:
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:
When picking the database file to be used by the sqlite3
command, smarky has
the following precedence:
- The
SMARKY_INDEX
environment variable, if set. - The path
$XDG_DATA_DIR/smarky-index.db
, ifXDG_DATA_DIR
is set. - 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
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
.