首页
Javascript
Html
Css
Node.js
Electron
移动开发
小程序
工具类
服务端
浏览器相关
前端收藏
其他
关于
公司注册

linux CentOS 安装oh my Zsh

2018年12月20日 发布 阅读(5633) 作者:Jerman

linux 默认bash shell是这样

想变的酷一点,类似这样:

zsh

先了解下什么是zsh?
https://wiki.archlinux.org/index.php/Zsh_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

安装oh my Zsh

官网:https://ohmyz.sh/ 提供两种安装方式

  1. //via curl
  2. sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  3. //via wget
  4. sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

报错zsh 没有安装

  1. [root@VM_0_8_centos /]# sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  2. Zsh is not installed! Please install zsh first!
安装Zsh
  1. [root@VM_0_8_centos /]# sudo yum install -y zsh
  2. Loaded plugins: fastestmirror, langpacks
  3. Repository epel is listed more than once in the configuration
  4. Determining fastest mirrors
  5. epel | 3.2 kB 00:00:00
  6. extras | 3.4 kB 00:00:00
  7. os | 3.6 kB 00:00:00
  8. updates | 3.4 kB 00:00:00
  9. (1/6): os/7/x86_64/group_gz | 166 kB 00:00:00
  10. (2/6): extras/7/x86_64/primary_db | 156 kB 00:00:00
  11. (3/6): epel/7/x86_64/updateinfo | 940 kB 00:00:00
  12. (4/6): updates/7/x86_64/primary_db | 1.3 MB 00:00:00
  13. (5/6): epel/7/x86_64/primary | 3.6 MB 00:00:00
  14. (6/6): os/7/x86_64/primary_db | 6.0 MB 00:00:00
  15. epel 12745/12745
  16. Resolving Dependencies
  17. --> Running transaction check
  18. ---> Package zsh.x86_64 0:5.0.2-31.el7 will be installed
  19. --> Finished Dependency Resolution
  20. Dependencies Resolved
  21. =================================================================================================================================================================================================================================================
  22. Package Arch Version Repository Size
  23. =================================================================================================================================================================================================================================================
  24. Installing:
  25. zsh x86_64 5.0.2-31.el7 os 2.4 M
  26. Transaction Summary
  27. =================================================================================================================================================================================================================================================
  28. Install 1 Package
  29. Total download size: 2.4 M
  30. Installed size: 5.6 M
  31. Downloading packages:
  32. zsh-5.0.2-31.el7.x86_64.rpm | 2.4 MB 00:00:00
  33. Running transaction check
  34. Running transaction test
  35. Transaction test succeeded
  36. Running transaction
  37. Installing : zsh-5.0.2-31.el7.x86_64 1/1
  38. Verifying : zsh-5.0.2-31.el7.x86_64 1/1
  39. Installed:
  40. zsh.x86_64 0:5.0.2-31.el7
  41. Complete!
  42. [root@VM_0_8_centos /]# zsh --version
  43. zsh 5.0.2 (x86_64-redhat-linux-gnu)

执行zsh --version检测,zsh安装成功

继续执行安装oh my Zsh
又报错,git没安装

  1. [root@VM_0_8_centos]/# sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  2. Cloning Oh My Zsh...
  3. Error: git is not installed
