Skip to content

Commit 501f619

Browse files
author
skywind3000
committed
improve powershell 7 compatibility
1 parent 7a8acd4 commit 501f619

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

README.cn.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ z -b foo # 跳转到父目录中名称以 foo 开头的那一级
6565
antigen bundle skywind3000/z.lua
6666

6767
就可以了(主要要放在 antigen apply 语句之前)。
68+
69+
**注意**:使用 WSL-1 的用户,需要安装 `lua-filesystem` 包:
70+
71+
sudo apt-get install lua-filesystem
6872

73+
这是由于 wsl-1 的 [bug](https://github.com/microsoft/WSL/issues/5505) 引起的,使用 lua-filesystem 可以避免该问题。
6974

7075
- Fish Shell:
7176

@@ -83,7 +88,7 @@ z -b foo # 跳转到父目录中名称以 foo 开头的那一级
8388

8489
在你 Power Shell 的配置文件 `profile.ps1` 中放入下面语句:
8590

86-
iex ($(lua /path/to/z.lua --init powershell) -join "`n")
91+
Invoke-Expression (& { (lua /path/to/z.lua --init powershell) -join "`n" })
8792

8893

8994
- Windows cmd (with clink):

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,19 @@ z -b foo # cd to the parent directory starting with foo
6969

7070
and perhaps this:
7171

72-
export _ZL_ECHO=1
72+
eval "$(lua /path/to/z.lua --init bash enhanced once echo)"
7373

7474
if you want `z.lua` print the new directory after cd.
7575

76-
If you want `fzf` tab completion use:
76+
For `fzf` tab completion use:
7777

7878
eval "$(lua /path/to/z.lua --init bash enhanced once fzf)"
79+
80+
**NOTE**: For wsl-1 users, `lua-filesystem` must be installed:
81+
82+
sudo apt-get install lua-filesystem
83+
84+
To avoid a wsl-1 [defect](https://github.com/microsoft/WSL/issues/5505).
7985

8086
- Zsh:
8187

@@ -85,6 +91,8 @@ z -b foo # cd to the parent directory starting with foo
8591

8692
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).
8793

94+
**NOTE**: for wsl-1 users, `lua-filesystem` must be installed.
95+
8896
- Posix Shells:
8997

9098
put something like this in your `.profile`:
@@ -113,21 +121,26 @@ z -b foo # cd to the parent directory starting with foo
113121

114122
put something like this in your `profile.ps1`:
115123

116-
iex ($(lua /path/to/z.lua --init powershell) -join "`n")
117-
124+
Invoke-Expression (& { (lua /path/to/z.lua --init powershell) -join "`n" })
118125

119126
- Windows cmd (with clink):
120127

121-
- copy z.lua and z.cmd to clink's home directory
128+
- Copy z.lua and z.cmd to clink's home directory
122129
- Add clink's home to `%PATH%` (z.cmd can be called anywhere)
123130
- Ensure that "lua" can be called in `%PATH%`
124131

125132
- Windows cmder:
126133

127-
- copy z.lua and z.cmd to cmder/vendor
134+
- Copy z.lua and z.cmd to cmder/vendor
128135
- Add cmder/vendor to `%PATH%`
129136
- Ensure that "lua" can be called in `%PATH%`
130137

138+
- Windows WSL-1:
139+
140+
- Install `lua-filesystem` module.
141+
- Initialize z.lua as in Linux.
142+
143+
131144

132145
## Options
133146

z.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- z.lua - a cd command that learns, by skywind 2018, 2019, 2020
55
-- Licensed under MIT license.
66
--
7-
-- Version 1.8.11, Last Modified: 2020/12/31 02:05
7+
-- Version 1.8.12, Last Modified: 2020/12/31 02:05
88
--
99
-- * 10x faster than fasd and autojump, 3x faster than z.sh
1010
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
@@ -51,7 +51,8 @@
5151
-- Power Shell Install:
5252
--
5353
-- * put something like this in your config file:
54-
-- iex ($(lua /path/to/z.lua --init powershell) -join "`n")
54+
-- Invoke-Expression (& {
55+
-- (lua /path/to/z.lua --init powershell) -join "`n" })
5556
--
5657
-- Windows Install (with Clink):
5758
-- * copy z.lua and z.cmd to clink's home directory

0 commit comments

Comments
 (0)