Skip to content

Kat404/ZSH-Terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ The Ultimate Zsh Tutorial

README en EspaΓ±ol

πŸ“š Table of Contents

  1. Zsh Installation
  2. Introduction
  3. Basic Navigation
  4. File and Directory Management
  5. Day-to-Day Utilities
  6. Searches
  7. Pipes and Redirections
  8. Essential Keyboard Shortcuts
  9. Text Editors
  10. The Power of Zsh and Oh My Zsh
  11. Oh My Zsh Plugins
  12. Useful Aliases
  13. Yazi - Terminal File Browser
  14. Antidote - Zsh Plugin Manager
  15. Powerlevel10k Customization

πŸ“¦ Zsh Installation β†₯

To get started with the content of this repository, you'll need to install zsh and set it as your default shell. Depending on your Linux distribution, the command to install zsh will vary. It can usually be found natively in various package managers.

Debian/Ubuntu

sudo apt update && sudo apt install zsh

Fedora

sudo dnf install zsh

Arch Linux

sudo pacman -S zsh

OpenSUSE

sudo zypper install zsh

Post-installation

After installing zsh, you can set it as your default shell by running the following command:

chsh -s $(which zsh)

Finally, for zsh to be applied correctly, you will need to log out (and log back in) or simply restart your system.

🏠 Introduction β†₯

When we start our terminal, we will see a unique prompt:

user_name@pc_name ~
  • user_name@pc_name: This is the user@hostname
  • ~: This is the current directory. The ~ symbol (called a "tilde") is a shortcut for your home folder (/home/user/).

Note: Using Powerlevel10k, you will see a visual indicator (βœ“ or βœ—) that shows whether the last command was successful or failed.

πŸ“‚ Basic Navigation β†₯

ls - List files and directories

Lists the content of the current directory.

Useful options:

  • ls -l: Shows a detailed list (permissions, owner, size, date).
  • ls -a: Shows all files, including hidden ones (those starting with .).
  • ls -h: Used with -l, shows the size in a human-readable format (KB, MB, GB).
  • ls --color: Displays the output with colors, differentiating folders from files.

Oh My Zsh Shortcuts:

alias ll='ls -l'
alias l='ls -CF'
alias la='ls -A'

cd - Change directory

  • cd Downloads: Go to the Downloads folder
  • cd or cd ~: Return to your home folder
  • cd -: Return to the previous directory
  • cd ..: Go up one level
  • cd ../..: Go up two levels

Tip: Type cd Do and press Tab. Zsh will autocomplete to Downloads/ for you.

pwd - Show current directory

Shows the full path of the current directory.

pwd
# Output: /home/user

πŸ“ File and Directory Management β†₯

mkdir - Create directories

Create a simple directory:

mkdir Projects

Create nested directories:

mkdir -p Projects/2025/Web

touch - Create empty files

touch note.txt
touch app.py

cp - Copy files and directories

Copy a file:

cp file.txt Documents/

Copy and rename:

cp file.txt file_copy.txt

Copy directories (use -r for recursive):

cp -r directory/ directory_copy/

mv - Move or rename

Rename a file:

mv old.txt new.txt

Move a file:

mv document.txt Documents/

Move and rename:

mv file.txt Documents/new_name.txt

rm - Delete files and directories

⚠️ Warning! Deleted files do not go to the trash.

Delete a file:

rm file.txt

Delete an empty directory:

rmdir empty_directory/

Delete a directory with content (Use with caution!):

rm -r directory_with_content/

πŸ› οΈ Day-to-Day Utilities β†₯

sudo - Execute as superuser

sudo command

Package management (Debian/Ubuntu)

Update package list:

sudo apt update

Upgrade the system:

sudo apt upgrade

Install software:

sudo apt install package_name

Remove software:

sudo apt remove package_name

πŸ” Searches β†₯

find - Search for files

Find .conf files:

find . -name "*.conf"

Find files modified in the last 7 days:

find /path -mtime -7

grep - Search within files

Search for "error" in .log files:

grep "error" *.log

Recursive search:

grep -r "word" /directory/

πŸ”„ Pipes and Redirections β†₯

Pipe (|): Connect commands

ps aux | grep firefox

Redirection (>): Save output to a file

ls -l > file_list.txt

Append to the end of a file (>>)

echo "new line" >> file.txt

⌨️ Essential Keyboard Shortcuts β†₯

  • Ctrl + C: Cancel the current command
  • Ctrl + D: Close the terminal
  • Ctrl + L: Clear the screen
  • Ctrl + A: Go to the beginning of the line
  • Ctrl + E: Go to the end of the line
  • Ctrl + U: Delete up to the beginning of the line
  • Ctrl + K: Delete up to the end of the line
  • Ctrl + W: Delete the previous word
  • Ctrl + R: Search in history

πŸ“ Text Editors β†₯

nano - Simple editor

nano file.txt

Basic commands:

  • Ctrl + O: Save
  • Ctrl + X: Exit
  • Ctrl + K: Cut line
  • Ctrl + U: Paste

neovim/vim - Advanced editor

nvim file.conf

