ZSH的安装

ZSH的安装

zsh是一个功能强大的shell解释器

  1. 安装zsh

    • 安装zsh

      yum -y install zsh
      
    • 检查是否安装成功

      cat /etc/shells
      
      /bin/zsh
      
  2. 配置zsh

    配置很复杂,使用开源脚本进行配置

    这个是配置zsh的开源脚本的链接
    https://github.com/ohmyzsh/ohmyzsh
    
    • 准备一下

      yum -y install git
      
    • 自动配置

      sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
      #访问github不顺畅的话,可以用下面的命令,把链接地址替换成了可以正常的访问的网址(这个地址由该项目的作者提供)
      sh -c "$(curl -fsSL https://install.ohmyz.sh)" "" --unattended
      
    • 修改默认的shell解释器

      #root字段为用户名,此处给root用户修改shell解释器;如果是其他用户,在此填写该用户的用户名即可。
      chsh -s /bin/zsh root
      
  3. 修改提示符为随机主题

    • 修改~/.zshrc中的ZSH_THEME的值为random

      vim ~/.zshrc +11
      
      ZSH_THEME="random"
      
    • 通过zsh命令修改主题

      zsh
      zsh
      zsh
      zsh
      zsh
      zsh
      jb@localhost:~
      [oh-my-zsh] Random theme 'sammy' loaded
      ~$ 
      
    • 保存自己喜欢的主题

      将自己喜欢的主题名替换random即可

  4. 扩展使用zsh

    zsh支持使用插件扩充功能,待补充。

Q&A:有点小问题

  1. 为什么我使用chsh命令的时候,提示命令不存在?

    • 提示命令不存在

      #此处代码为伪代码
      命令:chsh -s /bin/zsh
      提示:command not found
      
    • 找到chsh命令的安装包

      #参考链接:https://forums.centos.org/viewtopic.php?t=73864
      #此处代码为论坛上的代码
      [root@centos8 ~]# dnf provides '*/chsh'
      Last metadata expiration check: 0:51:14 ago on Sat Mar 28 14:23:21 2020.
      util-linux-user-2.32.1-17.el8.x86_64 : libuser based util-linux utilities
      Repo : BaseOS
      Matched from:
      Filename : /etc/pam.d/chsh
      Filename : /usr/bin/chsh
      Filename : /usr/share/bash-completion/completions/chsh
      
    • 装包

      dnf -y install util-linux-user-2.32.1-17.el8.x86_64
      
    • 验证

      [jbb@localhost ~]$ chsh -s /bin/zsh
      Changing shell for jbb.
      
  2. 为什么安装完zsh提示没有配置文件?

    [jbb@localhost]~% zsh
    This is the Z Shell configuration function for new users,
    zsh-newuser-install.
    You are seeing this message because you have no zsh startup files
    (the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
    ~).  This function can help you with a few settings that should
    make your use of the shell easier.
    
    You can:
    
    (q)  Quit and do nothing.  The function will be run again next time.
    
    (0)  Exit, creating the file ~/.zshrc containing just a comment.
         That will prevent this function being run again.
    
    (1)  Continue to the main menu.
    
    --- Type one of the keys in parentheses --- 
    
    q 退出(下次使用zsh还有这个告警)
    0 创建一个空的配置文件(用于取消该告警)
    1 手动配置各种参数
    

    出现该告警就是因为没有配置zsh的配置文件,需要自己配置一下。建议用脚本配置sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended

  3. root安装的zsh,普通用户可以用吗?

    • 普通用户使用zsh
    1. 添加用户
      useradd 用户名
      passwd 密码
      密码
    2. 切换终端(必须使用新创建的用户重新登录)
    3. 更改默认shell解释器
      chsh -s /bin/zsh
    4. 配置zsh
    #sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended
    
    sh -c "$(curl -fsSL https://install.ohmyz.sh)" "" --unattended
    
    • 第二步,未切换终端告警如下(不知道为啥,希望有缘人解答,可以指明是哪一部分的知识更好)

      [jbb@localhost]/root% sh -c "$(curl -fsSL https://install.ohmyz.sh)" "" --unattended
      Cloning Oh My Zsh...
      fatal: cannot mkdir /root/.oh-my-zsh: Permission denied
      Error: git clone of oh-my-zsh repo failed
      
      [jbb@localhost]/root% sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/ma
      ster/tools/install.sh)" --unattended
      curl: (56) OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104
      
      
  • 6
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值