#notes #file #command-line-tool #utility #cli

bin+lib dn-cli

A simple, minimal, and flexible command line utility for organising plaintext files

1 unstable release

new 0.1.3 Feb 13, 2025
0.1.2 Feb 13, 2025
0.1.1 Feb 12, 2025
0.1.0 Feb 11, 2025

#784 in Command line utilities

Download history 462/week @ 2025-02-11

462 downloads per month

GPL-3.0-or-later

88KB
1.5K SLoC

Rust 1K SLoC // 0.1% comments BASH 253 SLoC PowerShell 91 SLoC Elvish 82 SLoC Just 42 SLoC // 0.3% comments Nushell 39 SLoC // 0.2% comments

dn

dn is a CLI tool for creating and renaming plaintext notes with a predictable, timestamped naming format. It is inspired by the amazing Emacs package Denote created by Prot. dn creates files that can be easily queried using standard tools like find, sed, grep, awk, ripgrep, fzf, etc.

dn aims to reproduce the file naming functionality of Denote, while being entirely editor agnostic and scriptable in any language. It deviates in several ways from the behaviour of Denote, both due to the reduced scope (much of Denote's functionality is best suited for editor integrations) and different concerns (Emacs & Org already have a complete, quality solution to practically all of the goals dn addresses, i.e. Denote).

Installation

Cargo Install

Crates.io

If you have a Rust environment set up, you can install the binary from crates.io with the following command:

cargo install dn-cli

Build From Source

git clone https://github.com/mmibbetson/dn
cd dn
just install

Nix

Download From Nixpkgs

In configuration.nix, you can add the package as dn --- for example:

  users.users.yourUsername = {
    packages = with pkgs; [
      dn
    ]

Build Derivation

git clone https://github.com/mmibbetson/dn
cd dn
nix-build

You can then add the package in your configuration.nix with the following:

nixpkgs.config.packageOverrides = pkgs: {
  dn = pkgs.callPackage <route-to-dn-repository>/default.nix { };
}

From there you can install the package as dn at the system level or user level by including it in your packages.

Quick Start

# Create a new note
dn new -k personal_ideas -t "My First Note"

# Rename an existing note
dn rename oldfile.txt -k converted -e md # produces something like 20241006T145030--oldfile__converted.md

# Remove the title and change extension of an existing note
dn rename 20241001T121314--oldtitle__foo.md -e dj # produces something like 20241001T121314--oldtitle__foo.dj

# Add and remove keywords on an existing file
dn rename 20241001T121314--oldtitle__foo.dj -A bar_baz -R baz # produces 20241001T121314--oldtitle__foo_bar.dj

# Search $DN_DIRECTORY for a note with fzf and then open it in helix
rg $DN_DIRECTORY --file | fzf | xargs hx

Extras

Manpages and shell completions are available, they can be installed manually. The supported shells are:

  • bash
  • zsh
  • fish
  • powershell
  • nushell
  • elvish

Editor Support

dn is designed with the intention that it will be integrated into text editors via extensions. When Helix's plugin system is implemented, the intention is to provide an ergonomic set of extensions as specified in the integration docs. A VSCode extension is also being considered.

  • Helix
  • Visual Studio Code

Inspirations

Dependencies

Dependencies are relatively minimal. In time, this project will be feature-complete, and enter maintenance mode. A primary concern for dn is to minimise churn and maximise long-term stability. Eventually, all dependencies will be vendored and the program will be considered "finished", outside of necessary bug fixes and/or emergency patches.

Development

Dependencies

~9–19MB
~263K SLoC