第一个选项卡完成增强
First tab completion enhancement
自定义 zsh allows you to simply hit the tab key and let you cycle through directories. See this answer。
这是一项了不起的工作流程改进,但我需要以下方面的帮助:
我怎样才能实现 zsh tab 补全将显示所有文件和文件夹并让我循环浏览它们? (实际上它只在没有更多目录可更改时才显示文件。)
In addition, it would be very useful, that it will not put "cd" in front of the completion when the choice is a file and not a folder.
(我使用系统 mime 从终端打开文件。)
谢谢。
稍微修改the answer here:
function complete_pwd_items_on_empty_buffer
{
if [[ -z $BUFFER ]]; then
BUFFER="./"
CURSOR=2
zle list-choices
else
zle expand-or-complete
fi
}
zle -N complete_pwd_items_on_empty_buffer
bindkey '^I' complete_pwd_items_on_empty_buffer
如果命令行为空并且您按 TAB 键,这将插入 ./
并列出可执行文件或目录。您可以通过这种方式在当前目录树中执行可执行文件,或者如果您设置了 AUTO_CD
选项,则可以通过这种方式 cd
进入子目录。
事实上,我们可以通过在仅包含空格的命令行上启用此技巧来做得更好:
function complete_pwd_items_on_empty_buffer
{
if [[ $BUFFER =~ ^[[:space:]]*$ ]]; then
BUFFER+="./"
CURSOR+=2
zle list-choices
else
zle expand-or-complete
fi
}
zle -N complete_pwd_items_on_empty_buffer
bindkey '^I' complete_pwd_items_on_empty_buffer
自定义 zsh allows you to simply hit the tab key and let you cycle through directories. See this answer。
这是一项了不起的工作流程改进,但我需要以下方面的帮助:
我怎样才能实现 zsh tab 补全将显示所有文件和文件夹并让我循环浏览它们? (实际上它只在没有更多目录可更改时才显示文件。)
In addition, it would be very useful, that it will not put "cd" in front of the completion when the choice is a file and not a folder.
(我使用系统 mime 从终端打开文件。)
谢谢。
稍微修改the answer here:
function complete_pwd_items_on_empty_buffer
{
if [[ -z $BUFFER ]]; then
BUFFER="./"
CURSOR=2
zle list-choices
else
zle expand-or-complete
fi
}
zle -N complete_pwd_items_on_empty_buffer
bindkey '^I' complete_pwd_items_on_empty_buffer
如果命令行为空并且您按 TAB 键,这将插入 ./
并列出可执行文件或目录。您可以通过这种方式在当前目录树中执行可执行文件,或者如果您设置了 AUTO_CD
选项,则可以通过这种方式 cd
进入子目录。
事实上,我们可以通过在仅包含空格的命令行上启用此技巧来做得更好:
function complete_pwd_items_on_empty_buffer
{
if [[ $BUFFER =~ ^[[:space:]]*$ ]]; then
BUFFER+="./"
CURSOR+=2
zle list-choices
else
zle expand-or-complete
fi
}
zle -N complete_pwd_items_on_empty_buffer
bindkey '^I' complete_pwd_items_on_empty_buffer