You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-15Lines changed: 27 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,16 +42,17 @@ From people using z.lua:
42
42
## Examples
43
43
44
44
```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
55
56
```
56
57
57
58
@@ -176,16 +177,12 @@ To z.lua, a directory that has low ranking but has been accessed recently will q
176
177
177
178
## Default Matching
178
179
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.
180
181
181
182
- cd to a directory contains foo:
182
183
183
184
z foo
184
185
185
-
- cd to a directory ends with foo:
186
-
187
-
z foo$
188
-
189
186
- use multiple arguments:
190
187
191
188
Assuming the following database:
@@ -195,6 +192,15 @@ By default, z.lua uses default matching algorithm similar to the original z.sh.
195
192
196
193
`"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`.
197
194
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
+
198
204
## Enhanced Matching
199
205
200
206
Enhanced matching can be enabled by exporting the environment:
@@ -319,6 +325,7 @@ New option `"-b"` can quickly go back to a specific parent directory in bash ins
319
325
-**(No argument)**: `cd` into the project root, the project root the nearest parent directory with `.git`/`.hg`/`.svn` in it.
320
326
-**(One argument)**: `cd` into the closest parent starting with keyword, if not find, go to the parent containing keyword.
321
327
-**(Two arguments)**: replace the first value with the second one (in the current path).
328
+
If simple substitution does not work, falls back to fuzzily replacing path components.
322
329
323
330
Let's start by aliasing `z -b` to `zb`:
324
331
@@ -338,6 +345,11 @@ Let's start by aliasing `z -b` to `zb`:
338
345
# substitute jekyll with ghost
339
346
~/github/jekyll/test$ zb jekyll ghost
340
347
=>cd~/github/ghost/test
348
+
349
+
# same as above, but fuzzy
350
+
~/github/jekyll/test$ zb jek gh
351
+
=> z ~/github/ gh /test
352
+
=>cd~/github/ghost/test # Assuming that's the most frecent match
341
353
```
342
354
343
355
Backward jumping can also be used with `$_ZL_ECHO` option (echo $PWD after cd), which makes it possible to combine them with other tools without actually changing the working directory (eg. ``ls `zb git` ``).
0 commit comments