iTerm2 Configuration for Enhanced Terminal Workflow with rz/sz File Transfers

Obtaining iTerm2

Acquire the latest release from the officcial iTerm2 website and complete the installation process.

Configuring Homebrew

Before executing the installation command, select a appropriate mirror source based on your terminal environment. Verify your shell type first.

# Install Homebrew with mirror support
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install/HEAD/install.sh)"

# Configure mirror for faster downloads
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

If the cask tap is missing after installation, initialize it manually:

brew tap homebrew/cask

Deploying Zsh

Execute the appropriate command for your operating system:

# For macOS
brew install zsh

# For RHEL/CentOS/Fedora
sudo dnf install -y zsh git

# For Debian/Ubuntu
sudo apt update && sudo apt install -y zsh git

Installing Oh My Zsh Framework

Use the gitee mirror for faster installation in certain regions:

export REMOTE='https://gitee.com/mirrors/oh-my-zsh.git'
sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

Extending with Plugins

Syntax Highlighting

macOS approach:

brew install zsh-syntax-highlighting
echo "source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

Linux approach:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
# Enable the plugin
sed -i '/^plugins=/s/)/ zsh-syntax-highlighting)/' ~/.zshrc

Command Autosuggestions

macOS approach:

brew install zsh-autosuggestions
echo "source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

Linux approach:

git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
# Enable the plugin
sed -i '/^plugins=/s/)/ zsh-autosuggestions)/' ~/.zshrc

Reload configuration:

source ~/.zshrc

Enabling rz/sz File Transfer

Install the lrzsz package:

brew install lrzsz  # macOS
# or
sudo apt install lrzsz  # Debian/Ubuntu
# or
sudo dnf install lrzsz  # RHEL/CentOS

Create transfer scripts in your local bin directory:

mkdir -p ~/bin
cat > ~/bin/iterm2-recv-zmodem << 'EOF'
#!/bin/bash
osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1
if [ $? -eq 0 ]; then
    /usr/local/bin/rz -E -b --bufsize 4096
else
    /usr/bin/rz -E -b --bufsize 4096
fi
EOF

cat > ~/bin/iterm2-send-zmodem << 'EOF'
#!/bin/bash
osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1
if [ $? -eq 0 ]; then
    /usr/local/bin/sz "$@" -b --bufsize 4096
else
    /usr/bin/sz "$@" -b --bufsize 4096
fi
EOF

chmod +x ~/bin/iterm2-{recv,send}-zmodem

Configure iTerm2 triggers:

  1. Open PreferencesProfilesAdvancedTriggers
  2. Add two triggers:
    • Receive trigger: Regular Expression: \*\*B0100, Action: Run Silent Coprocess, Parameters: ~/bin/iterm2-recv-zmodem
    • Send trigger: Regular Expresssion: \*\*B00000000000000, Action: Run Silent Coprocess, Parameters: ~/bin/iterm2-send-zmodem

Visual Enhancements

Applying Themes

Download preferred color schemes and import via PreferencesProfilesColorsColor PresetsImport.

Setting Background Images

Navigate to PreferencesProfilesWindowBackground Image to apply custom visuals.

Adjust transparency and blur effects under the same panel for optimal readability.

Tags: iTerm2 Zsh rz-sz Terminal homebrew

Posted on Thu, 06 Aug 2026 16:11:50 +0000 by Balu