Skip to content

Repository files navigation

Buildgo reportRenovate

cmdmark

A small fzf-driven command-bookmark tool: store shell command templates in YAML, pick a template with fzf and fill variables interactively.

Demo

Example

vars:
containers:
multi: truedelimiter: ""options_cmd: docker ps --format '{{.Names}}'service:
multi: falseoptions_cmd: systemctl list-units --type=service --no-legend | awk '{print $1};commands:
- title: Follow Systemd Service Logscmd: journalctl {{flags}} -u {{service}} -fvars:
flags:
required: falsemulti: trueoptions:
- --boot
- --since "1 hour ago"
- title: Stop Docker Containerscmd: docker stop {{containers}}
- title: Find Files by Extensionscmd: find {{path}} -type f -name '*.{{ext}}'vars:
ext:
multi: falseoptions:
- py
- go
- js

Install & Run

Go

go install github.com/tarow/cmdmark@latest
cmdmark search --config config.yml

Nix

nix run github:tarow/cmdmark -- search --config config.yml

Shell Integration

When accepting a selection, cmdmark will print the command. To put the selected command into the command line buffer, you can integrate cmdmark with your shell:

Bash

functioncmdmark-select() {
BUFFER=$(cmdmark search --config ~/.config/cmdmark/config.yml)
READLINE_LINE=$BUFFER
READLINE_POINT=${#BUFFER}
}
bind -x '"\C-b": cmdmark-select'

Zsh

functioncmdmark-select() {
BUFFER=$(cmdmark search --config ~/.config/cmdmark/config.yml)
CURSOR=$#BUFFER
zle redisplay
}
zle -N cmdmark-select
bindkey '^b' cmdmark-select

Fish

functioncmdmark-select
commandline -r -- $(cmdmark search --config ~/.config/cmdmark/config.yml)
end
bind\cb cmdmark-select

NixOS / Home Manager Module

To use the NixOS or Home Manager module, import the flake output nixosModules.cmdmark or homeModules.cmdmark. You can then use the module like this:

programs.cmdmark={enable=true;settings={commands=[{title="Find files by extension";cmd="find {{path}} -type f -name '*.{{ext}}'";vars.ext.options=["py""nix""js"" go"];}];};};

Screenshots

Command Selection

Variable Selection

About

fzf-powered command bookmarks

Resources

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages