Zum Inhalt springen

iTerm2 für macOS – Das ultimative Terminal-Setup mit Oh My Zsh & Powerlevel10k (2025)

· von

iTerm2 ist das Terminal für macOS. Mit Oh My Zsh und Powerlevel10k wird's zum Power-Tool. Hier die komplette Anleitung von Installation bis zu fortgeschrittenen Features – mit großem Cheatsheet am Ende.

iTerm2 Terminal Setup auf macOS – Übersicht

~12 Min. Lesezeit · Veröffentlicht am

🚀 Quick Start für Eilige:

  • iTerm2 installieren: brew install --cask iterm2
  • Oh My Zsh: sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • Powerlevel10k: git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Installation & Erste Schritte

🟢 Einsteiger-Bereich: Basics für den Start

Installation via Homebrew (empfohlen)

# Falls Homebrew noch nicht installiert ist:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# iTerm2 installieren
brew install --cask iterm2

Erste Konfiguration

Nach dem ersten Start solltest du diese Grundeinstellungen vornehmen:

  1. Shell festlegen: iTerm2 → Settings → Profiles → General → Command: /bin/zsh
  2. Unlimited Scrollback: Profiles → Terminal → Scrollback Buffer → Unlimited scrollback ✓
  3. Natural Text Editing: Profiles → Keys → Key Mappings → Presets → Natural Text Editing

Grundkonfiguration

Appearance anpassen

# Minimales Theme aktivieren
iTerm2 → Settings → Appearance → General → Theme: Minimal

# Transparenz für coolen Look
Profiles → Window → Transparency: ~15%
Profiles → Window → Blur: ✓

Fonts installieren

Für Powerlevel10k brauchst du einen Nerd Font:

# MesloLGS NF installieren (empfohlen für Powerlevel10k)
brew tap homebrew/cask-fonts
brew install --cask font-meslo-lg-nerd-font

# In iTerm2 aktivieren
Profiles → Text → Font: MesloLGS NF
Size: 13pt (oder nach Geschmack)

ZSH mit Oh My Zsh einrichten

Oh My Zsh Installation

# Oh My Zsh installieren
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# Backup der originalen .zshrc wird automatisch erstellt als .zshrc.pre-oh-my-zsh

Wichtige Plugins aktivieren

Editiere ~/.zshrc und füge diese Plugins hinzu:

# ~/.zshrc
plugins=(
  git                   # Git aliases und Funktionen
  zsh-autosuggestions  # Fish-like autosuggestions
  zsh-syntax-highlighting # Syntax highlighting
  web-search           # Schnelle Web-Suchen
  z                    # Schnelle Navigation
  macos               # macOS-spezifische Shortcuts
  vscode              # VS Code Integration
  docker              # Docker Completion
  npm                 # npm Completion
)

# Plugins installieren (falls noch nicht vorhanden)
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Nützliche Aliases einrichten

# ~/.zshrc oder ~/.oh-my-zsh/custom/aliases.zsh

# Navigation
alias ..="cd .."
alias ...="cd ../.."
alias ll="ls -la"
alias l="ls -la"

# Git Shortcuts
alias gs="git status"
alias ga="git add"
alias gc="git commit -m"
alias gp="git push"
alias gpl="git pull"
alias gco="git checkout"
alias gb="git branch"

# Entwicklung
alias ns="npm start"
alias nb="npm run build"
alias nt="npm test"
alias y="yarn"
alias p="pnpm"

# Projekt-Shortcuts
alias work="cd ~/WorkSource"
alias proj="cd ~/iCloud/Projekte"

# System
alias reload="source ~/.zshrc"
alias zshconfig="code ~/.zshrc"
alias ohmyzsh="code ~/.oh-my-zsh"

🔥 Fortgeschrittene Features ab hier: Power-User Territory

Powerlevel10k Theme

Installation

# Powerlevel10k klonen
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
  ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

# In ~/.zshrc aktivieren
ZSH_THEME="powerlevel10k/powerlevel10k"

# Terminal neu starten oder
source ~/.zshrc

Konfiguration Wizard

Beim ersten Start führt dich p10k durch die Konfiguration:

# Manuell starten falls nötig
p10k configure

# Meine Empfehlungen:
# - Prompt Style: (3) Rainbow
# - Character Set: (1) Unicode
# - Show current time: (2) 24-hour format
# - Prompt Height: (2) Two lines
# - Prompt Connection: (1) Disconnected
# - Prompt Frame: (2) Left
# - Prompt Spacing: (2) Sparse
# - Icons: (2) Many icons
# - Prompt Flow: (1) Concise
# - Enable Transient Prompt: (y) Yes
# - Instant Prompt Mode: (1) Verbose

Anpassungen in ~/.p10k.zsh

# Segmente anpassen
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
  os_icon       # OS Logo
  dir           # Aktuelles Verzeichnis
  vcs           # Git Status
  node_version  # Node.js Version wenn in Projekt
  newline       # Neue Zeile
  prompt_char   # Prompt Character
)

typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
  status        # Exit Status des letzten Commands
  command_execution_time # Ausführungszeit
  background_jobs # Hintergrund-Jobs
  time          # Uhrzeit
)

Profiles & Themes

Profile für verschiedene Zwecke

# Profile duplizieren
iTerm2 → Settings → Profiles → Duplicate Profile

# Beispiel-Profile:
1. "Default" - Tägliche Arbeit
2. "Production" - Roter Hintergrund für SSH zu Servern
3. "Presentation" - Große Schrift für Screensharing
4. "Minimal" - Ohne Ablenkungen zum Fokussieren

Profile automatisch wechseln

# Automatic Profile Switching basierend auf Pfad
Profiles → Advanced → Automatic Profile Switching

# Regel hinzufügen:
If the hostname matches: *.production.com
Use profile: Production

# Oder per Shell-Integration
echo -e "\033]50;SetProfile=Production\a"

Color Schemes

Empfohlene Themes (importieren via Settings → Profiles → Colors → Color Presets):

# Themes via Kommandozeile installieren
# Dracula
curl -o ~/Downloads/Dracula.itermcolors https://raw.githubusercontent.com/dracula/iterm/master/Dracula.itermcolors

# Dann importieren in iTerm2
Settings → Profiles → Colors → Color Presets → Import...

Split Panes & Window Management

Pane-Management Hotkeys

# Standard Hotkeys
⌘D - Split vertikal
⌘⇧D - Split horizontal
⌘⌥↑/↓/←/→ - Zwischen Panes navigieren
⌘⇧Enter - Pane maximieren/minimieren
⌘W - Pane schließen

# Custom Hotkeys einrichten
Settings → Keys → Key Bindings → +

# Beispiele:
⌘K - Clear Buffer (wie in Terminal.app)
⌘⇧T - Neuer Tab mit gleichem Verzeichnis
⌘1-9 - Direkt zu Tab springen

Broadcast Input

Gleiche Befehle an mehrere Panes senden:

# Aktivieren für alle Panes
Shell → Broadcast Input → Broadcast Input to All Panes in Current Tab

# Use Cases:
- Multiple Server gleichzeitig updaten
- Gleiche Config auf mehreren Hosts
- Parallele Git-Operations in mehreren Repos

Hotkeys & Productivity Features

Hotkey Window

Terminal mit einem Tastendruck von überall aufrufen:

# Einrichten
Settings → Keys → Hotkey → Create a Dedicated Hotkey Window
Hotkey: ⌥Space (oder deine Wahl)
Profile: Hotkey Window (neues Profil)

# Profil-Einstellungen für Hotkey Window
- Style: Full-Width Top of Screen
- Screen: Screen with Cursor
- Space: All Spaces

Instant Replay

# Die letzten 4MB Terminal-Output durchsuchen
View → Start Instant Replay (⌘⌥B)

# Navigation:
← → - Frame für Frame
⇧← ⇧→ - 1 Sekunde vor/zurück
ESC - Instant Replay beenden

Advanced Paste

# Smart Paste Options
Edit → Paste Special → Advanced Paste (⌘⌥V)

Optionen:
- Tabs to Spaces konvertieren
- Escaping für Shell
- Zeilenumbrüche entfernen
- Base64 encode/decode
- Geschwindigkeit limitieren (für alte Systeme)

Shell-Integration & Status Bar

Shell Integration installieren

# Automatisch installieren
iTerm2 → Install Shell Integration

# Oder manuell
curl -L https://iterm2.com/shell_integration/zsh -o ~/.iterm2_shell_integration.zsh
echo "source ~/.iterm2_shell_integration.zsh" >> ~/.zshrc

Features nach Installation

Status Bar konfigurieren

# Aktivieren
Profiles → Session → Status bar enabled ✓

# Komponenten hinzufügen
Configure Status Bar → Drag & Drop Components

# Empfohlene Komponenten:
- Current Directory
- Git State
- CPU Usage
- Memory Usage
- Network Throughput
- Clock
- Battery (für MacBooks)

Eigene Status Bar Components

#!/bin/bash
# ~/Library/Application Support/iTerm2/Scripts/status_node.sh
# Node Version anzeigen

if command -v node &> /dev/null; then
    echo "Node $(node -v)"
else
    echo "No Node"
fi

# In Status Bar: Add Component → Interpolated String
# String: \(user.status_node)

VS Code Integration

iTerm als Terminal in VS Code

# VS Code settings.json
{
  "terminal.external.osxExec": "iTerm.app",
  "terminal.integrated.fontFamily": "MesloLGS NF",
  "terminal.integrated.fontSize": 13,
  "terminal.integrated.env.osx": {
    "FIG_NEW_SESSION": "1"
  }
}

VS Code aus iTerm öffnen

# code Command installieren (falls noch nicht vorhanden)
# In VS Code: ⌘⇧P → Shell Command: Install 'code' command in PATH

# Verwendung
code .                    # Aktuelles Verzeichnis
code ~/WorkSource/projekt # Spezifisches Projekt
code file.js             # Einzelne Datei
code -n                  # Neues Fenster
code -r                  # Im aktuellen Fenster

Smart Selection Rules für Pfade

# iTerm2 erkennt Dateipfade automatisch
# Settings → Profiles → Advanced → Smart Selection → Edit

# Regel für VS Code Links (file:line:column)
Regular Expression: ([~/][^:]+):(\d+):(\d+)
Action: Run Command...
Parameter: code -g \1:\2:\3

# Jetzt kannst du auf Fehler-Output klicken und VS Code
# öffnet die Datei an der richtigen Stelle!

Raycast Integration

iTerm mit Raycast steuern

#!/bin/bash
# ~/Scripts/open-iterm-here.sh
# @raycast.schemaVersion 1
# @raycast.title Open iTerm Here
# @raycast.mode silent
# @raycast.packageName iTerm
# @raycast.icon 📟

osascript -e 'tell application "iTerm"
    create window with default profile
    tell current session of current window
        write text "cd '"$PWD"'"
    end tell
end tell'

Quick Terminal Commands via Raycast

#!/bin/bash
# ~/Scripts/git-status-iterm.sh
# @raycast.schemaVersion 1
# @raycast.title Git Status in iTerm
# @raycast.mode silent
# @raycast.icon 📊

osascript -e 'tell application "iTerm"
    tell current window
        create tab with default profile
        tell current session
            write text "git status"
        end tell
    end tell
end tell'

Troubleshooting

Häufige Probleme & Lösungen

1. Langsamer Prompt

# Powerlevel10k Instant Prompt aktivieren
# Am Anfang der ~/.zshrc:
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# Git-Status in großen Repos deaktivieren
git config --add oh-my-zsh.hide-status 1
git config --add oh-my-zsh.hide-dirty 1

2. Zeichen werden nicht richtig dargestellt

# Nerd Font installiert?
brew list | grep nerd-font

# In iTerm2 aktiviert?
# Profiles → Text → Font sollte "... NF" oder "... Nerd Font" sein

# Unicode Version prüfen
Profiles → Text → Unicode Version: Unicode 9 oder höher

3. Copy & Paste funktioniert nicht wie erwartet

# Einstellungen prüfen
General → Selection → 
  ✓ Applications in terminal may access clipboard
  ✓ Copy to pasteboard on selection

# Für tmux-Nutzer in ~/.tmux.conf:
set -g mouse on
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"

4. SSH Sessions haben falsches Theme

# LC_TERMINAL Variable setzen
# In ~/.zshrc auf lokalem Mac:
export LC_TERMINAL=iTerm2
export LC_TERMINAL_VERSION=$TERM_PROGRAM_VERSION

# In ~/.ssh/config:
Host *
  SendEnv LC_TERMINAL LC_TERMINAL_VERSION

Großes Cheatsheet

🎯 iTerm2 Keyboard Shortcuts

Navigation

⌘T          - Neuer Tab
⌘W          - Tab/Pane schließen
⌘D          - Split vertikal  
⌘⇧D         - Split horizontal
⌘[/]        - Zwischen Panes wechseln
⌘⌥↑/↓/←/→   - Pane-Navigation
⌘⇧Enter     - Pane maximieren
⌘1-9        - Zu Tab 1-9 springen
⌘←/→        - Zwischen Tabs wechseln
⌘⌥E         - Expose all Tabs
⌘/          - Cursor Position finden

Text & Editing

⌘F          - Suchen
⌘G          - Nächstes Suchergebnis
⌘⇧G         - Vorheriges Suchergebnis  
⌘K          - Clear Buffer
⌘⌥B         - Instant Replay
⌘⇧H         - Paste History
⌘⌥V         - Advanced Paste
⌘;          - Autocomplete
⌃L          - Clear Screen (behält Scrollback)

Session Management

⌘Enter      - Fullscreen toggle
⌘⇧S         - Save Window Arrangement
⌘⇧R         - Restore Window Arrangement
⌘⌥I         - Broadcast Input toggle
⌘⇧I         - Show/Hide Timestamps
⌘⌥A         - Alert on next Mark
⌘⇧M         - Set Mark
⌘⇧J         - Jump to Mark

