下载incr地址:

https://mimosa-pudica.net/zsh-incremental.html

值得注意的是,该插件某些场景下比较卡顿,可以不设置为自动启动,在想用的时候通过:
source /incr所在目录/incr*.zsh

  • 事实上,我认为,shell自带的tab提示候选已经足够了,如果在配合轻量的autocomplete插件,则更加高效,但是incr虽然可以动态提示,但是开销较大,影响性能
  • incr插件本身不依赖于oh-my-zsh框架,只需要原始的zsh(zshell)就可以驱动该插件
  • 下载时,为了和oh my zsh 插件目录结构相适应,执行如下命令创建目录:
mkdir -p ~/.oh-my-zsh/plugins/incr/
cd ~/.oh-my-zsh/plugins/incr/
wget http://mimosa-pudica.net/src/incr-0.2.zsh   

启用脚本

source incr*.zsh

配置自启

设置自动启动incr动态提示插件:(设置永久有效,当然可以把添加的行注释掉以关闭它)
编辑.zshrc:

 vim ~/.zshrc   

在末尾添加一行:
(ctrl+G),o

source ~/.oh-my-zsh/plugins/incr/incr*.zsh

在这里插入图片描述
立即生效,执行

source ~/.zshrc

使配置生效.
在这里插入图片描述


reference link1:How Do I Enable Syntax Highlighting in ZSH
reference link2


> 高亮插件不依赖于oh My zsh

zsh-syntax-highlighting

下载(clone)插件到指定目录

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

在zshrc中注册该插件

Finally, add the zsh-syntax-highlighting as the plugin in your .zshrc file as:

plugins=( zsh-syntax-highlighting)

但是一般的,您的插件不只一个,可以写成如下形式

# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git
 # zsh-autosuggestions
  #其他插件...
  autojump
  zsh-syntax-highlighting
)

激活该配置,使插件生效

To apply the changes to your current terminal session, enter the command:

source ~/.oh-my-zsh/zshrc

zsh-autosuggestion

  • 过程和zsh-syntaxhighlith几乎一样

reference of auto-suggestions

  • How to Use ZSH Auto-suggestions (linuxhint.com)
    插件也不依赖于oh my zsh框架(仅依赖于zsh),但是可以整合到oh-my-zsh
  • 下载(克隆)
    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
    然后添加
# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git
 zsh-autosuggestions
  #其他插件...
  autojump
  zsh-syntax-highlighting
)

激活

cd ~
source .zhsrc

一键批量安装上述两个插件

!!! 执行下述脚本最好切换到bash执行(zsh下执行sed的某些指令可能会提示找不到sed!)

包括 zsh-autosuggestion
zsh-syntax-highlight

两个插件克隆成功可能需要多次尝试

成功后,执行一下代码配置和激活插件


# 将两个插件下载到指定目录下:(git 已经指定好了目录)
git clone https://gitee.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://gitee.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
#将工作目录转移到家目录
cd ~
path=.zshrc
sed '/(^plugins)/ s/^#*/#/;
/^#*plugins/ a\
plugins=(\
    git\
    zsh-syntax-highlighting\
    zsh-autosuggestions\
    # 注意,sed命令的后续不能换行\
)' -r -iE $path

source .zshrc

cd - 


附:加速/clone两个插件

将github换为gitee,提高clone成功率


git clone https://gitee.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://gitee.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