centos7 安装 zsh,oh-my-zsh和推荐插件


最近在捣鼓 linux终端,使自己开发高效也更加舒适,这里记录一下:

一、将默认的shell从bash改成更强大的zsh

echo $SHELL  #默认返回 bin/bash

二、安装 zsh

sudo yum install -y zsh

三、设置用户默认 shell

方法1:

chsh -s /bin/zsh  # 修改当前用户,root用户请先 su root

方法2:修改 passwd 对应用户的默认登录 shell 环境 保存退出

sudo vim /etc/passwd

四、安装 git, wget, curl

sudo yum install -y git wget curl

五、安装 oh-my-zsh

方法1:

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

方法2:

1 git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
2 cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

六、修改主题

vim ~/.zshrc  #找到文件中 ZSH_THEME="主题名称" 
# 可选主题名称
# ys
# random
# agnoster

七、安装oh-my-zsh必备插件

1、autojump(快速跳转文件夹,效率神器)

git clone git://github.com/joelthelion/autojump.git
# 进入目录,执行安装脚本
cd autojump && ./install.py
# .zshrc 加入以下 内容
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh

2、zsh-syntax-highlighting(命令高亮 正确路径自带下划线)

作用 平常用的lscd 等命令输入正确会绿色高亮显示,输入错误会显示其他的颜色。

# 克隆项目
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 在 ~/.zshrc 中配置
plugins=(其他的插件 zsh-syntax-highlighting)

3、zsh-autosuggestions(自动补全可能的路径)

# 克隆项目
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
# 在 ~/.zshrc 中配置
plugins=(其他的插件 zsh-autosuggestions)

4、git-open

官网:

在终端里打开当前项目的远程仓库地址
不要小看这个插件欧,每次改完本地代码,当你想用浏览器访问远程仓库的时候,就知道这个插件多方便了 😘
支持打开的远程仓库

  • github.com
  • gist.github.com
  • gitlab.com
  • 自定义域名的 GitLab
  • bitbucket.org
  • Atlassian Bitbucket Server (formerly Atlassian Stash)
  • Visual Studio Team Services
  • Team Foundation Server (on-premises)
# 克隆项目
git clone https://github.com/paulirish/git-open.git $ZSH_CUSTOM/plugins/git-open
# 在 ~/.zshrc 中配置
plugins=(其他的插件 git-open)
# 使配置生效
source ~/.zshrc

其他设置:

# history 命令查看历史输入命令的时间展示格式
alias history="history -t'%F %T'"

最后  source ~/.zshrc

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM