Oh My Zsh 离线安装

[TOC]

离线安装 zsh

下载oh-my-zsh ZIP安装包

离线安装 oh my zsh

  • 已有ZIP压缩包文件

    1
    2
    3
    4
    ohmyzsh-master.zip
    zsh-autosuggestions-master.zip
    zsh-syntax-highlighting-master.zip
    zsh-history-substring-search-master.zip
  • 解压

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    unzip ohmyzsh-master.zip -d ./
    mv ohmyzsh-master ~/.oh-my-zsh

    unzip zsh-autosuggestions-master.zip -d ./
    mv zsh-autosuggestions-master ~/.oh-my-zsh/plugins/zsh-autosuggestions

    unzip zsh-syntax-highlighting-master.zip -d ./
    mv zsh-syntax-highlighting-master ~/.oh-my-zsh/plugins/zsh-syntax-highlighting

    unzip zsh-history-substring-search-master.zip -d ./
    mv zsh-history-substring-search-master ~/.oh-my-zsh/plugins/zsh-history-substring-search

    cd .oh-my-zsh/plugins/
    mkdir incr # 放 incr-0.2.zsh
    vim ~/.zshrc # 添加 source ~/.oh-my-zsh/plugins/incr/incr*.zsh
    source ~/.zshrc
  • 修改安装脚本文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    cd ~/.oh-my-zsh/tools
    cp install.sh install.sh.back # 备份安装脚本
    vim install.sh
    # 删除或者注释掉 setup_ohmyzsh() 函数,第91行~第123行
    # 删除或者注释调用 setup_ohmyzsh 函数的地方,第263行~第290行

    263 if ! command_exists zsh; then
    264 echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first."
    265 exit 1
    266 fi
    267
    268 if [ -d "$ZSH" ]; then
    269 echo "${YELLOW}The \$ZSH folder already exists ($ZSH).${RESET}"
    270 if [ "$custom_zsh" = yes ]; then
    271 cat <<EOF
    272
    273 You ran the installer with the \$ZSH setting or the \$ZSH variable is
    274 exported. You have 3 options:
    275
    276 1. Unset the ZSH variable when calling the installer:
    277 $(fmt_code "ZSH= sh install.sh")
    278 2. Install Oh My Zsh to a directory that doesn't exist yet:
    279 $(fmt_code "ZSH=path/to/new/ohmyzsh/folder sh install.sh")
    280 3. (Caution) If the folder doesn't contain important information,
    281 you can just remove it with $(fmt_code "rm -r $ZSH")
    282
    283 EOF
    284 else
    285 echo "You'll need to remove it if you want to reinstall."
    286 fi
    287 exit 1
    288 fi
    289
    290 setup_ohmyzsh
  • 最后执行安装:sh install.sh,然后输入:y,成功

配置

  • 编辑:vim ~/.zshrc

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # 推荐默认主题:robbyrussell 或者 agnoster
    ZSH_THEME="agnoster"

    plugins=(
    git
    zsh-autosuggestions
    zsh-syntax-highlighting
    zsh-history-substring-search
    vscode
    z
    extract)
  • 刷新:source ~/.zshrc

agnoster 主题乱码

  • Ubuntu、VsCode 显示乱码,原因是未配置Powerline字体
  • agnoster主题下面有备注官网:https://github.com/powerline/fonts
    1
    2
    3
    4
    5
    6
    7
    8
    9
    # Ubuntu
    sudo apt-get install fonts-powerline

    # VsCode
    # 打开设置,搜索字体,在控制字体系列里添加
    'PowerlineSymbols'

    # 或者直接打开 setting.json 文件,作如下修改
    "editor.fontFamily": "'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback', 'PowerlineSymbols'"

参考

坚持原创技术分享,您的支持将鼓励我继续创作!
0%