Skip to content

Commit 2d76c1e

Browse files
authored
Organize documents (#22)
Organize documents
2 parents 6e27706 + 57197ec commit 2d76c1e

File tree

4 files changed

+61
-135
lines changed

4 files changed

+61
-135
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ workflows:
4747
branches:
4848
only: # only branches matching the below regex filters will run
4949
- master
50-
- develop
50+
# - develop
5151
- integration-test:
5252
requires: # buildが成功したら実行する
5353
- build

README.md

Lines changed: 60 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,46 @@ eval "$(pmy init)"
3030

3131
You can also add the line into your ~/.zshrc if you want.
3232

33+
## Quick Start
34+
35+
Try downloading very simple pmy rule files into `$HOME/.pmy` (where pmy searches for rules by default).
36+
37+
```zsh
38+
git clone https://github.com/relastle/pmy-config $HOME/.pmy
39+
```
40+
41+
Then, you are already able to enjoy path completion using fuzzy finder.
42+
43+
![Sample GIF](https://user-images.githubusercontent.com/6816040/67204810-48a3e000-f449-11e9-8195-ee0ae1282bdb.gif)
44+
45+
This path-completion befavior is realized by simple yml configurations below
46+
47+
```yml
48+
- regexp-left: ^(?P<body>.*?)(?P<path>~{0,1}([0-9A-Za-z_\-.]*/)+)(?P<query>[0-9A-Za-z_\-.]*)$
49+
cmd-groups:
50+
- stmt: \ls -AlFG --color=always <path> | tail -n +2 | grep --color=always "<query>"
51+
after: awk '{print $8}'
52+
fuzzy-finder-cmd: fzf -0 -1 --ansi -n8
53+
buffer-left: <body><path>
54+
buffer-right: '[]'
55+
56+
- regexp-left: ^(?P<body>.*?) (?P<query>[0-9A-Za-z_\-.]*)$
57+
cmd-groups:
58+
- stmt: \ls -AlFG --color=always | tail -n +2 | grep --color=always "<query>"
59+
after: awk '{print $8}'
60+
fuzzy-finder-cmd: fzf -0 -1 --ansi -n8
61+
buffer-left: '<body> '
62+
buffer-right: '[]'
63+
```
64+
65+
Customization is very easy.
66+
67+
- Wrtie your own rule in JSON/YML format.
68+
- Save it in the name of `pmy_rules.[json|yml]`
69+
- Locate the file under one of `$PMY_RULE_PATH`.
70+
71+
If you want to investigate into further examples, see [Gallery](https://github.com/relastle/pmy/wiki/Gallery).
72+
3373
## Basic Usage
3474

3575
Pmy can be invoked by <kbd>Ctrl</kbd> + <kbd>Space</kbd>.
@@ -60,16 +100,16 @@ A single rule is described as follows
60100
"bufferRight": "[]"
61101
}
62102
```
63-
| property name | description |
64-
| --- | --- |
65-
| ***regexpLeft*** | If this regexp matches the current left buffer, this rule will be activated. |
66-
| ***regexpRight*** | Same as left one, but in many cases you don't have to set it becasue you usually work in line left to right. |
67-
| ***cmdGroups.tag*** | tag string which will be inserted ahead of each line of outputs of the corresponding command. |
68-
| ***cmdGroups.stmt*** | command that will be executed to make sources for fuzzy-finder. |
69-
| ***cmdGroups.after*** | command that will be executed against line after fuzzy-finder selection (using pipe). |
70-
| ***fuzzyFinderCmd*** | Fuzzy finder command that will be executed (piped) against obtained command |
71-
| ***bufferLeft*** | Buffer left values after completion. [] denotes the original left buffer. |
72-
| ***bufferRight*** | Buffer right values after completion. [] denotes the original right buffer. |
103+
| property name (JSON / YML) | description |
104+
| --- | --- |
105+
| ***regexpLeft*** / ***regexp-left*** | If this regexp matches the current left buffer, this rule will be activated. |
106+
| ***regexpRight*** / ***regexp-right*** | Same as left one, but in many cases you don't have to set it becasue you usually work in line left to right. |
107+
| ***cmdGroups.tag*** / ***cmd-groups.tag*** | tag string which will be inserted ahead of each line of outputs of the corresponding command. |
108+
| ***cmdGroups.stmt*** / ***cmd-groups.stmt*** | command that will be executed to make sources for fuzzy-finder. |
109+
| ***cmdGroups.after*** / ***cmd-groups.after*** | command that will be executed against line after fuzzy-finder selection (using pipe). |
110+
| ***fuzzyFinderCmd*** / ***fuzzy-finder-cmd*** | Fuzzy finder command that will be executed (piped) against obtained command |
111+
| ***bufferLeft*** / ***buffer-left*** | Buffer left values after completion. [] denotes the original left buffer. |
112+
| ***bufferRight*** / ***buffer-right*** | Buffer right values after completion. [] denotes the original right buffer. |
73113

74114
### Rule configuration
75115

@@ -91,9 +131,9 @@ This setting is similar that of that of `$PATH` variable (, which controlls path
91131

92132
In this situation, priorities as follows:
93133

94-
- 1. /path/to/1/hoge_pmy_rules.json
95-
- 2. /path/to/2/hoge_pmy_rules.json
96-
- 3. ${HOME}/.pmy/rules/hoge_pmy_rules.json
134+
- 1. `/path/to/1/hoge_pmy_rules.json`
135+
- 2. `/path/to/2/hoge_pmy_rules.json`
136+
- 3. `${HOME}/.pmy/rules/hoge_pmy_rules.json`
97137

98138
### command specific rule
99139

@@ -102,7 +142,7 @@ which means that setting such rules into a single one file will increase searchi
102142
Therefore, you can define command specific rule by putting command-specific rules in the same directory as
103143
`${PMY_RULE_PATH}` with an appropriate file name as follows.
104144

105-
```bash
145+
```zsh
106146
├── pmy_rules.json
107147
├── git_pmy_rules.json
108148
├── cd_pmy_rules.json
@@ -125,119 +165,13 @@ If you want to change these values, you should export them in .zshrc before you
125165
eval "$(pmy init)"
126166
```
127167

128-
## Demonstration
129-
130-
Here, some of examples of pmy's completion are provided as GIF with its rule(json format).
131-
They are just a few examples of all possible pattern-matching based completion, but I think it help you to create new pmy's rule.
132-
133-
### git checkout(co)
134-
135-
![pmy_git_checkout_resized](https://user-images.githubusercontent.com/6816040/59544897-a5e6cc80-8f51-11e9-8b6a-656734d159b0.gif)
136-
137-
```json
138-
{
139-
"regexpLeft": "(?P<body>git (co|checkout)) *(?P<query>.*)$",
140-
"cmdGroups": [
141-
{
142-
"tag": "🌱:branch",
143-
"stmt": "git branch --format=\"%(refname:short)\"",
144-
"after": "awk '{print $0}'"
145-
},
146-
{
147-
"tag": "🍺:commit",
148-
"stmt": "git log --oneline -10",
149-
"after": "awk '{print $1}'"
150-
}
151-
],
152-
"fuzzyFinderCmd": "fzf -0 -1 -q \"<query>\"",
153-
"bufferLeft": "<body> ",
154-
"bufferRight": "[]"
155-
}
156-
157-
```
158-
159-
### git cherry-pick(cp)
160-
161-
![pmy_git_cherry-pick_resized](https://user-images.githubusercontent.com/6816040/59544901-a67f6300-8f51-11e9-91f9-16e668b25af7.gif)
168+
## Features
162169

163-
```json
164-
{
165-
"regexpLeft": "git (cp|cherry-pick) *$",
166-
"cmdGroups": [
167-
{
168-
"tag": "🍒:commit",
169-
"stmt": "git log --oneline --branches --tags",
170-
"after": "awk '{print $1}'"
171-
}
172-
],
173-
"bufferLeft": "[]",
174-
"bufferRight": "[]"
175-
}
176-
177-
```
178-
179-
### cd
180-
181-
![pmy_cd_resized](https://user-images.githubusercontent.com/6816040/59544895-a54e3600-8f51-11e9-894a-22beac49014e.gif)
182-
183-
```json
184-
{
185-
"regexpLeft": "^cd +(?P<path>([^/]*/)*)(?P<query>[^/]*)$",
186-
"cmdGroups": [
187-
{
188-
"tag": "",
189-
"stmt": "command ls -F -1 <path> | egrep '/$'",
190-
"after": "awk '{print $0}'"
191-
}
192-
],
193-
"fuzzyFinderCmd": "fzf -0 -1 -q \"<query>\"",
194-
"bufferLeft": "cd <path>",
195-
"bufferRight": "[]"
196-
}
197-
```
198-
199-
### Postfix completion
200-
201-
Pmy's completion rule is highly customizable and flexible, you can easily create a rule that performs ***postfix-completion*** .
202-
203-
#### generate for loop iterating from 1 to a given number
204-
205-
![pmy_postfix_numfor_resized](https://user-images.githubusercontent.com/6816040/59544899-a5e6cc80-8f51-11e9-82ca-a149620264cb.gif)
206-
207-
```json
208-
{
209-
"regexpLeft": "^(?P<num>[1-9][0-9]*).for$",
210-
"cmdGroups": [
211-
{
212-
"tag": "",
213-
"stmt": "echo ''",
214-
"after": "awk '{print $0}'"
215-
}
216-
],
217-
"bufferLeft": "for x in $(seq 1 <num>); do ",
218-
"bufferRight": "; done"
219-
}
220-
221-
```
222-
223-
#### generate for loop iterating each line of outputs from a given command
224-
225-
![pmy_postfix_general_resized](https://user-images.githubusercontent.com/6816040/59544900-a5e6cc80-8f51-11e9-8c86-1a88a417b11e.gif)
226-
227-
```json
228-
{
229-
"regexpLeft": "(?P<cmd>.+)\\.for$",
230-
"cmdGroups": [
231-
{
232-
"tag": "",
233-
"stmt": "echo ''",
234-
"after": "awk '{print $0}'"
235-
}
236-
],
237-
"bufferLeft": "for x in $(<cmd>); do ",
238-
"bufferRight": "; done"
239-
}
240-
```
170+
- [x] JSON/YML rule-configurations.
171+
- [x] Customize fuzzy finder command used.
172+
- [x] Combining multiple command into one source.
173+
- [ ] Caching compiled regular expression.
174+
- [ ] Customizing priority of rules.
241175

242176
## [License](LICENSE)
243177

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ go 1.13
44

55
require (
66
github.com/fatih/color v1.7.0
7-
github.com/k0kubun/pp v3.0.1+incompatible
87
github.com/mattn/go-colorable v0.1.4 // indirect
98
github.com/mattn/go-isatty v0.0.10 // indirect
109
github.com/mattn/go-zglob v0.0.1
1110
github.com/rakyll/statik v0.1.6
12-
github.com/relastle/colorflag v0.0.0-20190926071630-d4c845e34e8c
1311
github.com/urfave/cli v1.22.1
1412
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 // indirect
1513
gopkg.in/yaml.v2 v2.2.4

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSY
33
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
44
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
55
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
6-
github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40=
7-
github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg=
8-
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
9-
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
106
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
117
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
128
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
@@ -19,8 +15,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1915
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2016
github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=
2117
github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
22-
github.com/relastle/colorflag v0.0.0-20190926071630-d4c845e34e8c h1:+rQG0CRZFZw5xK4A9RCLxRcWdROI4DzCU66iWZx/0HE=
23-
github.com/relastle/colorflag v0.0.0-20190926071630-d4c845e34e8c/go.mod h1:zCHW+H3mqOZ35829qC8zau+dnhUgsqKObIApF0m0KdM=
2418
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
2519
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
2620
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=

0 commit comments

Comments
 (0)