Skip to content

Commit 546b983

Browse files
committed
Add zsh plugin
1 parent 7b3e6c2 commit 546b983

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ include README.rst
22
include LICENSE
33
recursive-include doc *
44
prune doc/_build
5+
include utils/plugin.zsh

integration/plugin.zsh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Z Shell integration for sphinxnotes-snippet
2+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
#
4+
# :Author: Shengyu Zhang
5+
# :Date: 2021-03-20
6+
# :License: BSD
7+
8+
snippet="snippet"
9+
10+
# $1: kinds
11+
function snippet_list() {
12+
$snippet list --kinds $1 | \
13+
fzf --with-nth 2.. --no-hscroll --header-lines 1 | \
14+
cut -d ' ' -f1
15+
}
16+
17+
function snippet_view() {
18+
$snippet get --text $(snippet_list c)
19+
}
20+
21+
function snippet_edit() {
22+
$EDITOR $($snippet get --file $(snippet_list c))
23+
}
24+
25+
# Define a widget, mapped to our function above.
26+
zle -N snippet_view
27+
zle -N snippet_edit
28+
29+
# Bind it to ctrl-kv
30+
bindkey "^kv" snippet_view
31+
# Bind it to ctrl-ke
32+
bindkey "^ke" snippet_edit
33+
34+
# vim: set shiftwidth=2:

0 commit comments

Comments
 (0)