From 9153fd16e1a0eb5ff45c20752a12002cd7e5a880 Mon Sep 17 00:00:00 2001 From: Gadzhi Kharkharov Date: Sun, 24 Oct 2021 03:39:42 +0300 Subject: [PATCH] scripts: add markdown heading jump --- README.md | 19 ++++++++++--------- scripts/kks-md-heading | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) create mode 100755 scripts/kks-md-heading diff --git a/README.md b/README.md index d792864..b3d5c35 100644 --- a/README.md +++ b/README.md @@ -132,15 +132,16 @@ autostarting mechanism of your desktop to start it with `kak -d -s mysession`. ## Provided scripts -| script | function | -| -------------------------------------- | ------------------------------------------------------- | -| [`kks-buffers`](./scripts/kks-buffers) | pick buffers | -| [`kks-files`](./scripts/kks-files) | pick files | -| [`kks-grep`](./scripts/kks-grep) | search for pattern in working directory | -| [`kks-lf`](./scripts/kks-lf) | open [lf] with current buffer selected | -| [`kks-lines`](./scripts/kks-lines) | jump to line in buffer | -| [`kks-mru`](./scripts/kks-mru) | pick recently opened file | -| [`kks-select`](./scripts/kks-select) | select Kakoune session and client to set up environment | +| script | function | +| -------------------------------------------- | ------------------------------------------------------- | +| [`kks-buffers`](./scripts/kks-buffers) | pick buffers | +| [`kks-files`](./scripts/kks-files) | pick files | +| [`kks-grep`](./scripts/kks-grep) | search for pattern in working directory | +| [`kks-lf`](./scripts/kks-lf) | open [lf] with current buffer selected | +| [`kks-mru`](./scripts/kks-mru) | pick recently opened file | +| [`kks-lines`](./scripts/kks-lines) | jump to line in buffer | +| [`kks-md-heading`](./scripts/kks-md-heading) | jump to markdown heading | +| [`kks-select`](./scripts/kks-select) | select Kakoune session and client to set up environment | [lf]: https://github.com/gokcehan/lf diff --git a/scripts/kks-md-heading b/scripts/kks-md-heading new file mode 100755 index 0000000..e964886 --- /dev/null +++ b/scripts/kks-md-heading @@ -0,0 +1,14 @@ +#!/bin/sh +# +# jump to heading in markdown file +# +# requires: +# - ripgrep (https://github.com/BurntSushi/ripgrep) +# - fzf (https://github.com/junegunn/fzf) + +kks cat | + rg -n '^#+' | + column -t -s ':' | + fzf --height 100% --prompt 'heading> ' | + awk '{print $1}' | + xargs -r -I {} kks send "execute-keys '{}gx'"