Skip to content

qownnotes/qc

Repository files navigation

QOwnNotes command-line snippet manager

GitHub | Changelog | Releases

You can use the QOwnNotes command-line snippet manager to execute command snippets stored in notes in QOwnNotes from the command line.

qc

You can use notes with a special tag (commands by default) to store command snippets, which you can execute from the command-line snippet manager.

commands

For more information on how to add commands and configuration please see Command-line Snippet Manager.

The QOwnNotes command-line snippet manager is based on the wonderful pet CLI Snippet Manager.

Installation

Visit the latest release page and download the version you need.

If you have jq installed you can also use this snippet to download and install for example the latest Linux AMD64 binary to /usr/local/bin/qc:

curl https://api.github.com/repos/qownnotes/qc/releases/latest | \
jq '.assets[] | select(.browser_download_url | endswith("_linux_amd64.tar.gz")) | .browser_download_url' | \
xargs curl -Lo /tmp/qc.tar.gz && \
tar xfz /tmp/qc.tar.gz -C /tmp && \
rm /tmp/qc.tar.gz && \
sudo mv /tmp/qc /usr/local/bin/qc && \
/usr/local/bin/qc version

macOS / Homebrew

You can use homebrew on macOS to install qc.

brew install qownnotes/qc/qc

If you receive an error (Error: qownnotes/qc/qc 64 already installed) during brew upgrade, try the following command:

brew unlink qc && brew uninstall qc
rm -rf /usr/local/Cellar/qc/64
brew install qownnotes/qc/qc

Dependencies

fzf (fuzzy search) or peco (older, but more likely to be installed by default) need to be installed to search for commands on the command-line.

By default fzf is used for searching, but you can use peco by setting it with qc configure.

On some system you might need to set fzf --ansi when you use the qc --color flag. If you don't want the fuzzy search of fzf, you can use the fzf --exact flag.

Usage

Usage:
qc [command]

Available Commands:
completion  generate the autocompletion script for the specified shell
configure   Edit config file
exec        Run the selected commands
help        Help about any command
search      Search snippets
version     Print the version number

Flags:
--config string   config file (default is $HOME/.config/qc/config.toml)
--debug           debug mode
-h, --help        help for qc

Use "qc [command] --help" for more information about a command.

Configuration

Run qc configure.

[General]
  editor = "vim"            # your favorite text editor
  column = 40               # column size for list command
  selectcmd = "fzf"         # selector command for edit command (fzf or peco)
  sortby = ""               # specify how snippets get sorted (recency (default), -recency, description, -description, command, -command, output, -output)

[QOwnNotes]
  token = "SECRET"          # your QOwnNotes API token
  websocket_port = 22222    # websocket port in QOwnNotes

Shell completion

You can generate shell completion code for your shell with qc completion <shell>.

For example for the Fish shell you can use:

qc completion fish > ~/.config/fish/completions/qc.fish

Atuin integration

Executed commands can be stored in Atuin on execution when using the --atuin flag. They will then show up in the Atuin command history.

qc exec --atuin