From 501f619f94ff6547703c796b0cbfda15f50f90dc Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Mon, 15 Feb 2021 00:02:23 +0800 Subject: [PATCH] improve powershell 7 compatibility --- README.cn.md | 7 ++++++- README.md | 25 +++++++++++++++++++------ z.lua | 5 +++-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/README.cn.md b/README.cn.md index 18c56da..f092d02 100644 --- a/README.cn.md +++ b/README.cn.md @@ -65,7 +65,12 @@ z -b foo # 跳转到父目录中名称以 foo 开头的那一级 antigen bundle skywind3000/z.lua 就可以了(主要要放在 antigen apply 语句之前)。 + + **注意**:使用 WSL-1 的用户,需要安装 `lua-filesystem` 包: + + sudo apt-get install lua-filesystem + 这是由于 wsl-1 的 [bug](https://github.com/microsoft/WSL/issues/5505) 引起的,使用 lua-filesystem 可以避免该问题。 - Fish Shell: @@ -83,7 +88,7 @@ z -b foo # 跳转到父目录中名称以 foo 开头的那一级 在你 Power Shell 的配置文件 `profile.ps1` 中放入下面语句: - iex ($(lua /path/to/z.lua --init powershell) -join "`n") + Invoke-Expression (& { (lua /path/to/z.lua --init powershell) -join "`n" }) - Windows cmd (with clink): diff --git a/README.md b/README.md index ba67e05..0016f9b 100644 --- a/README.md +++ b/README.md @@ -69,13 +69,19 @@ z -b foo # cd to the parent directory starting with foo and perhaps this: - export _ZL_ECHO=1 + eval "$(lua /path/to/z.lua --init bash enhanced once echo)" if you want `z.lua` print the new directory after cd. - If you want `fzf` tab completion use: + For `fzf` tab completion use: eval "$(lua /path/to/z.lua --init bash enhanced once fzf)" + + **NOTE**: For wsl-1 users, `lua-filesystem` must be installed: + + sudo apt-get install lua-filesystem + + To avoid a wsl-1 [defect](https://github.com/microsoft/WSL/issues/5505). - Zsh: @@ -85,6 +91,8 @@ z -b foo # cd to the parent directory starting with foo Options like "enhanced" and "once" can be used after `--init` too. It can also be initialized from "skywind3000/z.lua" with your zsh plugin managers (antigen / oh-my-zsh). + **NOTE**: for wsl-1 users, `lua-filesystem` must be installed. + - Posix Shells: put something like this in your `.profile`: @@ -113,21 +121,26 @@ z -b foo # cd to the parent directory starting with foo put something like this in your `profile.ps1`: - iex ($(lua /path/to/z.lua --init powershell) -join "`n") - + Invoke-Expression (& { (lua /path/to/z.lua --init powershell) -join "`n" }) - Windows cmd (with clink): - - copy z.lua and z.cmd to clink's home directory + - 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: - - copy z.lua and z.cmd to cmder/vendor + - Copy z.lua and z.cmd to cmder/vendor - Add cmder/vendor to `%PATH%` - Ensure that "lua" can be called in `%PATH%` +- Windows WSL-1: + + - Install `lua-filesystem` module. + - Initialize z.lua as in Linux. + + ## Options diff --git a/z.lua b/z.lua index e95bbf1..7bc42fc 100755 --- a/z.lua +++ b/z.lua @@ -4,7 +4,7 @@ -- z.lua - a cd command that learns, by skywind 2018, 2019, 2020 -- Licensed under MIT license. -- --- Version 1.8.11, Last Modified: 2020/12/31 02:05 +-- Version 1.8.12, Last Modified: 2020/12/31 02:05 -- -- * 10x faster than fasd and autojump, 3x faster than z.sh -- * available for posix shells: bash, zsh, sh, ash, dash, busybox @@ -51,7 +51,8 @@ -- Power Shell Install: -- -- * put something like this in your config file: --- iex ($(lua /path/to/z.lua --init powershell) -join "`n") +-- Invoke-Expression (& { +-- (lua /path/to/z.lua --init powershell) -join "`n" }) -- -- Windows Install (with Clink): -- * copy z.lua and z.cmd to clink's home directory