Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
5f18dbf8
Commit
5f18dbf8
authored
Jun 15, 2019
by
Sung Won Cho
Committed by
Robby Russell
Jun 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a completion plugin for dnote (#7885)
parent
36e13f48
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
0 deletions
+90
-0
README.md
plugins/dnote/README.md
+51
-0
_dnote
plugins/dnote/_dnote
+39
-0
No files found.
plugins/dnote/README.md
0 → 100644
View file @
5f18dbf8
# Dnote Plugin
This plugin adds auto-completion for
[
Dnote
](
https://dnote.io
)
project.
To use it, add
`dnote`
to the plugins array in your zshrc file:
```
zsh
plugins
=(
dnote
)
```
## Usage
At the basic level, this plugin completes all Dnote commands.
```
zsh
$
dnote a
(
press <TAB> here
)
```
would result in:
```
zsh
$
dnote add
```
For some commands, this plugin dynamically suggests matching book names.
For instance, if you have three books that begin with 'j': 'javascript', 'job', 'js',
```
zsh
$
dnote view j
(
press <TAB> here
)
```
would result in:
```
zsh
$
dnote v j
javascript job js
```
As another example,
```
zsh
$
dnote edit ja
(
press <TAB> here
)
```
would result in:
```zsh
$ dnote v javascript
``````
plugins/dnote/_dnote
0 → 100644
View file @
5f18dbf8
#compdef dnote
local -a _1st_arguments
_1st_arguments=(
'add:add a new note'
'view:list books, notes, or view a content'
'edit:edit a note or a book'
'remove:remove a note or a book'
'find:find notes by keywords'
'sync:sync data with the server'
'login:login to the dnote server'
'logout:logout from the dnote server'
'version:print the current version'
'help:get help about any command'
)
get_booknames() {
local names=$(dnote view --name-only)
local -a ret
while read -r line; do
ret+=("${line}")
done <<< "$names"
echo "$ret"
}
if (( CURRENT == 2 )); then
_describe -t commands "dnote subcommand" _1st_arguments
return
elif (( CURRENT == 3 )); then
case "$words[2]" in
v|view|a|add)
_alternative \
"names:book names:($(get_booknames))"
esac
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment