热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

[Ubuntu20]安装zsh,ohmyzsh并配置

文章目录安装zsh安装git安装oh-my-zsh(轻量级配置zsh的开源软件)下载zsh-syntax-highlighting语法高亮插件下载zsh


文章目录

  • 安装zsh
  • 安装git
  • 安装oh-my-zsh(轻量级配置zsh的开源软件)
  • 下载 zsh-syntax-highlighting 语法高亮插件
  • 下载 zsh-autosuggestions 自动提示插件
  • 修改用户默认shell
  • oh-my-zsh更换位置
  • 修改zsh配置文件
  • 设置别名或环境变量


安装zsh

sudo apt-get install zsh

安装git

sudo apt-get install git

安装oh-my-zsh(轻量级配置zsh的开源软件)

以下三种方式任选其一


  1. 通过在github上的脚本安装

    sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

  2. 访问github如果有困难可以访问gitee的镜像

    sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

  3. 服务器实在不行可以先想办法下载下来install.sh,上传到服务器中,可以通过ftp或者其他方法。这里我推荐lrzsz,使用xshell直接拖入就可以
    安装lrzsz

    sudo apt-get install lrzsz

    chmod 775 install.sh
    ./install.sh

至此oh-my-zsh就安装完了


下载 zsh-syntax-highlighting 语法高亮插件

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

下载 zsh-autosuggestions 自动提示插件

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

修改用户默认shell

vim /etc/passwd

找到用户那一行

user:x:1000:1000:user:/home/user:/bin/bash

/bin/bash 是用户默认shell
修改为/usr/bin/zsh


oh-my-zsh更换位置

oh-my-zsh默认会安装到

~/.oh-my-zsh

如果想其他用户一起使用,可以放到一个公共的位置,比如

/usr/local/

可以用以下命令更换位置

mv ~/.oh-my-zsh /usr/local/.oh-my-zsh

修改zsh配置文件

vim ~/.zshrc
修改.oh-my-zsh位置

export ZSH="/usr/local/.oh-my-zsh"

修改主题

ZSH_THEME="ys"

设置别名或环境变量

之前在bash中的别名或环境变量可以加在~/.zshrc底部
在这里记录/分享我常用的环境变量

alias tailf='tail -f'
alias dc='docker-compose'
alias ll='ls -alh'#Rebind HOME and END to do the decent thing:
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
case $TERM in (xterm*)
bindkey '\eOH' beginning-of-line
bindkey '\eOF' end-of-line
esac#To discover what keycode is being sent, hit ^v
#and then the key you want to test.#And DEL too, as well as PGDN and insert:
bindkey '\e[3~' delete-char
bindkey '\e[6~' end-of-history
bindkey '\e[2~' redisplay#Now bind pgup to paste the last word of the last command,
bindkey '\e[5~' insert-last-word

参考
https://blog.csdn.net/dinofish/article/details/104452908/
https://zhuanlan.zhihu.com/p/27052046


推荐阅读
author-avatar
2cz2x
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有