|
4 | 4 | -- z.lua - a cd command that learns, by skywind 2018, 2019
|
5 | 5 | -- Licensed under MIT license.
|
6 | 6 | --
|
7 |
| --- Version 1.7.3, Last Modified: 2019/09/06 17:27 |
| 7 | +-- Version 1.7.4, Last Modified: 2019/12/29 04:52 |
8 | 8 | --
|
9 | 9 | -- * 10x faster than fasd and autojump, 3x faster than z.sh
|
10 | 10 | -- * available for posix shells: bash, zsh, sh, ash, dash, busybox
|
|
75 | 75 | -- set $_ZL_MATCH_MODE to 1 to enable enhanced matching mode.
|
76 | 76 | -- set $_ZL_NO_CHECK to 1 to disable path validation. z --purge to clear.
|
77 | 77 | -- set $_ZL_USE_LFS to 1 to use lua-filesystem package
|
| 78 | +-- set $_ZL_HYPHEN to 1 to stop treating hyphen as a regexp keyword |
78 | 79 | --
|
79 | 80 | --=====================================================================
|
80 | 81 |
|
@@ -121,6 +122,7 @@ Z_CMD = 'z'
|
121 | 122 | Z_MATCHMODE = 0
|
122 | 123 | Z_MATCHNAME = false
|
123 | 124 | Z_SKIPPWD = false
|
| 125 | +Z_HYPHEN = false |
124 | 126 |
|
125 | 127 | os.LOG_NAME = os.getenv('_ZL_LOG_NAME')
|
126 | 128 |
|
@@ -1267,6 +1269,9 @@ function data_select(M, patterns, matchlast)
|
1267 | 1269 | local pats = {}
|
1268 | 1270 | for i = 1, #patterns do
|
1269 | 1271 | local p = patterns[i]
|
| 1272 | + if Z_HYPHEN then |
| 1273 | + p = p:gsub('-', '%%-') |
| 1274 | + end |
1270 | 1275 | table.insert(pats, case_insensitive_pattern(p))
|
1271 | 1276 | end
|
1272 | 1277 | for i = 1, #M do
|
@@ -1868,6 +1873,7 @@ function z_init()
|
1868 | 1873 | local _zl_matchname = os.getenv('_ZL_MATCH_NAME')
|
1869 | 1874 | local _zl_skippwd = os.getenv('_ZL_SKIP_PWD')
|
1870 | 1875 | local _zl_matchmode = os.getenv('_ZL_MATCH_MODE')
|
| 1876 | + local _zl_hyphen = os.getenv('_ZL_HYPHEN') |
1871 | 1877 | if _zl_data ~= nil and _zl_data ~= "" then
|
1872 | 1878 | if windows then
|
1873 | 1879 | DATA_FILE = _zl_data
|
@@ -1920,6 +1926,12 @@ function z_init()
|
1920 | 1926 | Z_SKIPPWD = true
|
1921 | 1927 | end
|
1922 | 1928 | end
|
| 1929 | + if _zl_hyphen ~= nil then |
| 1930 | + local m = string.lower(_zl_hyphen) |
| 1931 | + if (m == '1' or m == 'yes' or m == 'true' or m == 't') then |
| 1932 | + Z_HYPHEN = true |
| 1933 | + end |
| 1934 | + end |
1923 | 1935 | end
|
1924 | 1936 |
|
1925 | 1937 |
|
|
0 commit comments