是否有一个 zsh 脚本可以让我用反斜杠自动完成空格?例如:
假设有一个名为“我的文件夹”的文件夹,中间有一个空格。如果我想进去,我
cd My\ folder
但是,我想要一种输入方式
cd My folder
zsh 会自动知道要放一个反斜杠,所以我不必这样做。
答案有点晚了,但这应该可以让你做你想做的事情,并保留命令的正常行为,如果没有给出目录cd
,还可以带你到你的目录。~
添加到您的~/.zshrc
文件中:
function cd() {
new_directory="$*";
if [ $# -eq 0 ]; then
new_directory=${HOME};
fi;
builtin cd "${new_directory}"
}
但是,您的 ZSH 应该内置自动完成功能,在这种情况下,您可以输入您尝试 cd 进入的目录的前几个字母,然后点击tab它应该完成目录名称或提供目录列表(如果有多个)火柴。
You could Make an alias with "Myfolder" and run that in a zsh script.
alias -g "Myfolder"="My\ folder" ---> cd Myfolder
I don't know if there is a way to make it possible with having the space in between the words. If it has to be my "My folder" then I don't know that I can help you.