cd
Browse / Zsh Cheat Sheet
Zsh Cheat Sheet
A comprehensive cheat sheet for Zsh, covering essential commands, expressions, process substitution, and configuration tips for efficient command-line usage.
Zsh Basics
      
        
            Shell Navigation
        
      
    
  | 
   | 
      
   Change directory to home.  | 
| 
   
  | 
      
   Change directory to   | 
| 
   
  | 
      
   Change to the previous directory.  | 
| 
   
  | 
      
   Print the current working directory.  | 
| 
   
  | 
      
   Push current directory onto stack and change to   | 
| 
   
  | 
      
   Pop directory from stack and change to it.  | 
      
        
            File and Directory Management
        
      
    
  | 
   
  | 
      
   List files and directories in the current directory.  | 
| 
   
  | 
      
   List files with detailed information.  | 
| 
   
  | 
      
   Create a new directory named   | 
| 
   
  | 
      
   Remove the specified   | 
| 
   
  | 
      
   Recursively remove the directory   | 
| 
   
  | 
      
   Copy   | 
      
        
            Basic Commands
        
      
    
  | 
   
  | 
      
   Print   | 
| 
   
  | 
      
   Display the contents of   | 
| 
   
  | 
      
   View   | 
| 
   
  | 
      
   Display the first 10 lines of   | 
| 
   
  | 
      
   Display the last 10 lines of   | 
| 
   
  | 
      
   Search for   | 
Expressions and History
      
        
            History Expansion
        
      
    
  | 
   
  | 
      
   Execute the last command.  | 
| 
   
  | 
      
   Execute the command with the specified history number.  | 
| 
   
  | 
      
   The last word of the previous command.  | 
| 
   
  | 
      
   All words from the previous command (except the command name).  | 
| 
   
  | 
      
   The first argument of the previous command.  | 
| 
   
  | 
      
   Execute the nth command from the end of the history list.  | 
      
        
            Filename Generation (Globbing)
        
      
    
  | 
   
  | 
      
   Matches any string of characters.  | 
| 
   
  | 
      
   Matches any single character.  | 
| 
   
  | 
      
   Matches a, b, or c.  | 
| 
   
  | 
      
   Matches any character except a, b, or c.  | 
| 
   
  | 
      
   Matches any character in the range a to z.  | 
| 
   
  | 
      
   Recursively matches files in subdirectories.  | 
      
        
            Modifiers in History Expansion
        
      
    
  | 
   
  | 
      
   Substitute   | 
| 
   
  | 
      
   Repeat the last substitution.  | 
| 
   
  | 
      
   Global substitution.  | 
| 
   
  | 
      
   Remove a trailing filename component, leaving only the head.  | 
| 
   
  | 
      
   Remove all leading filename components, leaving the tail.  | 
| 
   
  | 
      
   Remove a filename extension, leaving the root name.  | 
Process Substitution & Redirection
      
        
            Process Substitution
        
      
    
  | 
   
  | 
      
   Treat the output of   | 
| 
   
  | 
      
   Treat a file as the input to   | 
| 
   Example:  | 
      
   
  | 
| 
   Example:  | 
      
   
  | 
| 
   Example:  | 
      
   
  | 
      
        
            Redirection
        
      
    
  | 
   
  | 
      
   Redirect output to a file (overwrites).  | 
| 
   
  | 
      
   Redirect output to a file (appends).  | 
| 
   
  | 
      
   Redirect standard error to a file.  | 
| 
   
  | 
      
   Redirect both standard output and standard error to a file.  | 
| 
   
  | 
      
   Pipe output of one command to the input of another.  | 
| 
   
  | 
      
   Send output to both standard output and   | 
      
        
            Combining Redirection and Process Substitution
        
      
    
  | 
   Example: 
Compares two sorted files and outputs the lines unique to each file and the lines common to both.  | 
| 
   Example: 
Grep through gzipped file without explicit extraction.  | 
| 
   Example: 
Counts the number of files in the current directory.  | 
Zsh Configuration
      
        
            Zsh Configuration Files
        
      
    
  | 
   
  | 
| 
   
  | 
| 
   
  | 
| 
   
  | 
| 
   
  | 
| 
   
  | 
      
        
            Options and Settings
        
      
    
  | 
   
  | 
      
   Enable a Zsh option.  | 
| 
   
  | 
      
   Disable a Zsh option.  | 
| 
   
  | 
      
   Bind a key sequence to a Zsh command.  | 
| 
   
  | 
      
   Create an alias for a command.  | 
| 
   
  | 
      
   Set an environment variable.  | 
| 
   
  | 
      
   Execute commands from   | 
      
        
            Example Configuration Snippets
        
      
    
  | 
   Enable command autocorrection: 
     | 
| 
   Set up a custom alias: 
     | 
| 
   Configure history settings: 
     | 
| 
   Enable vi mode: 
     |