Skip to content

Commit 3703c5a

Browse files
committed
Put z -b foo bar in command summary, add regex docs
1 parent 3894a6b commit 3703c5a

File tree

2 files changed

+46
-38
lines changed

2 files changed

+46
-38
lines changed

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ From people using z.lua:
4242
## Examples
4343

4444
```bash
45-
z foo # cd to most frecent dir matching foo
46-
z foo bar # cd to most frecent dir matching foo and bar
47-
z -r foo # cd to the highest ranked dir matching foo
48-
z -t foo # cd to most recently accessed dir matching foo
49-
z -l foo # list matches instead of cd
50-
z -c foo # restrict matches to subdirs of $PWD
51-
z -e foo # echo the best match, don't cd
52-
z -i foo # cd with interactive selection
53-
z -I foo # cd with interactive selection using fzf
54-
z -b foo # cd to the parent directory starting with foo
45+
z foo # cd to most frecent dir matching foo
46+
z foo bar # cd to most frecent dir matching foo and bar
47+
z -r foo # cd to the highest ranked dir matching foo
48+
z -t foo # cd to most recently accessed dir matching foo
49+
z -l foo # list matches instead of cd
50+
z -c foo # restrict matches to subdirs of $PWD
51+
z -e foo # echo the best match, don't cd
52+
z -i foo # cd with interactive selection
53+
z -I foo # cd with interactive selection using fzf
54+
z -b foo # cd to the parent directory starting with foo
55+
z -b foo bar # replace foo with bar in cwd and cd there
5556
```
5657

5758

@@ -176,16 +177,12 @@ To z.lua, a directory that has low ranking but has been accessed recently will q
176177

177178
## Default Matching
178179

179-
By default, z.lua uses default matching algorithm similar to the original z.sh. Paths must be match all of the regexes in order.
180+
By default, `z.lua` uses default matching algorithm similar to the original `z.sh`. Paths must be match all of the regexes in order.
180181

181182
- cd to a directory contains foo:
182183

183184
z foo
184185

185-
- cd to a directory ends with foo:
186-
187-
z foo$
188-
189186
- use multiple arguments:
190187

191188
Assuming the following database:
@@ -195,6 +192,15 @@ By default, z.lua uses default matching algorithm similar to the original z.sh.
195192

196193
`"z in"` would cd into `/home/user/mail/inbox` as the higher weighted entry. However you can pass multiple arguments to z.lua to prefer a different entry. In the above example, `"z w in"` would then change directory to `/home/user/work/inbox`.
197194

195+
- use regexes:
196+
197+
```bash
198+
z foo$ # cd to a directory ends with foo
199+
z %d # cd to a directory that contains a digit
200+
```
201+
202+
Unlike `z.sh`, `z.lua` uses the [Lua regular expression syntax](https://www.lua.org/pil/20.2.html).
203+
198204
## Enhanced Matching
199205

200206
Enhanced matching can be enabled by exporting the environment:

z.lua

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
-- * compatible with lua 5.1, 5.2 and 5.3+
1313
--
1414
-- USE:
15-
-- * z foo # cd to most frecent dir matching foo
16-
-- * z foo bar # cd to most frecent dir matching foo and bar
17-
-- * z -r foo # cd to highest ranked dir matching foo
18-
-- * z -t foo # cd to most recently accessed dir matching foo
19-
-- * z -l foo # list matches instead of cd
20-
-- * z -c foo # restrict matches to subdirs of $PWD
21-
-- * z -e foo # echo the best match, don't cd
22-
-- * z -x path # remove path from history
23-
-- * z -i foo # cd with interactive selection
24-
-- * z -I foo # cd with interactive selection using fzf
25-
-- * z -b foo # cd to the parent directory starting with foo
15+
-- * z foo # cd to most frecent dir matching foo
16+
-- * z foo bar # cd to most frecent dir matching foo and bar
17+
-- * z -r foo # cd to highest ranked dir matching foo
18+
-- * z -t foo # cd to most recently accessed dir matching foo
19+
-- * z -l foo # list matches instead of cd
20+
-- * z -c foo # restrict matches to subdirs of $PWD
21+
-- * z -e foo # echo the best match, don't cd
22+
-- * z -x path # remove path from history
23+
-- * z -i foo # cd with interactive selection
24+
-- * z -I foo # cd with interactive selection using fzf
25+
-- * z -b foo # cd to the parent directory starting with foo
26+
-- * z -b foo bar # replace foo with bar in cwd and cd there
2627
--
2728
-- Bash Install:
2829
-- * put something like this in your .bashrc:
@@ -46,7 +47,7 @@
4647
--
4748
-- Fish Shell Install:
4849
-- * put something like this in your config file:
49-
-- source (lua /path/to/z.lua --init fish | psub)
50+
-- lua /path/to/z.lua --init fish | source
5051
--
5152
-- Power Shell Install:
5253
-- * put something like this in your config file:
@@ -2714,17 +2715,18 @@ end
27142715
-----------------------------------------------------------------------
27152716
function z_help()
27162717
local cmd = Z_CMD .. ' '
2717-
print(cmd .. 'foo # cd to most frecent dir matching foo')
2718-
print(cmd .. 'foo bar # cd to most frecent dir matching foo and bar')
2719-
print(cmd .. '-r foo # cd to highest ranked dir matching foo')
2720-
print(cmd .. '-t foo # cd to most recently accessed dir matching foo')
2721-
print(cmd .. '-l foo # list matches instead of cd')
2722-
print(cmd .. '-c foo # restrict matches to subdirs of $PWD')
2723-
print(cmd .. '-e foo # echo the best match, don\'t cd')
2724-
print(cmd .. '-x path # remove path from history')
2725-
print(cmd .. '-i foo # cd with interactive selection')
2726-
print(cmd .. '-I foo # cd with interactive selection using fzf')
2727-
print(cmd .. '-b foo # cd to the parent directory starting with foo')
2718+
print(cmd .. 'foo # cd to most frecent dir matching foo')
2719+
print(cmd .. 'foo bar # cd to most frecent dir matching foo and bar')
2720+
print(cmd .. '-r foo # cd to highest ranked dir matching foo')
2721+
print(cmd .. '-t foo # cd to most recently accessed dir matching foo')
2722+
print(cmd .. '-l foo # list matches instead of cd')
2723+
print(cmd .. '-c foo # restrict matches to subdirs of $PWD')
2724+
print(cmd .. '-e foo # echo the best match, don\'t cd')
2725+
print(cmd .. '-x path # remove path from history')
2726+
print(cmd .. '-i foo # cd with interactive selection')
2727+
print(cmd .. '-I foo # cd with interactive selection using fzf')
2728+
print(cmd .. '-b foo # cd to the parent directory starting with foo')
2729+
print(cmd .. '-b foo bar # replace foo with bar in cwd and cd there')
27282730
end
27292731

27302732

0 commit comments

Comments
 (0)