码农知识堂 - 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

  • 相关阅读:
    Git系列讲解 —— 提交日志(git log)的使用
    第一百四十四回 如何在页面中添加图片背景
    微信小程序开发的OA会议之会议个人中心的页面搭建及模板,自定义组件的学习
    python目录树生成器
    KKVIEW远程控制: 远程控制APP下载
    高并发面试:线程池的七大参数?手写一个线程池?
    热量传递总复习
    Java进阶-常用API
    《MySQL》数据类型与表操作
    酒店订房退房管理系统(数组应用)
  • 原文地址:https://blog.csdn.net/weixin_41819299/article/details/126943620
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号