Saltar a contenido

Mac Terminal (Terminal.app) - macOS Native Terminal

*Ultima referencia macOS Terminal.app para características nativas, AppleScript y productividad *

"Clase de la hoja"

########################################################################################################################################################################################################################################################## Copiar todos los comandos
########################################################################################################################################################################################################################################################## Generar PDF seleccionado/button

■/div titulada

Terminal.app es el emulador terminal incorporado para macOS, proporcionando una profunda integración con el sistema operativo y ofreciendo características como la automatización AppleScript, el soporte de Touch Bar y la integración perfecta con los servicios de macOS. Aunque puede no tener las características avanzadas de terminales de terceros, Terminal. app destaca en confiabilidad, integración nativa de macOS y facilidad de uso. Esta hoja de trampolín completa cubre atajos esenciales, opciones de personalización y funciones avanzadas para maximizar su productividad con MacOS Terminal.

Comienzo

Terminal de apertura

# 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

Gestión básica de ventana

# 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)

Atajos de teclado esenciales

Operaciones de texto

# 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
# 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)

Fuente y pantalla

# 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

Perfiles y personalización

Gestión del perfil

# 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

Creación de perfiles personalizados

# 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
# 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)

Características avanzadas

Integración 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 de automatización

# 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

Touch Bar Support

# 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

Integración de servicios

# 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

Integración Shell

Configuración de Shell

# 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

Prompt Customization

# 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\] $ "

Ventana y Gestión de Tab

Operaciones de ventana

# 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

Tab Management

# 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

Inspector y Debugging

# 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

Personalización y temas

Esquemas de color

# 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

Configuración de fuentes

# 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

Personalización

# 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

Características de seguridad

Entrada segura del teclado

# 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

Perfil de seguridad

# 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

Integración con macOS

Integración del Finder

# 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

Integración Spotlight

# 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)

Centro de notificación

# 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"'

Solución de problemas

Cuestiones comunes

# 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

Reset y recuperación

# 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)

Modo de depuración

# 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_*

Consejos y mejores prácticas

Consejos de productividad

# 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

Integración del flujo de trabajo

# 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

Prácticas óptimas de personalización

# 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 ofrece una experiencia terminal sólida y fiable que se integra perfectamente con macOS. Aunque puede carecer de algunas características avanzadas encontradas en terminales de terceros, su integración nativa, el soporte de AppleScript y las opciones de personalización robustas hacen que sea una opción excelente para los usuarios de Mac que valoran la simplicidad y la integración del sistema. La profunda integración de macOS, combinada con características como el apoyo de Touch Bar y la integración de Servicios, crea un flujo de trabajo cohesivo que se siente natural dentro del ecosistema de Apple.