The default terminal is already usable, but a lot of the little time-saving details are still turned off: smarter completion, friendlier prompts, and smoother history search. In this chapter, we’ll use a setup that’s as stable as possible to get your terminal to a state where it won’t get annoying over the long run.
1. Install Zsh
Zsh is an enhanced version of Bash, with more powerful autocompletion and plugin support.
1. Install Zsh:
sudo apt install zsh
2. Verify the installation:
zsh --version
3. Set it as the default shell:
chsh -s $(which zsh)
Note: after entering your password, you may need to log out and back in for it to take effect.
2. Install Oh My Zsh
Oh My Zsh is a framework for managing Zsh configuration, and it makes setting up Zsh ridiculously easy.
It’s a good idea to back up your config file before installing (if you already have ~/.zshrc):
cp ~/.zshrc ~/.zshrc.bak 2>/dev/null || true
Install command (requires curl and git first):
sudo apt install curl git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Once installed, you’ll notice the prompt has changed and the colors look nicer.
3. Change Themes
Oh My Zsh ships with hundreds of themes.
1. Edit the config file:
nano ~/.zshrc
2. Change the theme:
Find the line ZSH_THEME="robbyrussell".
• Recommended theme 1: ys (clean and clear, shows username, path, and Git branch).
• Recommended theme 2: agnoster (super flashy, requires Powerline fonts).
Change it to: ZSH_THEME="ys"
3. Apply the config:
source ~/.zshrc
4. Essential Plugins
Plugins are the soul of Zsh.
More plugins isn’t better. You really only need a few: input suggestions, syntax highlighting, and quick jumping. Something that runs reliably for a year matters more than looking flashy.
A. zsh-autosuggestions (autosuggestions)
When you type a command, it automatically suggests what comes next based on history (shown in gray); just press the right arrow key to complete it.
- Download:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
B. zsh-syntax-highlighting (syntax highlighting)
Correct commands are green, wrong ones are red—you can tell at a glance.
- Download:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
C. Enable the plugins
- Open
~/.zshrc. - Find the line
plugins=(git). - Change it to:
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
extract # 这是一个解压神器,x filename 即可解压任何格式
z # 快速跳转目录,z 目录名 即可跳转
)
- Run
source ~/.zshrcto apply it.
5. Tmux: The Terminal Multiplexer
If you often need to run multiple tasks in one window or work remotely over SSH, Tmux is a must-install.
• Features: lets you split a terminal window into multiple panes, or run sessions in the background so a dropped connection doesn’t interrupt your tasks.
• Install: sudo apt install tmux
Once you’ve got all this set up, your terminal won’t just look professional—your productivity will jump by an order of magnitude.
Ubuntu for Beginners Tutorial · Contents
02. Ubuntu Preparation and Installation Options
03. Step-by-Step Ubuntu 24.04 LTS Installation
04. First Look at the GNOME Desktop Environment
05. Software Installation and Management: Saying Goodbye to .exe
06. Chinese Environment Setup and Input Methods
07. Office and Productivity Tools
08. First Steps with the Linux Terminal
09. Linux File Permissions and User Management
10. The Text Editor Debate: Getting Started with Nano and Vim
默认终端已经能用,但很多“省时间的小细节”还没打开:更聪明的补全、更友好的提示、更顺手的历史搜索。这一章用一套尽量稳的配置,把终端改到“长期用也不烦”的状态。
一. 安装 Zsh
Zsh 是 Bash 的增强版,支持更强大的自动补全和插件。
1. 安装 Zsh:
sudo apt install zsh
2. 验证安装:
zsh --version
3. 设置为默认 Shell:
chsh -s $(which zsh)
注意:输入密码后可能需要注销并重新登录才能生效。
二. 安装 Oh My Zsh
Oh My Zsh 是一个管理 Zsh 配置的框架,它让配置 Zsh 变得极其简单。
建议在安装前先备份一下你的配置文件(如果你已经有 ~/.zshrc):
cp ~/.zshrc ~/.zshrc.bak 2>/dev/null || true
安装命令 (需要先安装 curl 和 git):
sudo apt install curl git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
安装完成后,你会发现终端提示符变了,而且颜色也变漂亮了。
三. 更换主题 (Themes)
Oh My Zsh 自带了上百个主题。
1. 编辑配置文件:
nano ~/.zshrc
2. 修改主题:
找到 ZSH_THEME="robbyrussell" 这一行。
• 推荐主题 1: ys (简洁清晰,显示用户名、路径、Git 分支)。
• 推荐主题 2: agnoster (极其酷炫,需要安装 Powerline 字体)。
修改为:ZSH_THEME="ys"
3. 生效配置:
source ~/.zshrc
四. 必备插件 (Plugins)
插件是 Zsh 的灵魂。
插件不是越多越好。常用的就那么几个:输入建议、语法高亮、快速跳转。能稳定跑一年,比“看起来很炫”更重要。
A. zsh-autosuggestions (自动建议)
当你输入命令时,它会根据历史记录自动建议后续内容(灰色显示),按右箭头键即可补全。
- 下载:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
B. zsh-syntax-highlighting (语法高亮)
命令输对了是绿色,输错了是红色,一眼便知。
- 下载:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
C. 启用插件
- 打开
~/.zshrc。 - 找到
plugins=(git)这一行。 - 修改为:
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
extract # 这是一个解压神器,x filename 即可解压任何格式
z # 快速跳转目录,z 目录名 即可跳转
)
4.运行 source ~/.zshrc 生效。
五. Tmux:终端复用神器
如果你经常需要在一个窗口里运行多个任务,或者通过 SSH 远程工作,Tmux 是必装的。
• 功能: 允许你在一个终端窗口中分割出多个窗格 (Pane),或者在后台运行会话 (Session) 防止断网导致任务中断。
• 安装: sudo apt install tmux
配置好这些,你的终端不仅看起来专业,工作效率也会提升一个量级。
小白Ubuntu教程 · 目录
Translated by AI from 简体中文Original (简体中文)
快银 VPN,一键连接全球节点,线路稳定、延迟低。支持 Windows、macOS 等多平台,TUN 全局模式覆盖全部应用流量。无需复杂配置,下载即用。
1 replies
Sort order