安装git
  1. [root@VM_0_8_centos]/# yum install -y git
  2. Loaded plugins: fastestmirror, langpacks
  3. Repository epel is listed more than once in the configuration
  4. Loading mirror speeds from cached hostfile
  5. Resolving Dependencies
  6. --> Running transaction check
  7. ---> Package git.x86_64 0:1.8.3.1-20.el7 will be installed
  8. --> Processing Dependency: perl-Git = 1.8.3.1-20.el7 for package: git-1.8.3.1-20.el7.x86_64
  9. --> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-20.el7.x86_64
  10. --> Processing Dependency: perl(Git) for package: git-1.8.3.1-20.el7.x86_64
  11. --> Processing Dependency: perl(Error) for package: git-1.8.3.1-20.el7.x86_64
  12. --> Running transaction check
  13. ---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed
  14. ---> Package perl-Git.noarch 0:1.8.3.1-20.el7 will be installed
  15. ---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed
  16. --> Finished Dependency Resolution
  17. Dependencies Resolved
  18. =================================================================================================================================================================================================================================================
  19. Package Arch Version Repository Size
  20. =================================================================================================================================================================================================================================================
  21. Installing:
  22. git x86_64 1.8.3.1-20.el7 updates 4.4 M
  23. Installing for dependencies:
  24. perl-Error noarch 1:0.17020-2.el7 os 32 k
  25. perl-Git noarch 1.8.3.1-20.el7 updates 55 k
  26. perl-TermReadKey x86_64 2.30-20.el7 os 31 k
  27. Transaction Summary
  28. =================================================================================================================================================================================================================================================
  29. Install 1 Package (+3 Dependent packages)
  30. Total download size: 4.5 M
  31. Installed size: 22 M
  32. Downloading packages:
  33. (1/4): perl-TermReadKey-2.30-20.el7.x86_64.rpm | 31 kB 00:00:00
  34. (2/4): perl-Git-1.8.3.1-20.el7.noarch.rpm | 55 kB 00:00:00
  35. (3/4): perl-Error-0.17020-2.el7.noarch.rpm | 32 kB 00:00:00
  36. (4/4): git-1.8.3.1-20.el7.x86_64.rpm | 4.4 MB 00:00:00
  37. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  38. Total 6.4 MB/s | 4.5 MB 00:00:00
  39. Running transaction check
  40. Running transaction test
  41. Transaction test succeeded
  42. Running transaction
  43. Installing : 1:perl-Error-0.17020-2.el7.noarch 1/4
  44. Installing : perl-TermReadKey-2.30-20.el7.x86_64 2/4
  45. Installing : git-1.8.3.1-20.el7.x86_64 3/4
  46. Installing : perl-Git-1.8.3.1-20.el7.noarch 4/4
  47. Verifying : perl-Git-1.8.3.1-20.el7.noarch 1/4
  48. Verifying : 1:perl-Error-0.17020-2.el7.noarch 2/4
  49. Verifying : git-1.8.3.1-20.el7.x86_64 3/4
  50. Verifying : perl-TermReadKey-2.30-20.el7.x86_64 4/4
  51. Installed:
  52. git.x86_64 0:1.8.3.1-20.el7
  53. Dependency Installed:
  54. perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-20.el7 perl-TermReadKey.x86_64 0:2.30-20.el7
  55. Complete!

git安装好后,继续执行安装oh my Zsh

  1. [root@VM_0_8_centos]/# sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  2. Cloning Oh My Zsh...
  3. Cloning into '/root/.oh-my-zsh'...
  4. remote: Enumerating objects: 991, done.
  5. remote: Counting objects: 100% (991/991), done.
  6. remote: Compressing objects: 100% (909/909), done.
  7. remote: Total 991 (delta 25), reused 840 (delta 18), pack-reused 0
  8. Receiving objects: 100% (991/991), 640.18 KiB | 253.00 KiB/s, done.
  9. Resolving deltas: 100% (25/25), done.
  10. Looking for an existing zsh config...
  11. Using the Oh My Zsh template file and adding it to ~/.zshrc
  12. __ __
  13. ____ / /_ ____ ___ __ __ ____ _____/ /_
  14. / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
  15. / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
  16. \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
  17. /____/ ....is now installed!
  18. Please look over the ~/.zshrc file to select plugins, themes, and options.
  19. p.s. Follow us at https://twitter.com/ohmyzsh.
  20. p.p.s. Get stickers and t-shirts at https://shop.planetargon.com.
  21. ➜ / ls
  22. bin boot data dev dump.rdb etc home lib lib64 lost+found media mnt opt proc root run sbin srv swapfile sys tmp usr var

安装成功

更改默认shell

查看系统默认shell,$SHELL是大写

  1. echo $SHELL

