ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

ubuntu20.0.4 安装zsh纪要

2021-11-20 00:00:43  阅读:292  来源: 互联网

标签:oh my zshrc alias usr zsh 纪要 ubuntu20.0


Z shell(Zsh)是一款可用作交互式登录的shell及脚本编写的命令解释器。Zsh对Bourne shell做出了大量改进,同时加入了Bash、ksh及tcsh的某些功能。

自2019年起,macOS的默认Shell已从Bash改为Zsh。

于是我要在我的ubuntu设备上安装zsh来增加我的愉悦值

首先下载zsh,也可以使用aptitude替代apt

$ sudo apt install zsh

查看是否安装成功了,打印版本号就ok

$ zsh --version
zsh 5.8 (x86_64-ubuntu-linux-gnu)

查看zsh安装位置

$ whereis zsh
zsh: /usr/bin/zsh /usr/lib/x86_64-linux-gnu/zsh /etc/zsh /usr/share/zsh /usr/share/man/man1/zsh.1.gz

网上大多数教程是使用:

sudo chsh -s /usr/bin/zsh
reboot

我自己在使用过程中发现这样做总是无效,重启或者重开中断后总是显示:

$ echo ${SHELL}
/usr/bin/bash

于是我改为下面这样就ok

sudo usermod -s /usr/bin/zsh $(whoami)
reboot

重启之后再次打开终端你将看到

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.

(2)  Populate your ~/.zshrc with the configuration recommended
     by the system administrator and exit (you will need to edit
     the file by hand, if so desired).

--- Type one of the keys in parentheses --- 

按键盘数字键 2,zsh 自动创建一个新的 ~/.zshrc 配置文件。
那么这个文件在哪里呢?它其实在用户家目录下面
此时的zsh缺少很多功能,你可以在~/.zshrc中添加:

alias cls='clear'
alias ll='ls -l'
alias la='ls -a'
alias vi='vim'
alias grep="grep --color=auto"

到此为止你的zsh就完全安装好了

oh-my-zsh

为了让zsh更好看,更好用,安装oh-my-zsh

git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh

下载好之后,使用它的.zshrc替换原本的

cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

再在中添加:

alias cls='clear'
alias ll='ls -l'
alias la='ls -a'
alias vi='vim'
alias grep="grep --color=auto"

然后可以参考这篇帖子,更换喜欢的主题、设置自己的插件。主题官网在这里,可以选个自己喜欢的

标签:oh,my,zshrc,alias,usr,zsh,纪要,ubuntu20.0
来源: https://blog.csdn.net/qq_41540355/article/details/121432875

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有