当前位置:网站首页>Kubectl_好用的命令行工具:oh-my-zsh_技巧和窍门
Kubectl_好用的命令行工具:oh-my-zsh_技巧和窍门
2022-07-24 15:16:00 【InfoQ】
Zsh 技巧和窍门
什么是 Zsh?
安装 Zsh
Mac
brew install zshLinux(Ubuntu)
# 1. 安装zsh
sudo apt-get install zsh
# 2. 确认是否安装成功
zsh --version
# 3. 设置zsh为默认shell
sudo chsh -s (which zsh)
# 4. 注销重新登录
Linux(Centos)
# 1. 安装zsh
sudo yum install zsh
# 2. 确认是否安装成功
zsh --version
# 3. 设置zsh为默认shell
sudo chsh -s (which zsh)
# 4. 注销重新登录
# 查看系统当前 shell
cat /etc/shells
yum remove zsh
sudo yum update -y
sudo yum install -y git make ncurses-devel gcc autoconf man
git clone -b zsh-5.7.1 https://github.com/zsh-users/zsh.git /tmp/zsh
cd /tmp/zsh
./Util/preconfig
./configure
sudo make -j 20 install.bin install.modules install.fns
command -v zsh | sudo tee -a /etc/shells
sudo chsh -s /usr/local/bin/zsh
oh-my-Zshsh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
手动安装
1.1 卸载低版本
# 卸载当前版本
sudo yum remove zsh
1.2 下载源码
- 源码:https://zsh.sourceforge.io/Arc/source.html
# 下载
wget https://sourceforge.net/projects/zsh/files/zsh/5.8/zsh-5.8.tar.xz/download
# 解压
tar xvf zsh-5.8.tar.xz
1.3 编译安装
# 安装编译工具
yum install gcc perl-ExtUtils-MakeMaker
yum install ncurses-devel
# 进入源码目录
cd zsh-5.8
# 执行配置
# 默认安装在:/usr/local/bin/zsh
./configure
# 编译和安装
make && make install
# 添加信息
vim /etc/shells
# 在最后一行加上:/usr/local/bin/zsh
1.4 验证结果
# 切换shell
chsh -s /usr/local/bin/zsh
# 查看版本信息
zsh --version
# zsh 5.8 (x86_64-pc-linux-gnu)
Zsh基本命令
6个鲜为人知的 Zsh 技巧和窍门
take命令
- 这个命令是 mkdir 和 cd 两个命令的组合。也可以根据需要生成中间目录。
- 指定命令查看历史
- 输入指定命令,再按向上箭头,可循环遍历以该命令开头的历史记录
zmv
- 用 zmv 重命名大量文件。首先,运行
autoload zmv来安装zmv。然后执行如下命令:
zmv '(*).(jpg|jpeg)' 'demo-1.2'
zcalc
- 在命令行中打开计算器,首先,运行
autoload zcalc来安装zcalc。然后就可以执行zcalc命令。
Ctrl-q
- 当你输入了一条长的命令,发现需要在其之前先执行一条命令时,就可以按
Ctrl-q暂存当前命令,然后输入另外一条命令,当另外这条命令执行结束后,会自动重新填充好暂存的命令。
ctrl-x-e
- 当你输入了一条很长的命令,发现命令中间有地方输入错误时,可以按
ctrl-x-e将该命令拷贝到编辑器中进行编辑,编辑完后,保存退出即可。
好用的插件
plugins=(git autojump last-working-dir tmux tmuxinator web-search fancy-ctrl-z themes)
- autojump
- last-working-dir
- tmux
- tmuxinator
- web-search
- fancy-ctrl-z
安装oh-my-zsh
- 可以通过 curl 或 wget 两种方式来安装,用一条命令即可安装。
curl 安装
GitHub
:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Gitee ( 国内镜像 )
sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
wget 安装
GitHub
:
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
Gitee ( 国内镜像 )
sh -c "$(wget -O- https://gitee.com/pocmon/mirrors/raw/master/tools/install.sh)"
[[email protected]]/fly/k8s/shell/ohmyzsh# ./install.sh
Cloning Oh My Zsh...
remote: Enumerating objects: 1280, done.
remote: Counting objects: 100% (1280/1280), done.
remote: Compressing objects: 100% (1236/1236), done.
remote: Total 1280 (delta 24), reused 1230 (delta 24), pack-reused 0
Receiving objects: 100% (1280/1280), 1.06 MiB | 1.23 MiB/s, done.
Resolving deltas: 100% (24/24), done.
From https://github.com/ohmyzsh/ohmyzsh
* [new branch] master -> origin/master
Branch master set up to track remote branch master from origin.
Already on 'master'
/fly/k8s/shell/ohmyzsh
Looking for an existing zsh config...
Found ~/.zshrc. Backing up to /root/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc.
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!
Before you scream Oh My Zsh! look over the `.zshrc` file to select plugins, themes, and options.
• Follow us on Twitter: https://twitter.com/ohmyzsh
• Join our Discord community: https://discord.gg/ohmyzsh
• Get stickers, t-shirts, coffee mugs and more: https://shop.planetargon.com/collections/oh-my-zsh
升级oh-my-zsh
获取更新
~/.zshrc- 自动更新无确认提示:
zstyle ':omz:update' mode auto
- 如果有可用更新,请每隔几天提供一次提醒:
zstyle ':omz:update' mode reminder
- 要完全禁用自动更新:
zstyle ':omz:update' mode disabled
# This will check for updates every 7 days
zstyle ':omz:update' frequency 7
# This will check for updates every time you open the terminal (not recommended)
zstyle ':omz:update' frequency 0
手动更新
omz update
卸载 Oh My Zsh
oh-my-zshuninstall_oh_my_zshbashzsh使用 Oh My Zsh
插件
启用插件
.zshrc$HOMEvim ~/.zshrc
plugins=(
git
bundler
dotenv
macos
rake
rbenv
ruby
)
# 刷新配置
source ~/.zshrc
使用插件
主题
选择主题
~/.zshrcZSH_THEME="robbyrussell"
ZSH_THEME="agnoster" # (this is one of the fancy ones)
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster

ZSH_THEME="random" # (...please let it be pie... please be some pie..)
ZSH_THEME_RANDOM_CANDIDATES=(
"robbyrussell"
"agnoster"
)
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
异常问题
1. 卸载zsh后无法登陆root账户的解决方案
#在终端中输入
sudo vim /etc/passwd
#将第一行
root:x:0:0:root:/root:/bin/zsh
#改为
root:x:0:0:root:/root:/bin/bash
# 将最后一行
username:x:1000:1000:username,,,:/home/username:/username/local/bin/zsh
# 改为
username:x:1000:1000:username,,,:/home/username:/username/local/bin/bash
# 保存就可以登录root了
参考链接:
边栏推荐
- spark:指定日期输出相应日期的日志(入门级-简单实现)
- 华为无线设备配置WPA2-802.1X-AES安全策略
- Rest style
- Learning rate adjustment strategy in deep learning (1)
- 【OpenCV 例程300篇】238. OpenCV 中的 Harris 角点检测
- Which securities company is good at opening an account with flush? Excuse me, is it safe to open an account with mobile phone or stock?
- 27.目录与文件系统
- Spark: specify the date and output the log of the corresponding date (entry level - simple implementation)
- 华为相机能力
- Huawei camera capability
猜你喜欢

【机器学习基础】——另一个视角解释SVM

Various searches (⊙▽⊙) consolidate the chapter of promotion

Summary of feature selection: filtered, wrapped, embedded
![[matlab] matlab drawing Series II 1. Cell and array conversion 2. Attribute cell 3. delete Nan value 4. Merge multiple figs into the same Fig 5. Merge multiple figs into the same axes](/img/4d/b0ba599a732d1390c5eeb1aea6e83c.png)
[matlab] matlab drawing Series II 1. Cell and array conversion 2. Attribute cell 3. delete Nan value 4. Merge multiple figs into the same Fig 5. Merge multiple figs into the same axes

Kali concise language transformation method (illustration)

Unity uses NVIDIA flex for unity plug-in to realize the effects of making software, water, fluid, cloth, etc. learning tutorial

JMeter - call the interface for uploading files or pictures

Performance test - Test Execution

Strongly connected component

2022 robocom world robot developer competition - undergraduate group (provincial competition) rc-u4 strategy team (completed)
随机推荐
多数据源配置下,解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
MySql函数
ZABBIX administrator forgot login password
Strongly connected component
基于ABP实现DDD--实体创建和更新
2022 RoboCom 世界机器人开发者大赛-本科组(省赛) CAIP 完整版题解
2022 robocom world robot developer competition - undergraduate group (provincial competition) rc-u4 strategy team (completed)
DS binary tree - parent and child nodes of binary tree
27.目录与文件系统
2022 robocom world robot developer competition - undergraduate group (provincial competition) CAIP full version solution
华为无线设备配置WPA2-802.1X-AES安全策略
Spark: specify the date and output the log of the corresponding date (entry level - simple implementation)
Circular structure practice
2022 robocom world robot developer competition - undergraduate group (provincial competition) -- question 2: intelligent medication assistant (finished)
Wildfire STM32 domineering, through the firmware library to achieve water light
Outlook tutorial, how to create tasks and to DOS in outlook?
Overall testing framework for performance testing
【Bug解决】Win10安装pycocotools报错
onBlur和onChange冲突解决方法
Problems needing attention in mobile terminal testing