Skip to content

Commit

Permalink
improve powershell 7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
skywind3000 committed Feb 14, 2021
1 parent 7a8acd4 commit 501f619
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
7 changes: 6 additions & 1 deletion README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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):
Expand Down
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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`:
Expand Down Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions z.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 501f619

Please sign in to comment.