zsh 弄乱了新行 and/or 输入回显
zsh messing up new-line and/or input echoing
(编辑):下面的描述是两个不相关的行为:一个行为符合预期,另一个是与 zsh
相关的实际问题。 zsh
.
中没有换行回归
我已经从 OSX (Catalina) 的 bash
迁移到 zsh
。我也用oh-my-zsh
。我最近注意到换行符或输入的回声有时会丢失。我至少发现了两种情况:
- 使用
time
:(第一次调用使用 /bin/zsh
)
~
▶ time ls
1pwd.bkp Downloads Pictures 'VirtualBox VMs' go pf-docs.txt tools
Applications Library Public bin istio-lean.yaml plugins.sbt.bkp wip
Desktop Movies SWIFT docs.txt main.txt project workshop
Documents Music Snapshots git normal.yml todo
gls --color=tty 0.00s user 0.00s system 62% cpu 0.009 total
~
▶ /bin/sh
# time ls
1pwd.bkp Downloads Pictures VirtualBox VMs go pf-docs.txt tools
Applications Library Public bin istio-lean.yaml plugins.sbt.bkp wip
Desktop Movies SWIFT docs.txt main.txt project workshop
Documents Music Snapshots git normal.yml todo
real 0m0.011s
user 0m0.003s
sys 0m0.005s
#
- 使用
sbt
/g8
:(第一次调用使用 /bin/zsh
)
~/wip/deleteme
▶ sbt new scala/scala-seed.g8
[info] Loading settings for project global-plugins from build.sbt ...
[info] Loading global plugins from /Users/ignasi/.sbt/1.0/plugins
[info] Set current project to deleteme (in build file:/Users/ignasi/wip/deleteme/)
[info] Set current project to deleteme (in build file:/Users/ignasi/wip/deleteme/)
A minimal Scala project.
name [Scala Seed Project]:
Template applied in /Users/ignasi/wip/deleteme/./myprojectzsh
~/wip/deleteme
▶ /bin/sh
sh: _direnv_hook: command not found
%n@%m %1~ %# sbt new scala/scala-seed.g8
[info] Loading settings for project global-plugins from build.sbt ...
[info] Loading global plugins from /Users/ignasi/.sbt/1.0/plugins
[info] Set current project to deleteme (in build file:/Users/ignasi/wip/deleteme/)
[info] Set current project to deleteme (in build file:/Users/ignasi/wip/deleteme/)
A minimal Scala project.
name [Scala Seed Project]: MyProjectBinSh
Template applied in /Users/ignasi/wip/deleteme/./myprojectbinsh
# ls
请注意 /bin/zsh
下的调用如何在 name [...]:
:
之后不回显用户输入 (myprojectzsh
)
name [Scala Seed Project]:
Template applied in /Users/ignasi/wip/deleteme/./myprojectzsh
甚至缺少一个空白换行符。
我还没有排除问题实际上是 time
和 sbt
/g8
中的两个不同问题,它们恰好具有相同的症状。
PS:当我在 /bin/zsh
中尝试 time echo hello
时,事情变得有点奇怪:
▶ time echo hello
hello
~
▶
time
报告甚至没有打印 (?)。
1 中没有任何问题。time
是 zsh(以及 bash)中的内置 shell 命令。你可以自己查一下
which time
zsh time 的行为和输出风格与 bash 中的不同。您可以 运行 "real" time
: /usr/bin/time command
的二进制实现,看看它会产生另一种不同格式的输出。
另外,time echo hello
没有输出的原因是在 zsh 中 time
对 echo 等内置命令没有影响。如果你真的想要,你可以通过使用括号 time (echo hello)
来强制执行 subshell,但最终这没有任何意义——你正在测量 subshell 的时间生活,而不是回声本身。
(编辑):下面的描述是两个不相关的行为:一个行为符合预期,另一个是与 zsh
相关的实际问题。 zsh
.
我已经从 OSX (Catalina) 的 bash
迁移到 zsh
。我也用oh-my-zsh
。我最近注意到换行符或输入的回声有时会丢失。我至少发现了两种情况:
- 使用
time
:(第一次调用使用/bin/zsh
)
~
▶ time ls
1pwd.bkp Downloads Pictures 'VirtualBox VMs' go pf-docs.txt tools
Applications Library Public bin istio-lean.yaml plugins.sbt.bkp wip
Desktop Movies SWIFT docs.txt main.txt project workshop
Documents Music Snapshots git normal.yml todo
gls --color=tty 0.00s user 0.00s system 62% cpu 0.009 total
~
▶ /bin/sh
# time ls
1pwd.bkp Downloads Pictures VirtualBox VMs go pf-docs.txt tools
Applications Library Public bin istio-lean.yaml plugins.sbt.bkp wip
Desktop Movies SWIFT docs.txt main.txt project workshop
Documents Music Snapshots git normal.yml todo
real 0m0.011s
user 0m0.003s
sys 0m0.005s
#
- 使用
sbt
/g8
:(第一次调用使用/bin/zsh
)
~/wip/deleteme
▶ sbt new scala/scala-seed.g8
[info] Loading settings for project global-plugins from build.sbt ...
[info] Loading global plugins from /Users/ignasi/.sbt/1.0/plugins
[info] Set current project to deleteme (in build file:/Users/ignasi/wip/deleteme/)
[info] Set current project to deleteme (in build file:/Users/ignasi/wip/deleteme/)
A minimal Scala project.
name [Scala Seed Project]:
Template applied in /Users/ignasi/wip/deleteme/./myprojectzsh
~/wip/deleteme
▶ /bin/sh
sh: _direnv_hook: command not found
%n@%m %1~ %# sbt new scala/scala-seed.g8
[info] Loading settings for project global-plugins from build.sbt ...
[info] Loading global plugins from /Users/ignasi/.sbt/1.0/plugins
[info] Set current project to deleteme (in build file:/Users/ignasi/wip/deleteme/)
[info] Set current project to deleteme (in build file:/Users/ignasi/wip/deleteme/)
A minimal Scala project.
name [Scala Seed Project]: MyProjectBinSh
Template applied in /Users/ignasi/wip/deleteme/./myprojectbinsh
# ls
请注意 /bin/zsh
下的调用如何在 name [...]:
:
myprojectzsh
)
name [Scala Seed Project]:
Template applied in /Users/ignasi/wip/deleteme/./myprojectzsh
甚至缺少一个空白换行符。
我还没有排除问题实际上是 time
和 sbt
/g8
中的两个不同问题,它们恰好具有相同的症状。
PS:当我在 /bin/zsh
中尝试 time echo hello
时,事情变得有点奇怪:
▶ time echo hello
hello
~
▶
time
报告甚至没有打印 (?)。
1 中没有任何问题。time
是 zsh(以及 bash)中的内置 shell 命令。你可以自己查一下
which time
zsh time 的行为和输出风格与 bash 中的不同。您可以 运行 "real" time
: /usr/bin/time command
的二进制实现,看看它会产生另一种不同格式的输出。
另外,time echo hello
没有输出的原因是在 zsh 中 time
对 echo 等内置命令没有影响。如果你真的想要,你可以通过使用括号 time (echo hello)
来强制执行 subshell,但最终这没有任何意义——你正在测量 subshell 的时间生活,而不是回声本身。