当前位置:网站首页>Kubectl's handy command line tool: Oh my Zsh tips and tricks
Kubectl's handy command line tool: Oh my Zsh tips and tricks
2022-07-07 23:51:00 【Qiyan】
Zsh Tips and tricks
stay unix/linux In the operating system environment , We will often discuss shell、 Terminal and command line interface .Bash Probably the most famous shell, But in Mac In computer ,Zsh Probably the most popular shell 了 .
What is? Zsh?
Zsh Also known as z Shell, It expands Bourne Shell (sh) The function of , Provides updated features and more support for plug-ins and themes . from 2019 Year of MacOS Catalina Start ,Zsh Become Mac The default login and interaction in the computer shell.
install Zsh
install Oh My Zsh Prerequisite : Must be installed zsh
Mac
stay Mac On the computer , You can use Homebrew To install Zsh.brew install zsh
Linux(Ubuntu)
# 1. install zsh
sudo apt-get install zsh
# 2. Confirm whether the installation is successful
zsh --version
# 3. Set up zsh As the default shell
sudo chsh -s (which zsh)
# 4. Log out and log back in
Linux(Centos)
# 1. install zsh
sudo yum install zsh
# 2. Confirm whether the installation is successful
zsh --version
# 3. Set up zsh As the default shell
sudo chsh -s (which zsh)
# 4. Log out and log back in
# Check the current system shell
cat /etc/shells
adopt yum Installed zsh The version is 5.0.2 Of , And many topics need to use a higher version zsh, If you need a higher version, you can use the source code to install
First uninstall zsh
yum remove zsh
Then compile
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
Set to default shell
command -v zsh | sudo tee -a /etc/shells
sudo chsh -s /usr/local/bin/zsh
When installed Zsh after , You can also install the most popular Zsh plug-in unit ,oh-my-Zsh, This plug-in has many built-in plug-ins and themes , Use the following installation script :
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Manual installation
1.1 Uninstall lower version
# Uninstall the current version
sudo yum remove zsh
1.2 Download the source code
- Source code :https://zsh.sourceforge.io/Arc/source.html
# download
wget https://sourceforge.net/projects/zsh/files/zsh/5.8/zsh-5.8.tar.xz/download
# decompression
tar xvf zsh-5.8.tar.xz
1.3 Compilation and installation
# Install the compiler
yum install gcc perl-ExtUtils-MakeMaker
yum install ncurses-devel
# Enter the source directory
cd zsh-5.8
# Perform configuration
# Default installed in :/usr/local/bin/zsh
./configure
# Compile and install
make && make install
# Add information
vim /etc/shells
# Add in the last line :/usr/local/bin/zsh
1.4 The verification results
# Switch shell
chsh -s /usr/local/bin/zsh
# View version information
zsh --version
# zsh 5.8 (x86_64-pc-linux-gnu)
Zsh Basic commands
6 A little-known Zsh Tips and tricks
takecommandThe command is mkdir and cd A combination of two commands . You can also generate intermediate directories as needed .
Specify the command to view history
Enter the specified command , Press the up arrow again , The history starting with this command can be iterated
zmvuse zmv Rename a large number of files . First , function
autoload zmvTo installzmv. Then execute the following command :zmv '(*).(jpg|jpeg)' 'demo-1.2'zcalcOpen the calculator on the command line , First , function
autoload zcalcTo installzcalc. Then you can executezcalccommand .Ctrl-qWhen you enter a long command , When you find that you need to execute a command before it , You can press
Ctrl-qTemporarily store the current command , Then enter another command , When the execution of the other command ends , The temporary commands will be automatically refilled .ctrl-x-eWhen you enter a long command , When you find an input error in the middle of the command , Can press
ctrl-x-eCopy the command to the editor for editing , After editing , Save to exit .
Easy to use plug-ins
To enable the zsh Plug in for , stay ~/.zshrc Set in :
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
install oh-my-zsh
- Can pass curl or wget Two ways to install , Install... With one command .
curl install
GitHub:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Gitee ( Domestic mirror )
sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
wget install
GitHub:
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
Gitee ( Domestic mirror )
sh -c "$(wget -O- https://gitee.com/pocmon/mirrors/raw/master/tools/install.sh)"
[[email protected]r]/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
upgrade oh-my-zsh
To upgrade oh-my-zsh, The input terminal :
Get updates
By default , The system will prompt you every 2 Check for updates once a week . stay Oh My Zsh Before loading ~/.zshrc, You can choose another update mode by adding a line to the file :
Automatic update without confirmation :
zstyle ':omz:update' mode autoIf updates are available , Please provide a reminder every few days :
zstyle ':omz:update' mode reminderTo disable automatic updates completely :
zstyle ':omz:update' mode disabled
Be careful : You can use the following settings to control Oh My Zsh Check the frequency of updates :
# 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
Update manually
If you want to update at any time ( Maybe someone just released a new plug-in and you don't want to wait a week ?) You just need to run :
omz update
uninstall Oh My Zsh
Oh My Zsh Not for everyone . We will miss you , But we want to make breaking up easy .
If you want to uninstall oh-my-zsh, Just run... From the command line uninstall_oh_my_zsh. It will delete and restore your previous bash or zsh To configure .
Use Oh My Zsh
plug-in unit
Oh My Zsh There are a lot of plug-ins for you to use . You can view plug-in unit Contents and / or wiki To see what is currently available .
To enable the plugin
Once you find one ( Or more ) You want to contact Oh My Zsh Plug ins used together , You need to .zshrc Enable them in the file . You will be in your $HOME Found in the directory zshrc file . Open it with your favorite text editor , You will see a place listing all the plug-ins you want to load .
vim ~/.zshrc
for example , This may start to look like this :
plugins=(
git
bundler
dotenv
macos
rake
rbenv
ruby
)
Please note that , Plug ins are separated by spaces ( Space 、 tabs 、 New line …). Don't Use commas between them , Otherwise it will interrupt .
# Refresh configuration
source ~/.zshrc
The use of plug-in
Each built-in plug-in contains a README, Used to record it . This readme file should show the aliases contained in that particular plug-in ( If the plug-in adds any aliases ) And extra good things .
The theme
We will admit it . stay Oh My Zsh The early days of the world , We may be a little too happy . We are now tied to more than 150 A theme . Most of them are in wiki both Screenshot ( We are trying to update this !). To have a look at !
Select topic
Robby The theme of is the default theme . This is not the most fancy . This is not the simplest . That's right ( For him, ).
Find the theme to use , You need to edit this ~/.zshrc file . You will see an environment variable ( All capitals ), As shown below :
ZSH_THEME="robbyrussell"
Use different themes , Just change the value to match the name of the desired topic . for example :
ZSH_THEME="agnoster" # (this is one of the fancy ones)
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
Be careful : Many themes need to be installed Power line font or Nerd fonts In order to present correctly . Without them , These themes will present Strange prompt symbol
Open a new terminal window , Your prompt should be as follows :
If you don't find a theme that suits your needs , Please check out wiki understand more The theme .
If you feel bored , You can let the computer choose one randomly for you every time you open a new terminal window .
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
If you want to choose a random theme from your favorite theme list :
ZSH_THEME_RANDOM_CANDIDATES=(
"robbyrussell"
"agnoster"
)
If you only know which topics you don't like , They can be similarly added to the ignore list :
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
Abnormal problems
1. uninstall zsh I can't log in after root Account solution
# Input in the terminal
sudo vim /etc/passwd
# Take the first line
root:x:0:0:root:/root:/bin/zsh
# Change it to
root:x:0:0:root:/root:/bin/bash
# Put the last line
username:x:1000:1000:username,,,:/home/username:/username/local/bin/zsh
# Change it to
username:x:1000:1000:username,,,:/home/username:/username/local/bin/bash
# Save and log in root 了
Reference link :
t:/root:/bin/zsh
# Change it to
root0:0:root:/root:/bin/bash
Put the last line
username1000:1000:username,:/home/username:/username/local/bin/zsh
Change it to
username1000:1000:username,:/home/username:/username/local/bin/bash
Save and log in root 了
## Reference link :
[zsh](https://www.zsh.org/)
[ohmyzsh to update ](https://github.com/ohmyzsh/ohmyzsh#getting-updates)
[ohmyzsh Plug in list ](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins)
[ohmyzsh The theme ](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes)
边栏推荐
猜你喜欢
![Arbre binaire équilibré [Arbre AVL] - Insérer et supprimer](/img/1f/cd38b7c6f00f2b3e85d4560181a9d2.png)
Arbre binaire équilibré [Arbre AVL] - Insérer et supprimer

Ora-01741 and ora-01704

10 schemes to ensure interface data security

平衡二叉樹【AVL樹】——插入、删除

C - linear table

Take you hand in hand to build Eureka server with idea

Apng2gif solutions to various problems

HB 5469 combustion test method for non-metallic materials in civil aircraft cabin

MySQL Architecture

Traduction gratuite en un clic de plus de 300 pages de documents PDF
随机推荐
Possible SQL for Oracle table lookup information
MP4文件格式解析之结合实例分析
ASP. Net core middleware request processing pipeline
[summary] some panels and videos seen
神奇快速幂
C language greedy snake
SQL uses the in keyword to query multiple fields
archery安装测试
95. (cesium chapter) cesium dynamic monomer-3d building (building)
关于CH32库函数与STM32库函数的区别
正畸注意事项(持续更新中)
At the age of 35, I made a decision to face unemployment
Benchmarking Detection Transfer Learning with Vision Transformers(2021-11)
@Configuration注解的详细介绍
C language learning
Binary sort tree [BST] - create, find, delete, output
【路径规划】使用垂距限值法与贝塞尔优化A星路径
Dataguard 主备清理归档设置
0-1 knapsack problem
Come on, brother
