码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • Oh my zsh


         被命令行自动补齐功能吸引,在编辑指令的时候,对于之前使用过的指令,按→即可快速补全。

    下文详细讲述如何搭建环境及安装插件,以及存在防火墙的情况下如何手动安装操作。

    • 查看linux或Mac支持哪些shell,是否包含zsh,如不包含需另外安装
    cat /etc/shells

    输出:

    /bin/bash

    /bin/csh

    /bin/dash

    /bin/ksh

    /bin/sh

    /bin/tcsh

    /bin/zsh

    • 设置当前默认shell,需重新打开终端或新建一个窗口
    1. chsh -s /bin/bash 
    2. chsh -s /bin/zsh 
    • 安装oh-my-zsh
    sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

    参考的是以下网址,亲测mac上安装无误,安装好后终端就变彩色了

    Oh My Zsh, 『 安装 & 配置 』 - 知乎

    • 手动安装oh my zsh

    wget、curl一把安装好固然好,但在办公网络下,由于防火墙的存在或其他限制,可能需要手动下载,手动安装,这就比较头痛了,需要手动下载2个组件,修改安装sh文件,再手动执行。

    1.下载install.sh文件

    https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh

    2.下载oh my zsh 代码库

    GitHub - ohmyzsh/ohmyzsh: 🙃 A delightful community-driven (with 2,000+ contributors) framework for managing your zsh configuration. Includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc), 140+ themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.

    3.vim install.sh

    由于公司防火墙等原因,直接执行sh文件clone oh my zsh 代码库会报错"Error: git clone of oh-my-zsh repo failed"

    修改clone部分为 cp本地已下载的文件,相关代码在Manual clone with git config options to support git < v1.7.2处

    修改为: 

    1. # Manual clone with git config options to support git < v1.7.2
    2. git init --quiet "$ZSH" && cd "$ZSH" \
    3. && git config core.eol lf \
    4. && git config core.autocrlf false \
    5. && git config fsck.zeroPaddedFilemode ignore \
    6. && git config fetch.fsck.zeroPaddedFilemode ignore \
    7. && git config receive.fsck.zeroPaddedFilemode ignore \
    8. && git config oh-my-zsh.remote origin \
    9. && git config oh-my-zsh.branch "$BRANCH" \
    10. # && git remote add origin "$REMOTE" \
    11. # && git fetch --depth=1 origin \
    12. # && git checkout -b "$BRANCH" "origin/$BRANCH" || {
    13. # [ ! -d "$ZSH" ] || {
    14. # cd -
    15. # rm -rf "$ZSH" 2>/dev/null
    16. # }
    17. # fmt_error "git clone of oh-my-zsh repo failed"
    18. # exit 1
    19. # }
    20. # Exit installation directory
    21. cp -R /Users/myname/Downloads/ohmyzsh_install/ohmyzsh-master/* /Users/myname/.oh-my-zsh
    22. cd -
    23. #
    24. echo
    25. }

    4.执行安装

    ./install.sh

    • 查看zsh配置文件

    vim ~/.zshrc

    查看主题 ZSH_THEME

    查看插件plugins

    • 增加插件 

    zsh-syntax-highlighting 高亮插件,可用于检查命令是否输入正确

    zsh-autosuggestions 自动补全插件,可记住过往命令

    1.修改配置

    vim ~/.zshrc

    修改为plugins=(git zsh-syntax-highlighting zsh-autosuggestions)

    2.安装插件

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

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

            如不能git clone,手动下载后mv到对应路径下

    ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

    ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting

    3.更新配置,使之立刻起效

    source ~/.zshrc 

    参考oh-my-zsh 国内安装及配置_菜饼同学的博客-CSDN博客_ohmyzsh国内

    • 安装第三方自动补齐插件

    incr 目录提示和补全插件

    下载插件

    wget http://mimosa-pudica.net/src/incr-0.2.zsh 

    将第三方插件放在插件目录库路径下

    1. mkdir ~/.oh-my-zsh/plugins/incr
    2. cd ~/.oh-my-zsh/plugins/incr
    3. mv /Users/XXX/incr-0.2.zsh ./
    4. vim ~/.zshrc
    5. # 末尾加上 source ~/.oh-my-zsh/plugins/incr/incr*.zsh
    6. # 更新配置
    7. source ~/.zshrc

  • 相关阅读:
    基于微信小程序的医院门诊体检预约管理系统设计与实现(源码+lw+部署文档+讲解等)
    Vue权限控制
    浅谈泛型擦除
    OpenShift 4 - 定制 RHACS 安全策略,阻断生产集群使用高风险 Registry
    Python 运算符重载Demo
    React技术栈 --》plugin与JSX语法使用 ## Day2
    使用Docker中部署GitLab 避坑指南
    而今迈步从头越|nacos逼我在mac上重新安装java8与环境变量的配置
    css美化滚动条
    「Python实用秘技15」pandas中基于范围条件进行表连接
  • 原文地址:https://blog.csdn.net/weixin_41819299/article/details/126943620
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号