查看系统shell列表

  1. cat /etc/shells

更改系统shell为zsh

  1. chsh -s /usr/bin/zsh

更换主题

oh my Zsh默认主题是这样子的

修改vi ~/.zshrcZSH_THEME="robbyrussell"ZSH_THEME="agnoster"

  1. / vi ~/.zshrc
  2. # If you come from bash you might have to change your $PATH.
  3. # export PATH=$HOME/bin:/usr/local/bin:$PATH
  4. # Path to your oh-my-zsh installation.
  5. export ZSH="/root/.oh-my-zsh"
  6. # Set name of the theme to load --- if set to "random", it will
  7. # load a random theme each time oh-my-zsh is loaded, in which case,
  8. # to know which specific one was loaded, run: echo $RANDOM_THEME
  9. # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
  10. ZSH_THEME="robbyrussell"
  11. # Set list of themes to pick from when loading at random
  12. # Setting this variable when ZSH_THEME=random will cause zsh to load
  13. # a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
  14. # If set to an empty array, this variable will have no effect.
  15. # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
  16. # Uncomment the following line to use case-sensitive completion.
  17. # CASE_SENSITIVE="true"
  18. # Uncomment the following line to use hyphen-insensitive completion.
  19. # Case-sensitive completion must be off. _ and - will be interchangeable.
  20. # HYPHEN_INSENSITIVE="true"
  21. # Uncomment the following line to disable bi-weekly auto-update checks.
  22. # DISABLE_AUTO_UPDATE="true"
  23. # Uncomment the following line to change how often to auto-update (in days).
  24. # export UPDATE_ZSH_DAYS=13
  25. # Uncomment the following line to disable colors in ls.
  26. # DISABLE_LS_COLORS="true"
  27. # Uncomment the following line to disable auto-setting terminal title.
  28. # DISABLE_AUTO_TITLE="true"
  29. # Uncomment the following line to enable command auto-correction.
  30. # ENABLE_CORRECTION="true"
  31. # Uncomment the following line to display red dots whilst waiting for completion.
  32. # COMPLETION_WAITING_DOTS="true"
  33. # Uncomment the following line if you want to disable marking untracked files
  34. # under VCS as dirty. This makes repository status check for large repositories
  35. # much, much faster.
  36. # DISABLE_UNTRACKED_FILES_DIRTY="true"
  37. # Uncomment the following line if you want to change the command execution time
  38. # stamp shown in the history command output.
  39. # You can set one of the optional three formats:
  40. # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
  41. # or set a custom format using the strftime function format specifications,
  42. # see 'man strftime' for details.
  43. # HIST_STAMPS="mm/dd/yyyy"
  44. # Would you like to use another custom folder than $ZSH/custom?
  45. # ZSH_CUSTOM=/path/to/new-custom-folder
  46. "~/.zshrc" 98L, 3397C

退出终端(如xshell),重新登录,就变成这样了

环境变量问题

更换shell后,mongo环境变量用不了,需要重新配置mongo环境变量

  1. vi ~/.bash_profile
  2. # 加入mongo配置
  3. export MONGODB_HOME=/usr/local/mongodb-4.0.2/bin
  4. export PATH=$MONGODB_HOME:$PATH

使用source ~/.bash_profile使环境变量生效

参考

官网: https://ohmyz.sh/
https://www.addictivetips.com/ubuntu-linux-tips/switch-from-bash-to-zsh-on-linux/ (英文)
https://www.jianshu.com/p/9a5c4cb0452d
https://www.jianshu.com/p/97f33b7fac80?utm_source=oschina-app

主题 :https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
zsh: https://blog.csdn.net/u010138906/article/details/78778627
git: https://www.cnblogs.com/liaojie970/p/6253404.html