Main modes:

  1. Normal Mode (on open): For navigation

    • h, j, k, l: Move (left, down, up, right)
    • i: Enter Insert mode
    • v: Visual mode to select text
  2. Insert Mode (i): For writing text

    • Esc: Return to Normal mode
  3. Commands (from Normal mode, press :):

    • :w: Save
    • :q: Quit
    • :wq: Save and quit
    • :q!: Force quit without saving

⚑ The Power of Zsh and Oh My Zsh β†₯

Smart Autocompletion (Tab)

  • Paths: cd /v/l + Tab β†’ cd /var/log
  • Commands: git ch + Tab β†’ Shows options like checkout, cherry-pick
  • Packages: apt install + Tab β†’ Lists available packages

History Search

  • Ctrl + R: Searches through command history
  • Up/Down arrows: Navigate through recent commands

πŸ”Œ Oh My Zsh Plugins β†₯

Edit ~/.zshrc to enable plugins:

plugins=(
  git
  z
  colored-man-pages
  sudo
  wd
)

Recommended plugins:

  • git: Shortcuts like gaa for git add --all
  • z: Fast navigation between frequent directories
  • colored-man-pages: Manuals in color
  • wd: Directory bookmarks

πŸ› οΈ Useful Aliases β†₯

Add this to your ~/.zshrc. You can go to the Antidote section and follow the tutorial for better management and organization of your ~/.zshrc:

# System update
alias update="sudo apt update && sudo apt upgrade -y && flatpak update"

# Common shortcuts
alias cls="clear"
alias fsh="fastfetch"
alias nsh="neofetch"

# Spanish commands
alias salir="exit"
alias ir="cd"
alias cds="yazi"  # File manager

Reload the configuration:

source ~/.zshrc

πŸš€ Yazi - Terminal File Browser β†₯

Yazi is a fast and powerful file manager written in Rust, designed for efficient use in the terminal.

Installation

For Arch Linux (no need to use Rustup, skip all other steps)

sudo pacman -S yazi ffmpeg 7zip jq poppler fd ripgrep fzf zoxide resvg imagemagick

For Debian/Ubuntu (Yazi must be built with Rustup)

sudo apt install ffmpeg 7zip jq poppler-utils fd-find ripgrep fzf zoxide imagemagick

Build manually (necessary if your Linux distro does not have native packages for Yazi)

Install Rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup update
Clone the repository and build Yazi
git clone https://github.com/sxyazi/yazi.git
cd yazi
cargo build --release --locked
Add 'yazi' and 'ya' to your $PATH
sudo mv target/release/yazi target/release/ya /usr/local/bin/

Basic Usage

Start Yazi:

yazi

Navigation:

  • h/←: Previous directory
  • l/β†’: Enter directory
  • j/↓: Move down the list
  • k/↑: Move up the list
  • q: Quit
  • a: Create a file or directory (must end with / to create a directory)
  • d: Delete a file or directory (sent to the clipboard/trash)
  • D: Permanently delete a file or directory
  • y: Copy a file or directory
  • Y: Stop copying the most recent file or directory
  • x: Cut a file or directory
  • X: Stop cutting the most recent file or directory
  • p: Paste a file or directory (works with both y and x)

πŸ§ͺ Antidote - Zsh Plugin Manager β†₯

Antidote is the cure for slow Zsh plugin management.

Installation

git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-$HOME}/.antidote

Configuration

  1. Create the necessary files:

    touch ~/.zsh_plugins.txt
    mkdir -p ~/.zshrc.d/
    touch ~/.zshrc.d/aliases.zsh
    touch ~/.zshrc.d/keybindings.zsh
    touch ~/.zshrc.d/options.zsh
    touch ~/.zshrc.d/functions.zsh
  2. Add plugins to ~/.zsh_plugins.txt:

    zsh-users/zsh-autosuggestions
    zsh-users/zsh-syntax-highlighting
    • Or add the carefully curated plugins from this repository to your ~/.zsh_plugins.txt file.
  3. Add the following code to your ~/.zshrc file:

    source ${ZDOTDIR:-$HOME}/.antidote/antidote.zsh
    antidote load
    • Or add the out-of-the-box customized code from this repository to your ~/.zshrc file.
  4. Configure your aliases and keybindings:

    Option 1: Use the predefined configuration

    Copy alias configuration:

    cp zshrc.d/aliases.zsh ~/.zshrc.d/

    Copy keybinding configuration:

    cp zshrc.d/keybindings.zsh ~/.zshrc.d/

    Option 2: Customize manually

    Configure aliases

    Edit the aliases file with your favorite editor:

    To edit with nano:

    nano ~/.zshrc.d/aliases.zsh

    Configure keybindings

    Customize the keybindings according to your preferences:

    To edit with nano:

    nano ~/.zshrc.d/keybindings.zsh

    πŸ’‘ Tip: The configuration files include commented-out examples that you can uncomment or modify as needed.

  5. Reload the configuration:

    exit
  6. Open another terminal and enjoy your new, fast Zsh experience!

🎨 Powerlevel10k Customization β†₯

After installing Oh My Zsh or Antidote with the Powerlevel10k theme, run the following command (in case the Powerlevel10k configuration wizard did not start automatically):

p10k configure

Follow the wizard to customize your prompt. How about that? Easy, right?

About

Guide to use and customization (with OMZ or Antidote) for ZSH

Topics

Resources

License

Stars

Watchers

Forks

Languages