From 592771f70a3a46b8dc06398a1d43500cce0dedb2 Mon Sep 17 00:00:00 2001 From: 0xC0FFEE Date: Thu, 17 Jan 2019 20:17:00 +0100 Subject: [PATCH 1/3] Remove ^Ms --- README.md | 108 +++++++++++++++++++++++++++--------------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 8b6969b..84c84f0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ For example, `z foo bar` would match `/foo/bar` but not `/bar/foo`. - Supports Windows cmd (with clink) and cmder - Self contained, no dependence on awk/gawk - Compatible with lua 5.1, 5.2 and 5.3+ -- New "$_ZL_ADD_ONCE" to allow updating database only if `$PWD` changed. +- New "$_ZL_ADD_ONCE" to allow updating database only if `$PWD` changed. - Enhanced matching mode with "$_ZL_MATCH_MODE" set to 1. @@ -39,33 +39,33 @@ z -i foo # cd with interactive selection ## Install -- bash: - - put something like this in your `.bashrc`: - - eval "$(lua /path/to/z.lua --init bash)" - -- zsh: - - put something like this in your `.zshrc`: - - eval "$(lua /path/to/z.lua --init zsh)" - -- posix shells: - +- bash: + + put something like this in your `.bashrc`: + + eval "$(lua /path/to/z.lua --init bash)" + +- zsh: + + put something like this in your `.zshrc`: + + eval "$(lua /path/to/z.lua --init zsh)" + +- posix shells: + put something like this in your `.profile`: eval "$(lua /path/to/z.lua --init posix)" (sh, ash, dash and busybox have been tested) -- Windows (with clink): - +- Windows (with clink): + - copy z.lua and z.cmd to clink's home directory - Add clink's home to `%PATH%` (z.cmd can be called anywhere) - Ensure that "lua" can be called in `%PATH%` -- Windows cmder: +- Windows cmder: - copy z.lua and z.cmd to cmder/vendor - Add cmder/vendor to `%PATH%` @@ -77,11 +77,11 @@ z -i foo # cd with interactive selection - set `$_ZL_CMD` in .bashrc/.zshrc to change the command (default z). - set `$_ZL_DATA` in .bashrc/.zshrc to change the datafile (default ~/.zlua). - set `$_ZL_NO_PROMPT_COMMAND` if you're handling PROMPT_COMMAND yourself. -- set `$_ZL_EXCLUDE_DIRS` to an array of directories to exclude. -- set `$_ZL_ADD_ONCE` to '1' to update database only if `$PWD` changed. -- set `$_ZL_MAXAGE` to define a aging threshold (default is 5000). +- set `$_ZL_EXCLUDE_DIRS` to an array of directories to exclude. +- set `$_ZL_ADD_ONCE` to '1' to update database only if `$PWD` changed. +- set `$_ZL_MAXAGE` to define a aging threshold (default is 5000). - set `$_ZL_CD` to specify your own cd command. -- set `$_ZL_ECHO` to 1 to display new directory name after cd. +- set `$_ZL_ECHO` to 1 to display new directory name after cd. - set `$_ZL_MATCHMODE` to 1 to enable enhanced matching. ## Aging @@ -101,27 +101,27 @@ To z.lua, a directory that has low ranking but has been accessed recently will q z.lua has two different matching methods: 0 for default, 1 for enhanced: -### Default matching - -By default, z.lua uses default matching method similar to the original z.sh. Paths must be match all of the regexes in order. - -- cd to a directory contains foo: - - j foo - -- cd to a directory ends with foo: - - j foo$ - -- use multiple arguments: - - Assuming the following database: - - 30 /home/user/mail/inbox - 10 /home/user/work/inbox - - `"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`. - +### Default matching + +By default, z.lua uses default matching method similar to the original z.sh. Paths must be match all of the regexes in order. + +- cd to a directory contains foo: + + j foo + +- cd to a directory ends with foo: + + j foo$ + +- use multiple arguments: + + Assuming the following database: + + 30 /home/user/mail/inbox + 10 /home/user/work/inbox + + `"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`. + ### Enhanced matching Enhanced matching can be enabled by export the environment: @@ -129,13 +129,13 @@ Enhanced matching can be enabled by export the environment: export _ZL_MATCH_MODE=1 For a given set of queries (the set of command-line arguments passed to z.lua), a path is a match if and only if: - + 1. Queries match the path in order (same as default method). 2. The last query matches the last segment of the path. If no match is found, it will fall back to default matching method. -- match the last segment of the path: +- match the last segment of the path: Assuming the following database: @@ -148,7 +148,7 @@ If no match is found, it will fall back to default matching method. Since the last segment of a path is always easier to be recalled, it is sane to give it higher priority. You can also achieve this by typing `"z space$"` in both methods, but `"z wo"` is easier to type. -- cd to the existent path if there is no match: +- cd to the existent path if there is no match: Sometimes if you use: @@ -238,11 +238,11 @@ As you see, z.lua is the fastest one and requires less resource. Releated projects: -- [rupa/z](https://github.com/rupa/z): origin z.sh implementation -- [JannesMeyer/z.ps](https://github.com/JannesMeyer/z.ps): z for powershell - - -## License - -Licensed under MIT license. - +- [rupa/z](https://github.com/rupa/z): origin z.sh implementation +- [JannesMeyer/z.ps](https://github.com/JannesMeyer/z.ps): z for powershell + + +## License + +Licensed under MIT license. + From a0cfe629b8511a1d32812b0f1a318c2047275aa3 Mon Sep 17 00:00:00 2001 From: 0xC0FFEE Date: Thu, 17 Jan 2019 20:17:15 +0100 Subject: [PATCH 2/3] Remove trailing whitespace --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 84c84f0..326aaa5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ z - a better method to change directory. -An alternative to [z.sh](https://github.com/rupa/z) with windows and posix shells support and various improvements. +An alternative to [z.sh](https://github.com/rupa/z) with windows and posix shells support and various improvements. ## Description @@ -90,8 +90,8 @@ he rank of directories maintained by z.lua undergoes aging based on a sim-ple fo ## Frecency - -Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted rank that depends on how often and how recently something occurred. As far as I know, Mozilla came up with the term. + +Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted rank that depends on how often and how recently something occurred. As far as I know, Mozilla came up with the term. To z.lua, a directory that has low ranking but has been accessed recently will quickly have higher rank than a directory accessed frequently a long time ago. Frecency is determined at runtime. @@ -114,7 +114,7 @@ By default, z.lua uses default matching method similar to the original z.sh. Pat j foo$ - use multiple arguments: - + Assuming the following database: 30 /home/user/mail/inbox @@ -136,9 +136,9 @@ For a given set of queries (the set of command-line arguments passed to z.lua), If no match is found, it will fall back to default matching method. - match the last segment of the path: - + Assuming the following database: - + 10 /home/user/workspace 20 /home/user/workspace/project1 30 /home/user/workspace/project2 @@ -167,7 +167,7 @@ If no match is found, it will fall back to default matching method. 10 /Users/Great_Wall/.rbenv/versions/2.4.1/lib/ruby/gems 20 /Library/Ruby/Gems/2.0.0/gems - When I use `z gems` by default, it will take me to `/Library/Ruby/Gems/2.0.0/gems`, but it's not what I want, so I press up arrow and execute `z gems` again, it will take me to `/Users/Great_Wall/.rbenv/versions/2.4.1/lib/ruby/gems` and this what I want. + When I use `z gems` by default, it will take me to `/Library/Ruby/Gems/2.0.0/gems`, but it's not what I want, so I press up arrow and execute `z gems` again, it will take me to `/Users/Great_Wall/.rbenv/versions/2.4.1/lib/ruby/gems` and this what I want. Of course I can always use `z env gems` to indicate what I want precisely. Skip the current directory means when you use `z xxx` you always want to change directory instead of stay in the same directory and do nothing if current directory is the best match. @@ -176,7 +176,7 @@ The default matching method is designed to be compatible with original z.sh, but ## Add once -By default, z.lua will add current directory to database each time before display command prompt (correspond with z.sh). But there is an option to allow z.lua add path only if current working directory changed. +By default, z.lua will add current directory to database each time before display command prompt (correspond with z.sh). But there is an option to allow z.lua add path only if current working directory changed. To enable this, you can set `$_ZL_ADD_ONCE` to `1` before init z.lua. Or you can init z.lua on linux like this: From 02d3d836a1f680608575d570baa7a82b2ac9b39f Mon Sep 17 00:00:00 2001 From: 0xC0FFEE Date: Thu, 17 Jan 2019 20:17:20 +0100 Subject: [PATCH 3/3] Fix typos --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 326aaa5..2ea9750 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ z -i foo # cd with interactive selection ## Aging -he rank of directories maintained by z.lua undergoes aging based on a sim-ple formula. The rank of each entry is incremented every time it is accessed. When the sum of ranks is over 5000 (`$_ZL_MAXAGE`), all ranks are multiplied by 0.9. Entries with a rank lower than 1 are forgotten. +The rank of directories maintained by z.lua undergoes aging based on a sim-ple formula. The rank of each entry is incremented every time it is accessed. When the sum of ranks is over 5000 (`$_ZL_MAXAGE`), all ranks are multiplied by 0.9. Entries with a rank lower than 1 are forgotten. ## Frecency @@ -154,7 +154,7 @@ If no match is found, it will fall back to default matching method. z foo - And there is no mathing result in the database, but there is an existent directory which can be accessed with the name "foo" from current directory, "`z foo`" will just work as: + And there is no matching result in the database, but there is an existent directory which can be accessed with the name "foo" from current directory, "`z foo`" will just work as: cd foo @@ -190,7 +190,7 @@ It could be much faster on slow hardware or Cygwin/MSYS. ## Tips -Recommanded aliases you may find useful: +Recommended aliases you may find useful: ```bash alias zc='z -c' # restrict matches to subdirs of $PWD @@ -236,7 +236,7 @@ As you see, z.lua is the fastest one and requires less resource. ## Credit -Releated projects: +Related projects: - [rupa/z](https://github.com/rupa/z): origin z.sh implementation - [JannesMeyer/z.ps](https://github.com/JannesMeyer/z.ps): z for powershell