版权声明:本站文章除特别声明外,均采用署名-非商业性使用-禁止演绎 4.0 国际 许可协议,如需转载,请注明出处
  • 'GLIBCXX_3.4.21' not found--centos 升级gcc

    gcc版本老旧,经常会碰到的问题:/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found。不要在网上找各种方法,直接升级gcc吧

    发布:2021-09-14 阅读(11662)

  • linux下安装yarn

    发布:2021-09-13 阅读(3091)

  • redis启动多个实例,配置多个端口

    redis配置多个端口,redis启动多个实例

    发布:2020-08-11 阅读(3488)

  • LINUX挂载硬盘(不分区)的方法

    linux如何挂载新买的硬盘?

    发布:2020-06-21 阅读(3593)

  • vim编辑nginx conf文件时,设置高亮/显示行号

    vim编辑nginx conf文件时,设置高亮/显示行号

    发布:2020-06-19 阅读(2770)

  • vi/vim打开文件提示Found a swap file by the name

    vi/vim打开文件提示Found a swap file by the name

    发布:2020-06-04 阅读(1797)

  • C++ compiler too old, need g++ 4.9.4 or clang++ 3.4.2 (CXX=g++)

    linux报错:C++ compiler too old, need g++ 4.9.4 or clang++ 3.4.2 (CXX=g++)

    发布:2020-06-01 阅读(2922)

  • linux下安装nodejs

    linux下如何安装nodejs

    发布:2020-06-01 阅读(2056)

  • CentOS7 linux下yum安装redis以及使用

    linux下安装 redis,以及相关使用

    发布:2020-06-01 阅读(1475)

  • linux下通过yum安装mongodb

    linux下通过yum安装mongodb

    发布:2020-05-31 阅读(2913)

  • Linux rpm命令详解

    RPM是RedHat Package Manager(RedHat软件包管理工具)类似Windows里面的“添加/删除程序

    发布:2019-08-02 阅读(1624)

  • Linux中apt与apt-get命令的区别与解释

    Ubuntu 16.04 发布时,一个引人注目的新特性便是 apt 命令的引入。其实早在 2014 年,apt 命令就已经发布了第一个稳定版,只是直到 2016 年的 Ubuntu 16.04 系统发布时才开始引人关注。随着 apt install package 命令的使用频率和普遍性逐步超过 apt-get install package,越来越多的其它 Linux 发行版也开始遵循 Ubuntu 的脚步,开始鼓励用户使用 apt 而不是 apt-get。

    发布:2019-03-04 阅读(1859)

  • centos7设置、查看、删除环境变量的方法

    centos查看环境变量与设置环境变量在使用过程中很常见,本文整理了一些常用的与环境变量相关的命令,感兴趣的朋友可以参考下希望对你有所帮助

    发布:2018-12-27 阅读(5565)

  • linux CentOS 安装oh my Zsh

    linux cenos下安装oh my zsh,oh my zsh 用于管理zsh配置,使shell界面更美观。 Zsh 是一款功能强大终端(shell)软件,既可以作为一个交互式终端,也可以作为一个脚本解释器。它在兼容 Bash 的同时 (默认不兼容,除非设置成 emulate sh) 还有提供了很多改进。

    发布:2018-12-20 阅读(5633)

  • linux云服务通过Nginx绑定多个域名

    通过Nginx反向代理,在一个云服务器上绑定多个域名,不同的域名访问不同的目录,端口

    发布:2018-10-11 阅读(2245)

  • CentOS 7上安装Nginx

    如何在Linux(CentOS 7)上安装Nginx,作为反向代理服务器。

    发布:2018-10-11 阅读(2758)

  • tail命令详情

    命令从指定点开始将 File 参数指定的文件写到标准输出。如果没有指定文件,那么会使用标准输入。Number 变量指定将多少单元写到标准输出。Number 变量的值可以是正的或负的整数。如果值的前面有 +(加号),从文件开头指定的单元数开始将文件写到标准输出。如果值的前面有 -(减号),那么从文件末尾指定的单元数开始将文件写到标准输出。如果值前面没有 +(加号)或 -(减号),那么从文件末尾指定的单元号开始读取文件

    发布:2017-05-23 阅读(2855)