我正在压缩大约 1.3 GB 的文件夹,每个文件夹都包含 1440 个 JSON 文件,发现在 macOS 或Raspbian 10 (Buster)上使用tar命令和 Python 的内置tarfile库之间存在 15 倍的差异
此脚本比较了两种方法:
#!/usr/bin/env python3
from pathlib import Path
from subprocess import call
import tarfile
fullpath = Path("/Users/user/Desktop/temp/tar/2021-03-11")
zsh_out = Path(fullpath.parent, "zsh-archive.tar.xz")
py_out = Path(fullpath.parent, "py-archive.tar.xz")
# tar using terminal
# tar cJf zsh-archive.tar.xz folderpath
call(["tar", "cJf", zsh_out, fullpath])
# tar using tarfile library
with tarfile.open(py_out, "w:xz") as tar:
tar.add(fullpath, arcname=fullpath.stem)
# Print filesizes
print(f"zsh tar filesize: {round(Path(zsh_out).stat().st_size/(1024*1024), 2)} …Run Code Online (Sandbox Code Playgroud) 我刚刚在我的 Ubuntu 系统上安装了 zsh。似乎 zsh 没有在 init 上执行 ~/.profile 。据我所知,这应该是一种自动行为。我错过了什么?
在新设置中,tmux 使用 bash 而不是我的默认设置 (zsh)。
如何强制它使用 zsh?
重新启动后,我开始在加载 shell 时看到一条消息:
zsh: corrupt history file /home/myusername/.zsh_history
Run Code Online (Sandbox Code Playgroud)
我如何才能从这种情况中恢复并可能恢复一些历史记录?
使用像 bash 或 zshell 这样的 shell,如何进行递归的“查找和替换”?换句话说,我想在这个目录及其子目录中的所有文件中用 'bar' 替换每次出现的 'foo'。
我正在使用 iTerm 并想使用Oh My ZSH自定义终端窗口的外观!. 根据文档,我需要更改~/.zshrc文件并添加一个ZSH_THEME值:
找到要使用的主题后,您需要编辑该
~/.zshrc文件。您会在其中看到一个环境变量(全部大写),如下所示:Run Code Online (Sandbox Code Playgroud)ZSH_THEME="robbyrussell"
问题是我不知道在哪里可以找到~/.zshrc文件。
ZSH 从创建一个新的终端窗口到准备好大约需要一秒钟半的时间。我很确定罪魁祸首是compinit.
我一直没能找到好的文档,compinit,但看起来它应该在一些文件中缓存所有必要的东西,比如.zcompdump.
有什么加速的技巧吗?
我最近从 bash 切换到 zsh。在 bash 中,我用来查找以前运行的命令的一种方法(除了递归搜索)是history | grep whatever,whatever我记得的命令位在哪里。
在 zsh 中,这不起作用。history尽管我的.zsh_history文件包含许多条目,但我已将其配置为执行此操作,但仅返回少数项目。
如何输出我的整个历史,适合搜索grep?
当我通过 zsh 尝试 scp 时,我得到
scp hostA:Descargas/debian-6.0.4-* user@192.168.1.154:Escritorio/Software/
zsh: no matches found: hostA:Descargas/debian-6.0.4-*
Run Code Online (Sandbox Code Playgroud)
相同的命令在 bash 中工作
我对 bash 很满意,但最近我换了一个我不知道的替代品。
<(command)bash究竟是什么?它与=(command)zsh中的相比如何?
我知道这与默认文件描述符有关。在我的电脑里
echo <()
Run Code Online (Sandbox Code Playgroud)
Returns /proc/self/fd/11,我发现它是脚本 STDOUT 的副本,但这对我来说似乎仍然很混乱。