Mac Terminal (Terminal.app) - MacOS Terminal autochtone
*Ultimate macOS Terminal.app référence pour les fonctionnalités natives, AppleScript, et la productivité *
Terminal.app est l'émulateur de terminal intégré pour macOS, fournissant une intégration profonde avec le système d'exploitation et offrant des fonctionnalités telles que l'automatisation AppleScript, le support Touch Bar, et l'intégration transparente avec les services macOS. Bien qu'il puisse ne pas avoir les fonctionnalités avancées des terminaux tiers, Terminal. application excelle dans la fiabilité, l'intégration macOS native, et la facilité d'utilisation. Cette feuille de tri couvre les raccourcis essentiels, les options de personnalisation et les fonctionnalités avancées pour maximiser votre productivité avec macOS Terminal.
Commencer
Terminal d'ouverture
# Launch methods
Cmd+Space → "Terminal" # Spotlight search
Applications → Utilities → Terminal # Finder navigation
Launchpad → Other → Terminal # Launchpad
/Applications/Utilities/Terminal.app # Direct path
# Quick access setup
# Dock: Drag Terminal to Dock for quick access
# Desktop: Create alias on Desktop
Gestion de base des fenêtres
# New window/tab
Cmd+N # New window
Cmd+T # New tab
Cmd+Shift+N # New window with same command
# Close window/tab
Cmd+W # Close current tab
Cmd+Shift+W # Close current window
Cmd+Q # Quit Terminal
# Navigate tabs
Cmd+Shift+Left/Right # Previous/next tab
Cmd+1-9 # Jump to tab number
Cmd+\\\\{/\\\\} # Previous/next tab (alternative)
```_
## Raccourcis de clavier essentiels
### Opérations textuelles
```bash
# Copy/Paste
Cmd+C # Copy selected text
Cmd+V # Paste
Cmd+Shift+V # Paste escaped text
Cmd+Option+V # Paste selection
# Selection
Double-click # Select word
Triple-click # Select line
Cmd+A # Select all
Shift+Arrow # Extend selection
# Find and Replace
Cmd+F # Find
Cmd+G # Find next
Cmd+Shift+G # Find previous
Cmd+E # Use selection for find
```_
### Navigation et défilement
```bash
# Scrolling
Page Up/Down # Page scroll
Cmd+Up/Down # Scroll to top/bottom
Cmd+Left/Right # Scroll to beginning/end of line
# History navigation
Cmd+R # Show previous command in history
Up/Down arrows # Command history
Ctrl+R # Reverse search history
# Screen management
Cmd+K # Clear screen
Cmd+L # Clear screen (alternative)
Ctrl+L # Clear screen (shell command)
Police et affichage
# Font size
Cmd+Plus # Increase font size
Cmd+Minus # Decrease font size
Cmd+0 # Reset to default size
# Window management
Cmd+M # Minimize window
Cmd+H # Hide Terminal
Cmd+Option+H # Hide other applications
F11 # Toggle full screen
Profils et personnalisation
Gestion du profil
# Access profiles
Terminal → Preferences → Profiles # Profile settings
Cmd+, # Open preferences
# Profile operations
# Duplicate profile: Select profile → Gear icon → Duplicate
# Import profile: Gear icon → Import
# Export profile: Gear icon → Export
# Set default profile
# Select profile → Default button
Création de profils personnalisés
# Profile settings categories
Text:
- Font family, size, and style
- Character and line spacing
- Text rendering options
- Cursor style and blinking
Window:
- Window size and position
- Background color and opacity
- Background image
- Blur and vibrancy effects
Shell:
- Startup command
- Working directory
- Environment variables
- Shell exit behavior
Keyboard:
- Key mappings
- Option key behavior
- Function key behavior
- Delete key behavior
Advanced:
- Terminal type (TERM variable)
- Character encoding
- Scrollback buffer size
- Bell settings
Configurations de profils populaires
# Development Profile
Name: Development
Font: SF Mono, 14pt
Background: Dark gray (#1e1e1e)
Text: Light gray (#d4d4d4)
Cursor: Block, blinking
Scrollback: 10000 lines
Working Directory: ~/Development
# Server Profile
Name: Server
Font: Menlo, 12pt
Background: Black
Text: Green (#00ff00)
Cursor: Underline
Bell: Visual bell only
Title: Server - %host%
# Presentation Profile
Name: Presentation
Font: SF Mono, 18pt
Background: White
Text: Black
Cursor: Block, non-blinking
Window: Large (120x40)
Caractéristiques avancées
Intégration AppleScript
-- Basic Terminal control
tell application "Terminal"
activate
do script "ls -la"
end tell
-- Create new window with command
tell application "Terminal"
do script "cd ~/Documents && ls" in window 1
end tell
-- Multiple commands
tell application "Terminal"
set newTab to do script "cd ~/Projects"
do script "git status" in newTab
do script "npm start" in newTab
end tell
-- Window management
tell application "Terminal"
set bounds of front window to \\\\{100, 100, 800, 600\\\\}
set background color of front window to \\\\{0, 0, 0\\\\}
end tell
-- Profile switching
tell application "Terminal"
set current settings of front window to settings set "Pro"
end tell
Scripts d'automatisation
# Create Terminal automation script
#!/usr/bin/osascript
tell application "Terminal"
activate
-- Development environment setup
set devTab to do script "cd ~/Development"
do script "git status" in devTab
-- Start development server
set serverTab to do script "cd ~/Development/myapp"
do script "npm start" in serverTab
-- Open logs
set logTab to do script "cd ~/Development/myapp"
do script "tail -f logs/app.log" in logTab
end tell
# Save as .scpt file and run with:
osascript development-setup.scpt
Toucher le support de la barre
# Touch Bar customization (macOS with Touch Bar)
# Available in Terminal → View → Customize Touch Bar
# Default Touch Bar items
- New Tab
- Split View
- Profiles
- Font Size
- Full Screen
# Custom Touch Bar setup
1. View → Customize Touch Bar
2. Drag desired items to Touch Bar
3. Arrange in preferred order
4. Click Done
Intégration des services
# macOS Services with Terminal
# Available in any app: App Menu → Services
# New Terminal at Folder
# Right-click folder in Finder → Services → New Terminal at Folder
# New Terminal Tab at Folder
# Right-click folder in Finder → Services → New Terminal Tab at Folder
# Custom services (Automator)
1. Open Automator
2. New → Service
3. Add "Run Shell Script" action
4. Set input to "files or folders"
5. Save service
Intégration Shell
Configuration de la coque
# Default shell settings
# Terminal → Preferences → General → Shells open with
Options:
- Default login shell (/bin/zsh)
- Command: /bin/bash
- Command: /usr/local/bin/fish
# Shell-specific configurations
# Zsh (default macOS shell)
~/.zshrc # Zsh configuration
~/.zprofile # Zsh login configuration
# Bash
~/.bash_profile # Bash login configuration
~/.bashrc # Bash configuration
# Environment variables
export TERM=xterm-256color # Terminal type
export CLICOLOR=1 # Enable colors
export LSCOLORS=ExFxBxDxCxegedabagacad # ls colors
Personnalisation rapide
# Zsh prompt (in ~/.zshrc)
# Simple prompt
PS1="%n@%m %1~ %# "
# Colorful prompt
PS1="%F\\\\{green\\\\}%n@%m%f %F\\\\{blue\\\\}%1~%f %# "
# Git-aware prompt
autoload -Uz vcs_info
precmd() \\\\{ vcs_info \\\\}
zstyle ':vcs_info:git:*' formats ' (%b)'
setopt PROMPT_SUBST
PS1='%F\\\\{green\\\\}%n@%m%f %F\\\\{blue\\\\}%1~%f%F\\\\{red\\\\}$\\\\{vcs_info_msg_0_\\\\}%f %# '
# Bash prompt (in ~/.bash_profile)
export PS1="\u@\h \W $ "
# Colorful bash prompt
export PS1="\[\033[32m\]\u@\h\[\033[00m\] \[\033[34m\]\W\[\033[00m\] $ "
Gestion des fenêtres et des onglets
Opérations des fenêtres
# Window creation
Cmd+N # New window
Cmd+Shift+N # New window with same command
Option+Cmd+N # New window with same working directory
# Window arrangement
Window → Arrange in Front # Bring all windows forward
Window → Merge All Windows # Combine windows into tabs
# Split view (macOS)
View → Show Tab Bar # Show tab bar
Drag tab out of window # Create new window
Drag tab to another window # Merge windows
Gestion des onglets
# Tab operations
Cmd+T # New tab
Cmd+W # Close tab
Cmd+Shift+W # Close window
# Tab navigation
Cmd+Shift+Left/Right # Previous/next tab
Cmd+1-9 # Jump to tab number
Cmd+\\\\{/\\\\} # Previous/next tab
# Tab customization
# Right-click tab → Rename Tab
# Right-click tab → Duplicate Tab
# Right-click tab → Move Tab to New Window
Inspecteur et débogage
# Terminal Inspector
Shell → Show Inspector # Show window inspector
Cmd+I # Toggle inspector
# Inspector information
- Process information
- Window dimensions
- Character encoding
- Terminal type
- Working directory
- Command history
# Debug information
View → Show Tab Bar # Show tab information
View → Show All Tabs # Show all tab titles
Personnalisation et thèmes
Schémas de couleurs
# Built-in themes
- Basic
- Pro (dark theme)
- Grass (green on black)
- Homebrew (amber on black)
- Man Page (black on white)
- Novel (sepia tones)
- Ocean (blue theme)
- Red Sands (red theme)
- Silver Aerogel (light theme)
- Solid Colors (various solid backgrounds)
# Custom color configuration
Terminal → Preferences → Profiles → [Profile] → Text
- Text color
- Bold text color
- Background color
- Selection color
- Cursor color
Configuration de la police
# Font settings
Terminal → Preferences → Profiles → [Profile] → Text
# Recommended fonts for programming
- SF Mono (system default)
- Menlo (classic macOS)
- Monaco (classic Mac)
- JetBrains Mono (with ligatures)
- Fira Code (with ligatures)
- Source Code Pro
- Inconsolata
# Font features
- Font family and size
- Character spacing
- Line spacing
- Anti-aliasing
- Use bold fonts
- Allow blinking text
Personnalisation du contexte
# Background options
Terminal → Preferences → Profiles → [Profile] → Window
# Background types
- Solid color
- Color and transparency
- Background image
- Built-in patterns
# Transparency effects
- Opacity slider (0-100%)
- Blur background
- Use vibrancy (macOS visual effects)
# Background image settings
- Image file selection
- Scaling options (Stretch, Tile, Center, etc.)
- Image opacity
Caractéristiques de sécurité
Entrée sécurisée du clavier
# Enable secure input
Terminal → Secure Keyboard Entry # Toggle secure input
# When enabled:
- Prevents other applications from reading keystrokes
- Useful for entering passwords
- Indicated by lock icon in menu bar
- Automatically disabled when Terminal loses focus
Sécurité du profil
# Secure profile settings
Terminal → Preferences → Profiles → [Profile] → Shell
# Security options
- Prompt before closing if processes are running
- Prompt before closing if shell is running
- Ask before closing terminal
- Warn when shell exits abnormally
# Environment security
- Avoid storing sensitive data in environment variables
- Use secure methods for credential storage
- Regular profile cleanup
Intégration avec macOS
Intégration des chercheurs
# Open Terminal from Finder
# Enable: System Preferences → Keyboard → Shortcuts → Services
# Check "New Terminal at Folder" and "New Terminal Tab at Folder"
# Usage
Right-click folder → Services → New Terminal at Folder
Right-click folder → Services → New Terminal Tab at Folder
# Custom Finder toolbar
1. View → Customize Toolbar in Finder
2. Drag Terminal icon to toolbar
3. Click folder, then Terminal icon
Intégration des projecteurs
# Terminal in Spotlight
Cmd+Space → "Terminal" # Launch Terminal
Cmd+Space → "term" # Quick launch
# Index Terminal content
# Terminal history is not indexed by Spotlight
# Use shell history search instead (Ctrl+R)
Centre de notification
# Terminal notifications
# Configure in System Preferences → Notifications → Terminal
# Notification triggers
- Process completion (long-running commands)
- Bell character (ASCII 7)
- Custom notifications via osascript
# Custom notification script
#!/bin/bash
osascript -e 'display notification "Command completed" with title "Terminal"'
Dépannage
Questions communes
# Font rendering problems
# Try different fonts or adjust anti-aliasing
Terminal → Preferences → Profiles → Text → Font
# Color display issues
# Check color profile and terminal type
echo $TERM # Should show xterm-256color
export TERM=xterm-256color # Set if needed
# Keyboard input problems
# Reset keyboard settings
Terminal → Preferences → Profiles → Keyboard → Restore Defaults
# Performance issues
# Reduce scrollback buffer
Terminal → Preferences → Profiles → Advanced → Scrollback
Réinitialisation et récupération
# Reset Terminal preferences
# Quit Terminal completely
rm ~/Library/Preferences/com.apple.Terminal.plist
# Restart Terminal
# Reset specific profile
Terminal → Preferences → Profiles → [Profile] → Restore Defaults
# Clear Terminal history
history -c # Clear current session
rm ~/.zsh_history # Clear zsh history (if using zsh)
rm ~/.bash_history # Clear bash history (if using bash)
Mode de débogage
# Enable debug logging
# Add to shell configuration file
export TERM_DEBUG=1
# View system logs
Console.app → System Reports → Terminal
# Terminal crash logs
~/Library/Logs/DiagnosticReports/Terminal_*
Conseils et pratiques exemplaires
Conseils en matière de productivité
# Quick profile switching
# Create keyboard shortcuts for different profiles
# System Preferences → Keyboard → Shortcuts → App Shortcuts
# Add shortcuts for Terminal → Shell → New Window/Tab → [Profile]
# Efficient tab management
# Use descriptive tab titles
# Right-click tab → Rename Tab
# Use Cmd+1-9 for quick tab switching
# Command history optimization
# Increase history size in shell configuration
export HISTSIZE=10000 # Number of commands in memory
export HISTFILESIZE=20000 # Number of commands in history file
Intégration des flux de travail
# Development workflow
# Create profiles for different projects
# Use AppleScript for environment setup
# Integrate with version control systems
# System administration
# Create secure profiles for server access
# Use key-based authentication
# Implement logging and audit trails
# Automation
# Use shell functions for common tasks
# Create aliases for frequently used commands
# Implement custom services for Finder integration
Pratiques exemplaires de personnalisation
# Profile organization
# Create profiles for different purposes
# Use descriptive names
# Export profiles for backup
# Color scheme selection
# Choose high contrast for readability
# Consider accessibility requirements
# Test in different lighting conditions
# Font selection
# Use monospace fonts for programming
# Consider font size for screen resolution
# Enable ligatures for modern coding fonts
Terminal.app offre une expérience terminal solide et fiable qui s'intègre parfaitement avec macOS. Bien qu'il puisse manquer de fonctionnalités avancées trouvées dans des terminaux tiers, son intégration native, AppleScript support, et des options de personnalisation robustes en font un excellent choix pour les utilisateurs de Mac qui apprécient la simplicité et l'intégration système. L'intégration macOS profonde, combinée à des fonctionnalités comme le support Touch Bar et l'intégration Services, crée un flux de travail cohérent qui se sent naturel dans l'écosystème Apple.