diff --git a/CHANGELOG.md b/CHANGELOG.md index 84c7cb5..3a31393 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,13 @@ All notable changes to this project will be documented in this file. * You can customize the default behavior with the [`use-additional-text-edits` configuration key](docs/config-lsp.md). * [#163](https://github.com/mickael-menu/zk/issues/163) Use the `ZK_SHELL` environment variable to override the shell for `zk` only. * [#173](https://github.com/mickael-menu/zk/issues/173) Support for double star globbing in `note.ignore` config option. +* [#137](https://github.com/mickael-menu/zk/issues/137) Customize the `fzf` options used by `zk`'s interactive modes with the [`fzf-options`](docs/tool-fzf.md) config option (contributed by [@Nelyah](https://github.com/mickael-menu/zk/pull/154)). + +* [#168](https://github.com/mickael-menu/zk/discussions/168) Customize the `fzf` key binding to create new notes with the [`fzf-bind-new`](docs/tool-fzf.md) config option. + +### Changed + +* The default `fzf` key binding to create a new note with `zk edit --interactive` was changed to `Ctrl-E`, to avoid conflict with the default `Ctrl-N` binding. ### Fixed diff --git a/docs/assets/media/edit.svg b/docs/assets/media/edit.svg index 9e7f39e..84854d1 100644 --- a/docs/assets/media/edit.svg +++ b/docs/assets/media/edit.svg @@ -103,5 +103,5 @@ - $ $ zk edit $ zk edit --interactive $ zk edit --interactive --created-after "last week" > ╭──────────────────────────────────────╮ 4/4 (0) │ │ Ctrl-N: create a note with the quer.. │ │> A future-proof notebook `zk` is de.. │ │ Interesting subject I'm writing ab.. │ │ March 05, 2021 What did I do today.. │ │ Notebook housekeeping Tending to y.. │ │ │ │ ╰──────────────────────────────────────╯ 4/4 (0) # A future-proof notebook Ctrl-N: create a note with the quer.. > A future-proof notebook `zk` is de.. `zk` is designed to be future-proof Interesting subject I'm writing ab.. and rely on simple plain text format March 05, 2021 What did I do today.. s such as Markdown. Notebook housekeeping Tending to y.. The shape of your [notebook](noteboo k.md) is entirely up to you, making A future-proof notebook `zk` is de.. `zk` is designed to be future-proof > Interesting subject I'm writing ab.. and rely on simple plain text format 4/4 (0) # Interesting subject A future-proof notebook `zk` is de.. I'm writing about it > Interesting subject I'm writing ab.. March 05, 2021 What did I do today.. 4/4 (1) # Interesting subject >Interesting subject I'm writing ab.. > March 05, 2021 What did I do today.. 4/4 (1) # March 05, 2021 A future-proof notebook `zk` is de.. What did I do today? >Interesting subject I'm writing ab.. * > Notebook housekeeping Tending to y.. 4/4 (1) # Notebook housekeeping 1/26 A future-proof notebook `zk` is de.. Tending to your notes does not only >Interesting subject I'm writing ab.. mean writing. You need to keep your > Notebook housekeeping Tending to y.. ## Find related notes To surf your notebook with ease, mak e sure to link all related notes tog ether. You can list notes which coul d be good candidates for a new link with the `--related` [filtering opti on](note-filtering.md). ```sh $ zk list --related note.md ``` This returns notes which are not con nected to the given note, but with a t least one linked note in common. ## Find flimsy notes 4/4 (2) # Notebook housekeeping 1/26>>Notebook housekeeping Tending to y.. ## Find related notes 1 # Interesting subject 1 2 I'm writing about it 3 ~ docs/interesting-subject.md 1 # Interesting subject : :ne :nex :next :next 1 # Notebook housekeeping 2 Tending to your notes does not only mean writing. You need to keep your notebook in great shape to make good use of it. For many maintenance tasks, zk can help! 4 ## Find related notes 5 6 To surf your notebook with ease, make sure to link all related notes together. You can list notes which could be good candidates for a new link with the --related filtering option. 7 8 ```sh 9 $ zk list --related note.md 10 ``` 11 12 This returns notes which are not connected to the given note, but with at least one linked note in common. 13 14 ## Find flimsy notes 15 16 To find flimsy notes needing to be fleshed out, you can list the first few notes with the smallest word count from your notebook with the @@@ docs/notebook-housekeeping.md :next 1 # Notebook housekeeping :next Z $ - \ No newline at end of file + $ $ zk edit $ zk edit --interactive $ zk edit --interactive --created-after "last week" > ╭──────────────────────────────────────╮ 4/4 (0) │ │ Ctrl-E: create a note with the quer.. │ │> A future-proof notebook `zk` is de.. │ │ Interesting subject I'm writing ab.. │ │ March 05, 2021 What did I do today.. │ │ Notebook housekeeping Tending to y.. │ │ │ │ ╰──────────────────────────────────────╯ 4/4 (0) # A future-proof notebook Ctrl-E: create a note with the quer.. > A future-proof notebook `zk` is de.. `zk` is designed to be future-proof Interesting subject I'm writing ab.. and rely on simple plain text format March 05, 2021 What did I do today.. s such as Markdown. Notebook housekeeping Tending to y.. The shape of your [notebook](noteboo k.md) is entirely up to you, making A future-proof notebook `zk` is de.. `zk` is designed to be future-proof > Interesting subject I'm writing ab.. and rely on simple plain text format 4/4 (0) # Interesting subject A future-proof notebook `zk` is de.. I'm writing about it > Interesting subject I'm writing ab.. March 05, 2021 What did I do today.. 4/4 (1) # Interesting subject >Interesting subject I'm writing ab.. > March 05, 2021 What did I do today.. 4/4 (1) # March 05, 2021 A future-proof notebook `zk` is de.. What did I do today? >Interesting subject I'm writing ab.. * > Notebook housekeeping Tending to y.. 4/4 (1) # Notebook housekeeping 1/26 A future-proof notebook `zk` is de.. Tending to your notes does not only >Interesting subject I'm writing ab.. mean writing. You need to keep your > Notebook housekeeping Tending to y.. ## Find related notes To surf your notebook with ease, mak e sure to link all related notes tog ether. You can list notes which coul d be good candidates for a new link with the `--related` [filtering opti on](note-filtering.md). ```sh $ zk list --related note.md ``` This returns notes which are not con nected to the given note, but with a t least one linked note in common. ## Find flimsy notes 4/4 (2) # Notebook housekeeping 1/26>>Notebook housekeeping Tending to y.. ## Find related notes 1 # Interesting subject 1 2 I'm writing about it 3 ~ docs/interesting-subject.md 1 # Interesting subject : :ne :nex :next :next 1 # Notebook housekeeping 2 Tending to your notes does not only mean writing. You need to keep your notebook in great shape to make good use of it. For many maintenance tasks, zk can help! 4 ## Find related notes 5 6 To surf your notebook with ease, make sure to link all related notes together. You can list notes which could be good candidates for a new link with the --related filtering option. 7 8 ```sh 9 $ zk list --related note.md 10 ``` 11 12 This returns notes which are not connected to the given note, but with at least one linked note in common. 13 14 ## Find flimsy notes 15 16 To find flimsy notes needing to be fleshed out, you can list the first few notes with the smallest word count from your notebook with the @@@ docs/notebook-housekeeping.md :next 1 # Notebook housekeeping :next Z $ + diff --git a/docs/assets/media/list.svg b/docs/assets/media/list.svg index 66b6180..693eb6b 100644 --- a/docs/assets/media/list.svg +++ b/docs/assets/media/list.svg @@ -94,5 +94,5 @@ - $ $ zk list journal/ $ zk list journal/ March 05, 2021 journal/2021-03-05.md (46 minutes ago) ‣ What did I do today? *Found 1 note$ zk list -n2 $ zk list -n2 --match "create" $ zk list -n2 --match "create" Template context when creating notes template-creation.md (3 weeks ago) ‣ The following variables are available in the templates used when [creating new notes](note-creation.md) – both for the filename…Creating a new note note-creation.md (2 weeks ago) ‣ …From `fzf`, press `Ctrl-N` to create a new note using the current search query as title. ## Create a note…Found 2 notes$ zk list -n2 --match "create" $ zk list -n2 --match "create OR edit" $ zk list -n2 --match "create OR edit" Getting started with zk getting-started.md (2 weeks ago) ‣ …From `zk`'s interactive edit screen, press `Ctrl-N` to create a new note using the current search query as…Command aliases config-alias.md (2 weeks ago) ‣ …the trailing `$@`. ```toml recent = "zk edit --sort created- --created-after 'last two weeks' --interactive" ``` ### Edit the configuration file Here's a…$ zk list -n2 --match "create OR edit" $ zk list -n2 --match "create OR edit -alias" $ zk list -n2 --match "create OR edit -alias" ‣ …note or creating a new one in a single action. This option is available when running `zk edit --interactive`, which…$ - \ No newline at end of file + $ $ zk list journal/ $ zk list journal/ March 05, 2021 journal/2021-03-05.md (46 minutes ago) ‣ What did I do today? *Found 1 note$ zk list -n2 $ zk list -n2 --match "create" $ zk list -n2 --match "create" Template context when creating notes template-creation.md (3 weeks ago) ‣ The following variables are available in the templates used when [creating new notes](note-creation.md) – both for the filename…Creating a new note note-creation.md (2 weeks ago) ‣ …From `fzf`, press `Ctrl-E` to create a new note using the current search query as title. ## Create a note…Found 2 notes$ zk list -n2 --match "create" $ zk list -n2 --match "create OR edit" $ zk list -n2 --match "create OR edit" Getting started with zk getting-started.md (2 weeks ago) ‣ …From `zk`'s interactive edit screen, press `Ctrl-E` to create a new note using the current search query as…Command aliases config-alias.md (2 weeks ago) ‣ …the trailing `$@`. ```toml recent = "zk edit --sort created- --created-after 'last two weeks' --interactive" ``` ### Edit the configuration file Here's a…$ zk list -n2 --match "create OR edit" $ zk list -n2 --match "create OR edit -alias" $ zk list -n2 --match "create OR edit -alias" ‣ …note or creating a new one in a single action. This option is available when running `zk edit --interactive`, which…$ + diff --git a/docs/assets/media/new2.svg b/docs/assets/media/new2.svg index e17ae53..13667d3 100644 --- a/docs/assets/media/new2.svg +++ b/docs/assets/media/new2.svg @@ -98,5 +98,5 @@ - $ $ zk edit --interactive $ zk edit --interactive > ╭──────────────────────────────────────╮ 27/27 (0) │ │ Ctrl-N: create a note with the quer.. │ │> A future-proof notebook `zk` is de.. │ │ Automating frequent tasks `zk` was.. │ │ Call zk from other programs Callin.. │ │ Command aliases A command alias is.. │ │ Configuration file Each [notebook].. │ │ Creating a new note You can add a .. │ │ Extra user variables `zk` is opene.. │ │ Getting started with zk A short in.. │ │ Integration with fzf [`fzf`](https.. │ │ Interesting subject I'm writing ab.. │ │ Maintaining a daily journal Let's .. │ │ March 05, 2021 What did I do today.. │ │ Neuron [Neuron](https://neuron.zet.. │ │ Note ID Each note is uniquely iden.. │ │ Note configuration The `[note]` se.. │ │ Note group A *group* is a named [c.. │ │ Notebook A *notebook* is a directo.. │ │ Notebook housekeeping Tending to y.. │ │ Searching and filtering notes A fe.. │ │ Send notes for processing by other .. │ │ Setting your default editor `zk` i.. │ │ Setting your default pager When `z.. ╰──────────────────────────────────────╯ 27/27 (0) # A future-proof notebook Ctrl-N: create a note with the quer.. > A future-proof notebook `zk` is de.. `zk` is designed to be future-proof Automating frequent tasks `zk` was.. and rely on simple plain text format Call zk from other programs Callin.. s such as Markdown. Command aliases A command alias is.. Configuration file Each [notebook].. The shape of your [notebook](noteboo Creating a new note You can add a .. k.md) is entirely up to you, making Extra user variables `zk` is opene.. Getting started with zk A short in.. Integration with fzf [`fzf`](https.. Interesting subject I'm writing ab.. Maintaining a daily journal Let's .. March 05, 2021 What did I do today.. Neuron [Neuron](https://neuron.zet.. Note ID Each note is uniquely iden.. Note configuration The `[note]` se.. Note group A *group* is a named [c.. Notebook A *notebook* is a directo.. Notebook housekeeping Tending to y.. Searching and filtering notes A fe.. Send notes for processing by other .. Setting your default editor `zk` i.. > A ╭──────────────────────────────────────╮ 22/27 (0) # A future-proof notebook Notebook A *notebook* is a directo.. s such as Markdown. Command aliases A command alias is.. The shape of your [notebook](noteboo Getting started with zk A short in.. k.md) is entirely up to you, making Creating a new note You can add a .. Template syntax `zk` uses the [Han.. Template context when formatting a .. Template context when creating note.. Configuration file Each [notebook].. Setting your default pager When `z.. zk – a plain text note-taking assis.. Maintaining a daily journal Let's .. ╰──────────────────────────────────────╯> A ╭──────────────────────────────────────╮> A ne ╭──────────────────────────────────────╮ 21/27 (0) # A future-proof notebook > Notebook A *notebook* is a directo.. `zk` is designed to be future-proof Creating a new note You can add a .. and rely on simple plain text format Note group A *group* is a named [c.. s such as Markdown. Getting started with zk A short in.. The shape of your [notebook](noteboo Searching and filtering notes A fe.. k.md) is entirely up to you, making A future-proof notebook `zk` is de.. Automating frequent tasks `zk` was.. ╰──────────────────────────────────────╯> A new ╭──────────────────────────────────────╮ 12/27 (0) # Notebook > Notebook A *notebook* is a directo.. A *notebook* is a directory containi Creating a new note You can add a .. ng a collection of notes managed by Command aliases A command alias is.. To create a new notebook, simply run Getting started with zk A short in.. `zk init [<directory>]`. Template context when creating note.. Most `zk` commands are operating "Gi Template syntax `zk` uses the [Han.. t-style" on the notebook containing Notebook housekeeping Tending to y.. the current working directory (or on Note configuration The `[note]` se.. e of its parents). Maintaining a daily journal Let's .. ## Anatomy of a notebook Similarly to Git, a notebook is iden tified by the presence of a `.zk` di rectory at its root. This directory contains the only `zk`-specific file s in your notebook: * `.zk/config.toml` is the user [con figuration file](config.md) > A new ╭──────────────────────────────────────╮> A new n ╭──────────────────────────────────────╮> Note configuration The `[note]` se.. A *notebook* is a directory containi Note group A *group* is a named [c.. ng a collection of notes managed by Notebook housekeeping Tending to y.. To create a new notebook, simply run Creating a new note You can add a .. `zk init [<directory>]`. Getting started with zk A short in.. Most `zk` commands are operating "Gi Configuration file Each [notebook].. t-style" on the notebook containing Template context when creating note.. the current working directory (or on Extra user variables `zk` is opene.. e of its parents). > A new no ╭──────────────────────────────────────╮ 12/27 (0) # Note configuration 1/55> Note configuration The `[note]` se.. The `[note]` section from the [confi Note group A *group* is a named [c.. guration file](config.md) is used to Notebook A *notebook* is a directo.. set the [note creation rules](note- Notebook housekeeping Tending to y.. creation.md). The following properti Creating a new note You can add a .. es are customizable: Getting started with zk A short in.. * `language` (string) Configuration file Each [notebook].. * Two-letters code of the langua Template context when creating note.. ge used when writing notes, e.g. `en Extra user variables `zk` is opene.. * This is used to generate slugs Template syntax `zk` uses the [Han.. or with date formats. For now, only Maintaining a daily journal Let's .. English is fully supported. * `default-title` (string) * The default title used for new notes when no `--title` option is p rovided. * `filename` (string) * [Template](template.md) used t o generate the note filename, withou t its file extension. * `extension` (string) > A new not ╭──────────────────────────────────────╮> A new note ╭──────────────────────────────────────╮> A new note ╭──────────────────────────────────────╮ 1 # A new note 1 2 ~ docs/a-new-note.md Z - \ No newline at end of file + $ $ zk edit --interactive $ zk edit --interactive > ╭──────────────────────────────────────╮ 27/27 (0) │ │ Ctrl-E: create a note with the quer.. │ │> A future-proof notebook `zk` is de.. │ │ Automating frequent tasks `zk` was.. │ │ Call zk from other programs Callin.. │ │ Command aliases A command alias is.. │ │ Configuration file Each [notebook].. │ │ Creating a new note You can add a .. │ │ Extra user variables `zk` is opene.. │ │ Getting started with zk A short in.. │ │ Integration with fzf [`fzf`](https.. │ │ Interesting subject I'm writing ab.. │ │ Maintaining a daily journal Let's .. │ │ March 05, 2021 What did I do today.. │ │ Neuron [Neuron](https://neuron.zet.. │ │ Note ID Each note is uniquely iden.. │ │ Note configuration The `[note]` se.. │ │ Note group A *group* is a named [c.. │ │ Notebook A *notebook* is a directo.. │ │ Notebook housekeeping Tending to y.. │ │ Searching and filtering notes A fe.. │ │ Send notes for processing by other .. │ │ Setting your default editor `zk` i.. │ │ Setting your default pager When `z.. ╰──────────────────────────────────────╯ 27/27 (0) # A future-proof notebook Ctrl-E: create a note with the quer.. > A future-proof notebook `zk` is de.. `zk` is designed to be future-proof Automating frequent tasks `zk` was.. and rely on simple plain text format Call zk from other programs Callin.. s such as Markdown. Command aliases A command alias is.. Configuration file Each [notebook].. The shape of your [notebook](noteboo Creating a new note You can add a .. k.md) is entirely up to you, making Extra user variables `zk` is opene.. Getting started with zk A short in.. Integration with fzf [`fzf`](https.. Interesting subject I'm writing ab.. Maintaining a daily journal Let's .. March 05, 2021 What did I do today.. Neuron [Neuron](https://neuron.zet.. Note ID Each note is uniquely iden.. Note configuration The `[note]` se.. Note group A *group* is a named [c.. Notebook A *notebook* is a directo.. Notebook housekeeping Tending to y.. Searching and filtering notes A fe.. Send notes for processing by other .. Setting your default editor `zk` i.. > A ╭──────────────────────────────────────╮ 22/27 (0) # A future-proof notebook Notebook A *notebook* is a directo.. s such as Markdown. Command aliases A command alias is.. The shape of your [notebook](noteboo Getting started with zk A short in.. k.md) is entirely up to you, making Creating a new note You can add a .. Template syntax `zk` uses the [Han.. Template context when formatting a .. Template context when creating note.. Configuration file Each [notebook].. Setting your default pager When `z.. zk – a plain text note-taking assis.. Maintaining a daily journal Let's .. ╰──────────────────────────────────────╯> A ╭──────────────────────────────────────╮> A ne ╭──────────────────────────────────────╮ 21/27 (0) # A future-proof notebook > Notebook A *notebook* is a directo.. `zk` is designed to be future-proof Creating a new note You can add a .. and rely on simple plain text format Note group A *group* is a named [c.. s such as Markdown. Getting started with zk A short in.. The shape of your [notebook](noteboo Searching and filtering notes A fe.. k.md) is entirely up to you, making A future-proof notebook `zk` is de.. Automating frequent tasks `zk` was.. ╰──────────────────────────────────────╯> A new ╭──────────────────────────────────────╮ 12/27 (0) # Notebook > Notebook A *notebook* is a directo.. A *notebook* is a directory containi Creating a new note You can add a .. ng a collection of notes managed by Command aliases A command alias is.. To create a new notebook, simply run Getting started with zk A short in.. `zk init [<directory>]`. Template context when creating note.. Most `zk` commands are operating "Gi Template syntax `zk` uses the [Han.. t-style" on the notebook containing Notebook housekeeping Tending to y.. the current working directory (or on Note configuration The `[note]` se.. e of its parents). Maintaining a daily journal Let's .. ## Anatomy of a notebook Similarly to Git, a notebook is iden tified by the presence of a `.zk` di rectory at its root. This directory contains the only `zk`-specific file s in your notebook: * `.zk/config.toml` is the user [con figuration file](config.md) > A new ╭──────────────────────────────────────╮> A new n ╭──────────────────────────────────────╮> Note configuration The `[note]` se.. A *notebook* is a directory containi Note group A *group* is a named [c.. ng a collection of notes managed by Notebook housekeeping Tending to y.. To create a new notebook, simply run Creating a new note You can add a .. `zk init [<directory>]`. Getting started with zk A short in.. Most `zk` commands are operating "Gi Configuration file Each [notebook].. t-style" on the notebook containing Template context when creating note.. the current working directory (or on Extra user variables `zk` is opene.. e of its parents). > A new no ╭──────────────────────────────────────╮ 12/27 (0) # Note configuration 1/55> Note configuration The `[note]` se.. The `[note]` section from the [confi Note group A *group* is a named [c.. guration file](config.md) is used to Notebook A *notebook* is a directo.. set the [note creation rules](note- Notebook housekeeping Tending to y.. creation.md). The following properti Creating a new note You can add a .. es are customizable: Getting started with zk A short in.. * `language` (string) Configuration file Each [notebook].. * Two-letters code of the langua Template context when creating note.. ge used when writing notes, e.g. `en Extra user variables `zk` is opene.. * This is used to generate slugs Template syntax `zk` uses the [Han.. or with date formats. For now, only Maintaining a daily journal Let's .. English is fully supported. * `default-title` (string) * The default title used for new notes when no `--title` option is p rovided. * `filename` (string) * [Template](template.md) used t o generate the note filename, withou t its file extension. * `extension` (string) > A new not ╭──────────────────────────────────────╮> A new note ╭──────────────────────────────────────╮> A new note ╭──────────────────────────────────────╮ 1 # A new note 1 2 ~ docs/a-new-note.md Z + diff --git a/docs/assets/media/screencast.svg b/docs/assets/media/screencast.svg index 5ce376e..a89bbb8 100644 --- a/docs/assets/media/screencast.svg +++ b/docs/assets/media/screencast.svg @@ -145,5 +145,5 @@ - $ $ echo "I'm writing about it" | zk new --title "Interesting subject" 1 # Interesting subject 1 2 I'm writing about it 3 ~ docs/interesting-subject.md cwd: /Users/mickael/dvpts/mickael/zk 1 # Interesting subject cwd: /Users/mickael/dvpts/mickael/zk Z $ zk list --match "write subject" $ zk list --match "write subject" Interesting subject interesting-subject.md (just now) ‣ I'm writing about itGetting started with zk getting-started.md (2 weeks ago) ‣ …Pick a subject, [create a new note](note-creation.md) and write on! ```sh $ zk new --title "An interesting concept…Found 2 notes$ zk list --match "write OR subject" --limit 5 Extra user variables config-extra.md (2 weeks ago) ‣ …note-creation.md), for example: * expanding custom metadata (author, subject, etc.) * modifying a [template](template.md)'s output dynamically depending…Creating a new note note-creation.md (2 weeks ago) ‣ …sure whether a note already exists for a particular subject, the "search or create" mode might be more appropriate than…Maintaining a daily journal daily-journal.md (2 weeks ago): Found 5 notes$ zk new journal 1 # March 04, 2021 2 What did I do today? 3 * docs/journal/2021-03-04.md Z $ zk edit --interactive --exclude journal > ╭──────────────────────────────────────╮ 26/26 (0) │ │ Ctrl-N: create a note with the quer.. │ │> A future-proof notebook `zk` is de.. │ │ Automating frequent tasks `zk` was.. │ │ Call zk from other programs Callin.. │ │ Command aliases A command alias is.. │ │ Configuration file Each [notebook].. │ │ Creating a new note You can add a .. │ │ Extra user variables `zk` is opene.. │ │ Getting started with zk A short in.. │ │ Integration with fzf [`fzf`](https.. │ │ Interesting subject I'm writing ab.. │ │ Maintaining a daily journal Let's .. │ │ Neuron [Neuron](https://neuron.zet.. │ │ Note ID Each note is uniquely iden.. │ │ Note configuration The `[note]` se.. │ │ Note group A *group* is a named [c.. │ │ Notebook A *notebook* is a directo.. │ │ Notebook housekeeping Tending to y.. │ │ Searching and filtering notes A fe.. │ │ Send notes for processing by other .. │ │ Setting your default editor `zk` i.. │ │ Setting your default pager When `z.. │ │ Styling `zk` supports a `{{style}}.. ╰──────────────────────────────────────╯ 26/26 (0) # A future-proof notebook Ctrl-N: create a note with the quer.. > A future-proof notebook `zk` is de.. `zk` is designed to be future-proof Automating frequent tasks `zk` was.. and rely on simple plain text format Call zk from other programs Callin.. s such as Markdown. Command aliases A command alias is.. Configuration file Each [notebook].. The shape of your [notebook](noteboo Creating a new note You can add a .. k.md) is entirely up to you, making Extra user variables `zk` is opene.. Getting started with zk A short in.. Integration with fzf [`fzf`](https.. Interesting subject I'm writing ab.. Maintaining a daily journal Let's .. Neuron [Neuron](https://neuron.zet.. Note ID Each note is uniquely iden.. Note configuration The `[note]` se.. Note group A *group* is a named [c.. Notebook A *notebook* is a directo.. Notebook housekeeping Tending to y.. Searching and filtering notes A fe.. Send notes for processing by other .. Setting your default editor `zk` i.. Setting your default pager When `z.. > f ╭──────────────────────────────────────╮ 25/26 (0) # A future-proof notebook Call zk from other programs Callin.. and rely on simple plain text format Automating frequent tasks `zk` was.. s such as Markdown. Searching and filtering notes A fe.. k.md) is entirely up to you, making Template context when formatting a .. Template context when creating note.. zk – a plain text note-taking assis.. Styling `zk` supports a `{{style}}.. Template syntax `zk` uses the [Han.. Creating a new note You can add a .. ╰──────────────────────────────────────╯> fz ╭──────────────────────────────────────╮ 6/26 (0) # A future-proof notebook > Integration with fzf [`fzf`](https.. `zk` is designed to be future-proof Configuration file Each [notebook].. and rely on simple plain text format Notebook housekeeping Tending to y.. s such as Markdown. Creating a new note You can add a .. Command aliases A command alias is.. The shape of your [notebook](noteboo ╰──────────────────────────────────────╯ 6/26 (0) # Integration with `fzf` 1/25> Integration with fzf [`fzf`](https.. [`fzf`](https://github.com/junegunn/ Configuration file Each [notebook].. fzf) is an awesome and versatile fuz Notebook housekeeping Tending to y.. zy finder powering `zk`'s [interacti Creating a new note You can add a .. ve filtering mode](note-filtering.md Searching and filtering notes A fe.. Besides the standard [`fzf` configur ation options](https://github.com/ju negunn/fzf) documented on its websit e, `zk` offers additional options yo u can set in the `[tool]` [configura tion section](config.md). If you wish to customize more of `fz f` behavior, [please post a feature request](https://github.com/mickael- menu/zk/issues). ## Preview command You can customize the command used t o preview a note with `fzf-preview` 1 # Integration with fzf 2 `fzf` is an awesome and versatile fuzzy finder powering zk's interactive filtering mode . 4 Besides the standard `fzf` configuration options documented on its website, zk offers additional options you can set in the [tool] configuration section. 5 6 If you wish to customize more of fzf behavior, please post a feature request. 7 8 ## Preview command 9 10 You can customize the command used to preview a note with fzf-preview. The special placeholder {-1} will be expanded to the note file path. 11 12 By default, zk uses cat for preview, which is a bit boring. A much better option would be to use `bat` which supports syntax highlighting. 13 14 ```toml docs/tool-fzf.md $ zk edit --interactive --created-after "one week ago" 4/4 (0) │ │ March 04, 2021 What did I do today.. │ │ │ │ 4/4 (0) # A future-proof notebook Interesting subject I'm writing ab.. and rely on simple plain text format March 04, 2021 What did I do today.. s such as Markdown. The shape of your [notebook](noteboo k.md) is entirely up to you, making > N ╭──────────────────────────────────────╮ 1/4 (0) # A future-proof notebook > Notebook housekeeping Tending to y.. `zk` is designed to be future-proof and rely on simple plain text format s such as Markdown. 1/4 (0) # Notebook housekeeping 1/26> Notebook housekeeping Tending to y.. Tending to your notes does not only mean writing. You need to keep your ## Find related notes To surf your notebook with ease, mak e sure to link all related notes tog ether. You can list notes which coul d be good candidates for a new link with the `--related` [filtering opti on](note-filtering.md). ```sh $ zk list --related note.md ``` This returns notes which are not con nected to the given note, but with a t least one linked note in common. ## Find flimsy notes > Ne ╭──────────────────────────────────────╮ 0/4 (0) > New ╭──────────────────────────────────────╮> New n ╭──────────────────────────────────────╮> New no ╭──────────────────────────────────────╮> New not ╭──────────────────────────────────────╮> New note ╭──────────────────────────────────────╮ 1 # New note 2 docs/new-note.md > New note% $ zk list --link-to note-id.md $ zk list --link-to note-id.md Neuron neuron.md (2 weeks ago) ‣ using the [same settings as Neuron](https://neuron.zettel.page/id.html) to generate the [note IDs](note-id.md) in the [note configuration](config-note.md) Note configuration config-note.md (2 weeks ago) ‣ Characters set used to [generate random IDs](note-id.md). ‣ Just a [random ID](note-id.md), simple and elegant. Searching and filtering notes note-filtering.md (2 weeks ago) ‣ It works fine with only a path prefix as well. This is useful when you have a [note ID](note-id.md) prefix, but not the full file path. Found 3 notes $ zk list --link-to note-id.md --format oneline $ zk list --link-to note-id.md --format oneline Note configuration config-note.md (2 weeks ago)Searching and filtering notes note-filtering.md (2 weeks ago)Found 3 notes$ zk list --link-to note-id.md --format oneline --recursive $ zk list --link-to note-id.md --format oneline --recursive --max-distance 2 $ zk list --link-to note-id.md --format oneline --recursive --max-distance 2 Command aliases config-alias.md (2 weeks ago)Configuration file config.md (3 weeks ago)Integration with fzf tool-fzf.md (2 weeks ago)Neuron neuron.md (2 weeks ago)Note group config-group.md (2 weeks ago)Notebook notebook.md (2 weeks ago)Notebook housekeeping notebook-housekeeping.md (5 days ago)Send notes for processing by other programs external-processing.md (2 weeks ago)Template syntax template.md (2 weeks ago)zk – a plain text note-taking assistant README.md (3 weeks ago)Found 13 notes$ zk list --format "{{word-count}}\t{{title}}" --sort word-count --limit 10 $ zk list --format "{{word-count}}\t{{title}}" --sort word-count --limit 10 3 New note7 Interesting subject10 March 04, 202154 A future-proof notebook69 Setting your default editor88 Automating frequent tasks93 Setting your default pager101 Call zk from other programs106 zk – a plain text note-taking assistant117 NotebookFound 10 notes$ vim .zk/config.toml 1 [note] 1 filename = "{{slug title}}" 2 template = "default.md" 4 [group.journal.note] 5 filename = "{{date now}}" 6 template = "journal.md" 8 [tool] 9 editor = "nvim" 10 fzf-preview = "bat -p --theme Nord --color always {-1}" 12 [alias] docs/.zk/config.toml 12 [note] 11 filename = "{{slug title}}" 10 template = "default.md" 8 [group.journal.note] 7 filename = "{{date now}}" 4 [tool] 3 editor = "nvim" 2 fzf-preview = "bat -p --theme Nord --color always {-1}" 13 [alias] 13 [note] 12 filename = "{{slug title}}" 11 template = "default.md" 10 9 [group.journal.note] 8 filename = "{{date now}}" 7 template = "journal.md" 6 5 [tool] 4 editor = "nvim" 3 fzf-preview = "bat -p --theme Nord --color always {-1}" 1 [alias] 14 -- INSERT -- 14 wc = "zk list --quiet --format '{{word-count}}\t{{title}}' --sort word- count --limit 10 $@" count --limit 10 $@" count --limit 10 $@" "docs/.zk/config.toml" $ zk wc $ zk wc $ zk wc --exclude journal --limit 5 $ zk wc --exclude journal --limit 5 $ + $ $ echo "I'm writing about it" | zk new --title "Interesting subject" 1 # Interesting subject 1 2 I'm writing about it 3 ~ docs/interesting-subject.md cwd: /Users/mickael/dvpts/mickael/zk 1 # Interesting subject cwd: /Users/mickael/dvpts/mickael/zk Z $ zk list --match "write subject" $ zk list --match "write subject" Interesting subject interesting-subject.md (just now) ‣ I'm writing about itGetting started with zk getting-started.md (2 weeks ago) ‣ …Pick a subject, [create a new note](note-creation.md) and write on! ```sh $ zk new --title "An interesting concept…Found 2 notes$ zk list --match "write OR subject" --limit 5 Extra user variables config-extra.md (2 weeks ago) ‣ …note-creation.md), for example: * expanding custom metadata (author, subject, etc.) * modifying a [template](template.md)'s output dynamically depending…Creating a new note note-creation.md (2 weeks ago) ‣ …sure whether a note already exists for a particular subject, the "search or create" mode might be more appropriate than…Maintaining a daily journal daily-journal.md (2 weeks ago): Found 5 notes$ zk new journal 1 # March 04, 2021 2 What did I do today? 3 * docs/journal/2021-03-04.md Z $ zk edit --interactive --exclude journal > ╭──────────────────────────────────────╮ 26/26 (0) │ │ Ctrl-E: create a note with the quer.. │ │> A future-proof notebook `zk` is de.. │ │ Automating frequent tasks `zk` was.. │ │ Call zk from other programs Callin.. │ │ Command aliases A command alias is.. │ │ Configuration file Each [notebook].. │ │ Creating a new note You can add a .. │ │ Extra user variables `zk` is opene.. │ │ Getting started with zk A short in.. │ │ Integration with fzf [`fzf`](https.. │ │ Interesting subject I'm writing ab.. │ │ Maintaining a daily journal Let's .. │ │ Neuron [Neuron](https://neuron.zet.. │ │ Note ID Each note is uniquely iden.. │ │ Note configuration The `[note]` se.. │ │ Note group A *group* is a named [c.. │ │ Notebook A *notebook* is a directo.. │ │ Notebook housekeeping Tending to y.. │ │ Searching and filtering notes A fe.. │ │ Send notes for processing by other .. │ │ Setting your default editor `zk` i.. │ │ Setting your default pager When `z.. │ │ Styling `zk` supports a `{{style}}.. ╰──────────────────────────────────────╯ 26/26 (0) # A future-proof notebook Ctrl-E: create a note with the quer.. > A future-proof notebook `zk` is de.. `zk` is designed to be future-proof Automating frequent tasks `zk` was.. and rely on simple plain text format Call zk from other programs Callin.. s such as Markdown. Command aliases A command alias is.. Configuration file Each [notebook].. The shape of your [notebook](noteboo Creating a new note You can add a .. k.md) is entirely up to you, making Extra user variables `zk` is opene.. Getting started with zk A short in.. Integration with fzf [`fzf`](https.. Interesting subject I'm writing ab.. Maintaining a daily journal Let's .. Neuron [Neuron](https://neuron.zet.. Note ID Each note is uniquely iden.. Note configuration The `[note]` se.. Note group A *group* is a named [c.. Notebook A *notebook* is a directo.. Notebook housekeeping Tending to y.. Searching and filtering notes A fe.. Send notes for processing by other .. Setting your default editor `zk` i.. Setting your default pager When `z.. > f ╭──────────────────────────────────────╮ 25/26 (0) # A future-proof notebook Call zk from other programs Callin.. and rely on simple plain text format Automating frequent tasks `zk` was.. s such as Markdown. Searching and filtering notes A fe.. k.md) is entirely up to you, making Template context when formatting a .. Template context when creating note.. zk – a plain text note-taking assis.. Styling `zk` supports a `{{style}}.. Template syntax `zk` uses the [Han.. Creating a new note You can add a .. ╰──────────────────────────────────────╯> fz ╭──────────────────────────────────────╮ 6/26 (0) # A future-proof notebook > Integration with fzf [`fzf`](https.. `zk` is designed to be future-proof Configuration file Each [notebook].. and rely on simple plain text format Notebook housekeeping Tending to y.. s such as Markdown. Creating a new note You can add a .. Command aliases A command alias is.. The shape of your [notebook](noteboo ╰──────────────────────────────────────╯ 6/26 (0) # Integration with `fzf` 1/25> Integration with fzf [`fzf`](https.. [`fzf`](https://github.com/junegunn/ Configuration file Each [notebook].. fzf) is an awesome and versatile fuz Notebook housekeeping Tending to y.. zy finder powering `zk`'s [interacti Creating a new note You can add a .. ve filtering mode](note-filtering.md Searching and filtering notes A fe.. Besides the standard [`fzf` configur ation options](https://github.com/ju negunn/fzf) documented on its websit e, `zk` offers additional options yo u can set in the `[tool]` [configura tion section](config.md). If you wish to customize more of `fz f` behavior, [please post a feature request](https://github.com/mickael- menu/zk/issues). ## Preview command You can customize the command used t o preview a note with `fzf-preview` 1 # Integration with fzf 2 `fzf` is an awesome and versatile fuzzy finder powering zk's interactive filtering mode . 4 Besides the standard `fzf` configuration options documented on its website, zk offers additional options you can set in the [tool] configuration section. 5 6 If you wish to customize more of fzf behavior, please post a feature request. 7 8 ## Preview command 9 10 You can customize the command used to preview a note with fzf-preview. The special placeholder {-1} will be expanded to the note file path. 11 12 By default, zk uses cat for preview, which is a bit boring. A much better option would be to use `bat` which supports syntax highlighting. 13 14 ```toml docs/tool-fzf.md $ zk edit --interactive --created-after "one week ago" 4/4 (0) │ │ March 04, 2021 What did I do today.. │ │ │ │ 4/4 (0) # A future-proof notebook Interesting subject I'm writing ab.. and rely on simple plain text format March 04, 2021 What did I do today.. s such as Markdown. The shape of your [notebook](noteboo k.md) is entirely up to you, making > N ╭──────────────────────────────────────╮ 1/4 (0) # A future-proof notebook > Notebook housekeeping Tending to y.. `zk` is designed to be future-proof and rely on simple plain text format s such as Markdown. 1/4 (0) # Notebook housekeeping 1/26> Notebook housekeeping Tending to y.. Tending to your notes does not only mean writing. You need to keep your ## Find related notes To surf your notebook with ease, mak e sure to link all related notes tog ether. You can list notes which coul d be good candidates for a new link with the `--related` [filtering opti on](note-filtering.md). ```sh $ zk list --related note.md ``` This returns notes which are not con nected to the given note, but with a t least one linked note in common. ## Find flimsy notes > Ne ╭──────────────────────────────────────╮ 0/4 (0) > New ╭──────────────────────────────────────╮> New n ╭──────────────────────────────────────╮> New no ╭──────────────────────────────────────╮> New not ╭──────────────────────────────────────╮> New note ╭──────────────────────────────────────╮ 1 # New note 2 docs/new-note.md > New note% $ zk list --link-to note-id.md $ zk list --link-to note-id.md Neuron neuron.md (2 weeks ago) ‣ using the [same settings as Neuron](https://neuron.zettel.page/id.html) to generate the [note IDs](note-id.md) in the [note configuration](config-note.md) Note configuration config-note.md (2 weeks ago) ‣ Characters set used to [generate random IDs](note-id.md). ‣ Just a [random ID](note-id.md), simple and elegant. Searching and filtering notes note-filtering.md (2 weeks ago) ‣ It works fine with only a path prefix as well. This is useful when you have a [note ID](note-id.md) prefix, but not the full file path. Found 3 notes $ zk list --link-to note-id.md --format oneline $ zk list --link-to note-id.md --format oneline Note configuration config-note.md (2 weeks ago)Searching and filtering notes note-filtering.md (2 weeks ago)Found 3 notes$ zk list --link-to note-id.md --format oneline --recursive $ zk list --link-to note-id.md --format oneline --recursive --max-distance 2 $ zk list --link-to note-id.md --format oneline --recursive --max-distance 2 Command aliases config-alias.md (2 weeks ago)Configuration file config.md (3 weeks ago)Integration with fzf tool-fzf.md (2 weeks ago)Neuron neuron.md (2 weeks ago)Note group config-group.md (2 weeks ago)Notebook notebook.md (2 weeks ago)Notebook housekeeping notebook-housekeeping.md (5 days ago)Send notes for processing by other programs external-processing.md (2 weeks ago)Template syntax template.md (2 weeks ago)zk – a plain text note-taking assistant README.md (3 weeks ago)Found 13 notes$ zk list --format "{{word-count}}\t{{title}}" --sort word-count --limit 10 $ zk list --format "{{word-count}}\t{{title}}" --sort word-count --limit 10 3 New note7 Interesting subject10 March 04, 202154 A future-proof notebook69 Setting your default editor88 Automating frequent tasks93 Setting your default pager101 Call zk from other programs106 zk – a plain text note-taking assistant117 NotebookFound 10 notes$ vim .zk/config.toml 1 [note] 1 filename = "{{slug title}}" 2 template = "default.md" 4 [group.journal.note] 5 filename = "{{date now}}" 6 template = "journal.md" 8 [tool] 9 editor = "nvim" 10 fzf-preview = "bat -p --theme Nord --color always {-1}" 12 [alias] docs/.zk/config.toml 12 [note] 11 filename = "{{slug title}}" 10 template = "default.md" 8 [group.journal.note] 7 filename = "{{date now}}" 4 [tool] 3 editor = "nvim" 2 fzf-preview = "bat -p --theme Nord --color always {-1}" 13 [alias] 13 [note] 12 filename = "{{slug title}}" 11 template = "default.md" 10 9 [group.journal.note] 8 filename = "{{date now}}" 7 template = "journal.md" 6 5 [tool] 4 editor = "nvim" 3 fzf-preview = "bat -p --theme Nord --color always {-1}" 1 [alias] 14 -- INSERT -- 14 wc = "zk list --quiet --format '{{word-count}}\t{{title}}' --sort word- count --limit 10 $@" count --limit 10 $@" count --limit 10 $@" "docs/.zk/config.toml" $ zk wc $ zk wc $ zk wc --exclude journal --limit 5 $ zk wc --exclude journal --limit 5 $ diff --git a/docs/getting-started.md b/docs/getting-started.md index 73d387c..e7899dd 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -27,7 +27,7 @@ You can customize your experience using [custom templates](template.md) to gener If you are not sure whether a note already exists for a particular subject, the "search or create" mode might be more appropriate than `zk new`. It is inspired by [Notational Velocity](https://notational.net/) and enables searching for an existing note or creating a new one in a single action. -From `zk`'s interactive edit screen, press `Ctrl-N` to create a new note using the current search query as title. +From `zk`'s interactive edit screen, press `Ctrl-E` to create a new note using the current search query as title.
Create a note
diff --git a/docs/note-creation.md b/docs/note-creation.md index a3f38d0..4e8d9e0 100644 --- a/docs/note-creation.md +++ b/docs/note-creation.md @@ -10,7 +10,7 @@ By default, `zk new` will start [your editor](tool-editor.md) after creating the If you are not sure whether a note already exists for a particular subject, the "search or create" mode might be more appropriate than `zk new`. It is inspired by [Notational Velocity](https://notational.net/) and enables searching for an existing note or creating a new one in a single action. -This option is available when running `zk edit --interactive`, which spawns [`fzf`](tool-fzf.md) to filter selected notes. From `fzf`, press `Ctrl-N` to create a new note using the current search query as title. +This option is available when running `zk edit --interactive`, which spawns [`fzf`](tool-fzf.md) to filter selected notes. From `fzf`, press `Ctrl-E` to create a new note using the current search query as title. ## Create a note with initial content diff --git a/docs/tool-fzf.md b/docs/tool-fzf.md index 32bb9c1..9bbd888 100644 --- a/docs/tool-fzf.md +++ b/docs/tool-fzf.md @@ -60,3 +60,33 @@ The following variables are available in the line template. | `checksum` | string | SHA-256 checksum of the note file | 1. YAML keys are normalized to lower case. + + +## `fzf` options + +You can override the default `fzf` options used by `zk` with `fzf-options`. Look at `man fzf` for the list of available options. + +```toml +[tool] +fzf-options = "--height 40% --border" +``` + +Note that this overrides all the default options used by `zk`, you might want to keep some of them: + +* `--tiebreak begin` Prefer matches located at the beginning of the line +* `--exact` Look for exact matches instead of fuzzy ones by default +* `--tabstop 4` Length of tab characters +* `--height 100%` Height of the list relative to the terminal window +* `--layout reverse` Display the input field at the top +* `--no-hscroll` Make sure the path and titles are always visible +* `--color hl:-1,hl+:-1` Don't highlight search terms +* `--preview-window wrap` Enable line wrapping in the preview window + +## Key bindings + +When running `fzf` with `zk edit --interactive`, you can [create a new note with the `Ctrl-E` key binding](note-creation.md#search-or-create-with-a-single-command). This binding is customizable with `fzf-bind-new`. You can also disable it by setting it to an empty string (`""`). + +```toml +[tool] +fzf-bind-new = "Ctrl-C" +``` diff --git a/internal/adapter/fzf/fzf.go b/internal/adapter/fzf/fzf.go index 9e5658b..f65ff17 100644 --- a/internal/adapter/fzf/fzf.go +++ b/internal/adapter/fzf/fzf.go @@ -8,6 +8,7 @@ import ( "strings" "sync" + "github.com/kballard/go-shellquote" "github.com/mickael-menu/zk/internal/util/errors" "github.com/mickael-menu/zk/internal/util/opt" stringsutil "github.com/mickael-menu/zk/internal/util/strings" @@ -26,6 +27,8 @@ var ( type Opts struct { // Preview command executed by fzf when hovering a line. PreviewCmd opt.String + // Optionally provide additional arguments, taken from the config `fzf-options` property. + Options opt.String // Amount of space between two non-empty fields. Padding int // Delimiter used by fzf between fields. @@ -72,21 +75,18 @@ func New(opts Opts) (*Fzf, error) { opts.Delimiter = "\x01" } + // Hard-coded fzf options that are required by zk. args := []string{ - "--delimiter", opts.Delimiter, - "--tiebreak", "begin", "--ansi", - "--exact", - "--tabstop", "4", - "--height", "100%", - "--layout", "reverse", - //"--info", "inline", - // Make sure the path and titles are always visible - "--no-hscroll", - // Don't highlight search terms - "--color", "hl:-1,hl+:-1", - "--preview-window", "wrap", + "--delimiter", opts.Delimiter, + } + + // Additional options. + additionalArgs, err := shellquote.Split(opts.Options.String()) + if err != nil { + return nil, errors.Wrapf(err, "can't split the fzf-options: %s", opts.Options.String()) } + args = append(args, additionalArgs...) header := "" binds := []string{} diff --git a/internal/adapter/fzf/note_filter.go b/internal/adapter/fzf/note_filter.go index 847f834..5ff7910 100644 --- a/internal/adapter/fzf/note_filter.go +++ b/internal/adapter/fzf/note_filter.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "time" "github.com/mickael-menu/zk/internal/adapter/term" @@ -32,6 +33,10 @@ type NoteFilterOpts struct { AlwaysFilter bool // Format for a single line, taken from the config `fzf-line` property. LineTemplate opt.String + // Optionally provide additional arguments, taken from the config `fzf-options` property. + FzfOptions opt.String + // Key binding for the new action. + NewBinding opt.String // Preview command to run when selecting a note. PreviewCmd opt.String // When non null, a "create new note from query" binding will be added to @@ -88,16 +93,20 @@ func (f *NoteFilter) Apply(notes []core.ContextualNote) ([]core.ContextualNote, suffix = " in " + dir.Name + "/" } - bindings = append(bindings, Binding{ - Keys: "Ctrl-N", - Description: "create a note with the query as title" + suffix, - Action: fmt.Sprintf(`abort+execute("%s" new "%s" --title {q} < /dev/tty > /dev/tty)`, zkBin, dir.Path), - }) + newBinding := f.opts.NewBinding.OrString("Ctrl-E").String() + if newBinding != "" { + bindings = append(bindings, Binding{ + Keys: newBinding, + Description: "create a note with the query as title" + suffix, + Action: fmt.Sprintf(`abort+execute("%s" new "%s" --title {q} < /dev/tty > /dev/tty)`, zkBin, dir.Path), + }) + } } previewCmd := f.opts.PreviewCmd.OrString("cat {-1}").Unwrap() fzf, err := New(Opts{ + Options: f.opts.FzfOptions.OrString(defaultOptions), PreviewCmd: opt.NewNotEmptyString(previewCmd), Padding: 2, Bindings: bindings, @@ -158,6 +167,18 @@ func (f *NoteFilter) Apply(notes []core.ContextualNote) ([]core.ContextualNote, var defaultLineTemplate = `{{style "title" title-or-path}} {{style "understate" body}} {{style "understate" (json metadata)}}` +// defaultOptions are the default fzf options used when filtering notes. +var defaultOptions = strings.Join([]string{ + "--tiebreak begin", // Prefer matches located at the beginning of the line + "--exact", // Look for exact matches instead of fuzzy ones by default + "--tabstop 4", // Length of tab characters + "--height 100%", // Height of the list relative to the terminal window + "--layout reverse", // Display the input field at the top + "--no-hscroll", // Make sure the path and titles are always visible + "--color hl:-1,hl+:-1", // Don't highlight search terms + "--preview-window wrap", // Enable line wrapping in the preview window +}, " ") + type lineRenderContext struct { Filename string FilenameStem string `handlebars:"filename-stem"` diff --git a/internal/cli/container.go b/internal/cli/container.go index 0c00443..f9af809 100644 --- a/internal/cli/container.go +++ b/internal/cli/container.go @@ -206,6 +206,8 @@ func (c *Container) CurrentNotebook() (*core.Notebook, error) { func (c *Container) NewNoteFilter(opts fzf.NoteFilterOpts) *fzf.NoteFilter { opts.PreviewCmd = c.Config.Tool.FzfPreview opts.LineTemplate = c.Config.Tool.FzfLine + opts.FzfOptions = c.Config.Tool.FzfOptions + opts.NewBinding = c.Config.Tool.FzfBindNew return fzf.NewNoteFilter(opts, c.FS, c.Terminal, c.TemplateLoader) } diff --git a/internal/core/config.go b/internal/core/config.go index b7d8ab4..8db108f 100644 --- a/internal/core/config.go +++ b/internal/core/config.go @@ -151,6 +151,8 @@ type ToolConfig struct { Pager opt.String FzfPreview opt.String FzfLine opt.String + FzfOptions opt.String + FzfBindNew opt.String } // LSPConfig holds the Language Server Protocol configuration. @@ -362,6 +364,12 @@ func ParseConfig(content []byte, path string, parentConfig Config) (Config, erro if tool.FzfLine != nil { config.Tool.FzfLine = opt.NewNotEmptyString(*tool.FzfLine) } + if tool.FzfOptions != nil { + config.Tool.FzfOptions = opt.NewNotEmptyString(*tool.FzfOptions) + } + if tool.FzfBindNew != nil { + config.Tool.FzfBindNew = opt.NewStringWithPtr(tool.FzfBindNew) + } // LSP completion lspCompl := tomlConf.LSP.Completion @@ -506,6 +514,8 @@ type tomlToolConfig struct { Pager *string FzfPreview *string `toml:"fzf-preview"` FzfLine *string `toml:"fzf-line"` + FzfOptions *string `toml:"fzf-options"` + FzfBindNew *string `toml:"fzf-bind-new"` } type tomlLSPConfig struct { diff --git a/internal/core/config_test.go b/internal/core/config_test.go index 9eaefee..c29e51a 100644 --- a/internal/core/config_test.go +++ b/internal/core/config_test.go @@ -89,6 +89,8 @@ func TestParseComplete(t *testing.T) { pager = "less" fzf-preview = "bat {1}" fzf-line = "{{title}}" + fzf-options = "--border --height 40%" + fzf-bind-new = "Ctrl-C" [extra] hello = "world" @@ -229,6 +231,8 @@ func TestParseComplete(t *testing.T) { Pager: opt.NewString("less"), FzfPreview: opt.NewString("bat {1}"), FzfLine: opt.NewString("{{title}}"), + FzfOptions: opt.NewString("--border --height 40%"), + FzfBindNew: opt.NewString("Ctrl-C"), }, LSP: LSPConfig{ Completion: LSPCompletionConfig{