Shell Integration Shortcuts

⌘⇧↑/↓       - Zum vorherigen/nächsten Befehl
⌘⇧;         - Command History Popup
⌘⌥/         - Recent Directories Popup
⌘⌥B         - Instant Replay
⌘⇧E         - Select Output of Last Command
⌘⇧A         - Select Output including Prompt
⌃⌘Space     - Emoji & Symbols

🚀 Oh My Zsh Aliases & Commands

Git Plugin Aliases

g           - git
ga          - git add
gaa         - git add --all
gb          - git branch
gc          - git commit -v
gc!         - git commit -v --amend
gca         - git commit -v -a
gcam        - git commit -a -m
gco         - git checkout
gcp         - git cherry-pick
gd          - git diff
gf          - git fetch
gl          - git pull
gp          - git push
gst         - git status
glg         - git log --stat
glgg        - git log --graph
glgga       - git log --graph --decorate --all

Z Plugin (Frecent Directories)

z [keyword]  - Jump to frecent directory
z -l         - List matches
z -c         - Restrict to subdirs of PWD
z -e         - Echo best match, don't cd
z -r         - Rank matches by access time
z -t         - Recent matches first

Web Search Plugin

google [query]    - Google Suche
github [query]    - GitHub Suche
stackoverflow [q] - StackOverflow Suche
duckduckgo [q]    - DuckDuckGo Suche

⚡ Powerlevel10k Commands

p10k configure      - Konfigurations-Wizard
p10k reload        - Config neu laden
p10k segment       - Segment-Hilfe anzeigen

# Temporäre Änderungen
p10k display '*/dir'=hide      - Verzeichnis ausblenden
p10k display '*/dir'=show      - Verzeichnis einblenden
p10k display '*/vcs'=hide      - Git-Status ausblenden
p10k display '*/time'=hide     - Zeit ausblenden

# Instant Prompt
p10k-instant-prompt-enable     - Aktivieren
p10k-instant-prompt-disable    - Deaktivieren

🛠️ Nützliche Shell-Befehle

System & Prozesse

htop              - Prozess-Manager (brew install htop)
ncdu              - Disk Usage Analyzer (brew install ncdu)
tldr [command]    - Simplified man pages (brew install tldr)
bat [file]        - cat mit Syntax Highlighting (brew install bat)
exa               - Moderner ls Ersatz (brew install exa)
fd [pattern]      - Besseres find (brew install fd)
rg [pattern]      - Ripgrep, schneller als grep (brew install ripgrep)

Netzwerk

mtr [host]        - Kombiniert ping und traceroute
ss -tulpn         - Offene Ports anzeigen
curl wttr.in      - Wetter im Terminal
speedtest-cli     - Speedtest (brew install speedtest-cli)
httpie            - HTTP Client (brew install httpie)

Development

jq                - JSON processor (brew install jq)
diff-so-fancy     - Bessere Git diffs (brew install diff-so-fancy)
tig               - Text-mode interface for Git (brew install tig)
lazygit           - Terminal UI for Git (brew install lazygit)
gh                - GitHub CLI (brew install gh)

📝 ~/.zshrc Template

# Enable Powerlevel10k instant prompt
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# Path to oh-my-zsh
export ZSH="$HOME/.oh-my-zsh"

# Theme
ZSH_THEME="powerlevel10k/powerlevel10k"

# Plugins
plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
  z
  web-search
  macos
  vscode
  docker
  npm
)

source $ZSH/oh-my-zsh.sh

# User configuration
export LANG=de_DE.UTF-8
export EDITOR='code -w'

# Aliases
alias ..="cd .."
alias ...="cd ../.."
alias ll="ls -la"
alias gs="git status"
alias work="cd ~/WorkSource"

# Functions
mkcd() { mkdir -p "$1" && cd "$1" }
backup() { cp "$1" "$1.backup.$(date +%Y%m%d_%H%M%S)" }

# Node Version Manager
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

🎨 Empfohlene iTerm2 Settings

# Optimale Performance-Settings
Preferences → General → GPU Rendering: ✓
Preferences → General → Native Full Screen Windows: ✗
Preferences → Advanced → Experimental Features → Metal Renderer: Yes

# Backup & Sync
Preferences → General → Preferences → 
  Load preferences from custom folder: ~/iCloud/iTerm2
  Save changes: Automatically

# Sinnvolle Defaults
Profiles → Terminal → Scrollback: Unlimited
Profiles → Terminal → Save lines to scrollback when app status bar is present: ✓
Profiles → Keys → Option key: Esc+
Profiles → Advanced → Triggers → Add:
  Regex: error|fail|fatal
  Action: Highlight Text
  Text Color: Red