Skip to content

Commit

Permalink
scripts: add markdown heading jump
Browse files Browse the repository at this point in the history
  • Loading branch information
kkga committed Oct 24, 2021
1 parent 6541943 commit 9153fd1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions scripts/kks-md-heading
Original file line number Diff line number Diff line change
@@ -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 '<esc>{}gx'"

0 comments on commit 9153fd1

Please sign in to comment.