oh my zsh安装
1、安装
sudo apt update
sudo apt-get install zsh
将默认的shell从bash改为zsh
chsh -s /bin/zsh
重新启动
sudo reboot
这两个命令可以查看安装的shell以及当前的shell:
cat /etc/shells
echo $SHELL
配置zsh略微复杂,可以直接使用Oh-My-Zsh进行配置,以下三种命令,任何一种均可
Method | Command |
---|---|
curl | sh -c “$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)” |
wget | sh -c “$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)” |
fetch | sh -c “$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)” |
也可以手动进行安装
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh
或者下面的命令
wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
2、更换zsh主题
官网可以查看主题风格介绍举例。
编辑~/.zshrc
文件
修改ZSH_THEME="robbyrussell"
,我比较喜欢jispwoso
主题,就更换为这个主题,然后保存并重新启动你的终端。
主题风格如下;
3、zsh插件
3.1 vscode
官网插件安装说明。
安装
git clone https://github.com/valentinocossar/vscode.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/vscode
修改~/.zshrc
文件如下,保存并使修改的文件生效source .zshrc
命令如下
Common aliases
Alias | Command | Description |
---|---|---|
vsc | code . | Open the current folder in VS code |
vsca dir | code --add dir | Add folder(s) to the last active window |
vscd file file | code --diff file file | Compare two files with each other. |
vscg file:line[:char] | code --goto file:line[:char] | Open a file at the path on the specified line and character position. |
vscn | code --new-window | Force to open a new window. |
vscr | code --reuse-window | Force to open a file or folder in the last active window. |
vscw | code --wait | Wait for the files to be closed before returning. |
vscu dir | code --user-data-dir dir | Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code. |
Extensions aliases
Alias | Command | Description |
---|---|---|
vsced dir | code --extensions-dir dir | Set the root path for extensions. |
vscie id or vsix-path | code --install-extension extension-id> or <extension-vsix-path | Installs an extension. |
vscue id or vsix-path | code --uninstall-extension id or vsix-path | Uninstalls an extension. |
Other options:
Alias | Command | Description |
---|---|---|
vscv | code --verbose | Print verbose output (implies --wait). |
vscl level | code --log level | Log level to use. Default is ‘info’. Allowed values are ‘critical’, ‘error’, ‘warn’, ‘info’, ‘debug’, ‘trace’, ‘off’. |
vscde | code --disable-extensions | Disable all installed extensions. |
3.2 zsh-autosuggestions
官网安装说明。
记录你之前输入过的所有命令,并且自动匹配你可能想要输入命令,然后按Tab
补全
安装
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
修改~/.zshrc
文件如下,保存并使修改的文件生效source .zshrc
plugins=(
# other plugins...
zsh-autosuggestions
)
3.3 zsh-syntax-highlighting
官网安装说明
在输入命令时提示当前命令是否正确,错误红色,正确绿色
安装
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
修改~/.zshrc
文件如下,保存并使修改的文件生效source .zshrc
plugins=(
# other plugins...
zsh-syntax-highlighting
)
4、终端透明度设置
打开终端,在窗口中点击右键,选择Preferences
,如下图设置,拖动滑块即可修改终端的透明度
最终效果如下:
5、docker自动切换到zsh
将.bashrc
的一些配置复制到.zshrc
,在~
路径下新建.bash_profile
touch .bash_profile
在文件中添加
export PATH=/bin:/usr/bin:/usr/local/bin:$PATH
保存关闭,在.zshrc
中添加
source ~/.bash_profile