Comprehensive Command-Line Reference for macOS and Unix Workflows

Homebrew Package Ecosystem

Core Package Operations

  • brew help / brew help <tool>: Display global commmand reference or detailed usage for a specific utility.
  • brew --version: Print current build identifier alongside Ruby and Git runtime dependencies.
  • brew config: Dump internal configuration state including cellars, repository paths, and compiler flags.
  • brew install <formula>: Fetch and compile a package. Common modifiers: --force (overwrite existing), --HEAD (compile from latest repository commit), --build-from-source (skip pre-compiled binaries), --with-feature (enable optional compile-time flags).
  • brew reinstall <formula>: Rebuild a formula in place to resolve broken symlinks or missing dependencies.
  • brew uninstall <formula>: Remove a package. Append --force to ignore reverse dependencies or --zap to purge configuration files and cached data.
  • brew search <term>: Query available formulas. Use --desc to filter by metadata descriptions.

Maintenance & Lifecycle

  • brew update: Synchronize the core repository index without touching installed packages.
  • brew upgrade [<formula>]: Pull the latest versions for all managed packages or a single target.
  • brew pin <formula> / brew unpin <formula>: Freeze a package version to exclude it from automatic upgrades.
  • brew list [<formula>]: Enumerate installed formulas. Add --full-name to display scoped taps. Targeting a specific formula reveals its filesystem layout.
  • brew info <formula>: Retrieve metadata, dependency graphs, optional build flags, and installation paths.
  • brew cleanup [-n] [-s] [<formula>]: Purge outdated cellar versions. Use -n for dry-run mode, -s to include source tarballs, or target a single package.
  • brew autoremove: Prune orphaned dependencies that no longer satisfy reverse dependency trees.
  • brew doctor: Diagnose environmental misconfigurations, permission mismatches, and missing system libraries.

Casks, Services & Taps

  • brew install --cask <app> / brew uninstall --cask <app>: Deploy or remove macOS graphical applications.
  • brew services list: Monitor background daemons managed by launchd. Start with start, halt with stop, or cycle with restart. Use run for foreground-only sessions without persistence.
  • brew tap <user>/<repo> / brew untap <user>/<repo>: Register or deregister third-party formula repositories.
  • brew deps --tree <formula>: Visualize the hierarchical dependency chain.
  • brew uses <formula>: Identify which installed packages require the specified target.
  • brew outdated: Generate a diff between installed versions and upstream releases.

Mirror Redirection

# Override API endpoint for metadata retrieval
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"

# Redirect pre-compiled binary downloads
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

# Point Git remote to a domestic mirror (legacy workflows)
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

Fish Shell & Core CLI Utilities

Navigation & File Manipulation

  • ls -lah --sort=time: List directory contents with human-readable sizes, hidden files, and reverse chronological ordering.
  • cd, cd /, cd ../: Navigate to home, root, or parent directories respectively.
  • pwd: Resolve absolute path of the current working directory.
  • mkdir -p project/src/{core,utils}: Recursively generate nested directory trees.
  • cp -rvi data/ backup/: Recursively duplicate directories while preserving attributes and prompting before overwrites.
  • mv old_name.txt new_name.txt: Relocate or rename filesystem objects.
  • rm -rf temp_build/: Forcefully remove directories and contents. Exercise extreme caution.
  • ln -s /usr/local/bin/tool ~/bin/tool: Generate symbolic links that delegate to target paths.

Stream Processing & Editors

  • cat: Concatenate and output file streams. Redirect using > or append with >>.
  • less: Paginated viewer. Press q to exit, /pattern to search forward.
  • head -n 20 log.txt / tail -f daemon.log: Preview leading lines or attach to live log streams.
  • nano / vim: Terminal-based editors. Navigate buffers using standard modal or shortcut interfaces (:wq to persist changes in Vim).

System Diagnostics & Networking

  • system_profiler SPHardwareDataType: Extract hardware specifications and firmware revisions.
  • df -h / du -sh /var/log: Report filesystem capacity and aggregate directory sizes.
  • htop: Interactive process monitor with sortable columns and tree views. Requires manual installation.
  • ps aux | grep nginx: Snapshot running tasks and filter by process signature.
  • kill -15 <PID> / pkill -f worker.js: Send termination signals to specific PIDs or matching process names.
  • ping -c 5 api.example.com: Validdate connectivity via ICMP echo requests.
  • lsof -iTCP:8080 -sTCP:LISTEN: Identify processes bound to specific ports.
  • curl -o payload.json -L https://api.example.com/data: Retrieve remote resources with follow-redirect support.
  • scp local.conf admin@remote.host:/etc/app/: Securely transfer files across SSH sessions.
  • ssh deploy@192.168.1.50: Establish remote shell access.

Permissions & Archives

  • chmod 644 config.yaml / chmod +x deploy.sh: Adjust read/write/execute bits for owners and groups.
  • chown developer:staff app.log: Reassign file ownership and primary group.
  • tar -xzf backup.tar.gz -C /restore/point/ / tar -czf snapshot.tar.gz /data/: Extract or compress archives using gzip.
  • zip -r archive.zip docs/ / unzip archive.zip -d ./output: Handle standard ZIP containers.

Oh-My-Fish Framework

Core & Plugin Orchestration

  • omf / omf help <cmd>: Invoke framework entry point or retrieve usage documentation.
  • omf update: Fetch latest framework patches and synchronize all managed extensions.
  • omf install <plugin>: Retrieve plugins via name, Git URL, or filesystem path. Example: omf install nvm.
  • omf uninstall <plugin> / omf list: Remove extensions or enumerate the current inventory.
  • omf upgrade [<plugin>]: Pull upstream revisions for all or specific components.
  • omf search <keyword> / omf info <name>: Browse the registry and inspect metadata before installation.

Theme Routing & Configuration

  • omf theme <name>: Switch the prompt renderer. Precede with omf install --theme dracula to fetch first.
  • omf reload: Apply config.fish modifications and plugin hooks without restarting the shell.
  • omf doctor: Validate environment prerequisites and detect broken symlinks or missing dependencies.
  • omf self-update / omf destroy: Update the framework core independently or perform a complete teardown of the extension system.
  • omf repo add|remove|update: Manage third-party plugin registries.
  • omf new plugin|theme <slug>: Scaffold boilerplate structures for custom extensions.

Prompt Configuration with Starship

To deploy a cross-shell, information-dense prompt, follow this initialization sequence:

  1. Download the binary bundle: curl -sS https://starship.rs/install.sh | sh
  2. Bootstrap shell integration: starship init fish | source
  3. Apply a color scheme: starship preset tokyo-night -o ~/.config/starship.toml
  4. Install a compatible Nerd Font (e.g., JetBrainsMono or FiraCode) and assign it to your terminal emulator.
  5. Persist the integration by appending starship init fish | source to ~/.config/fish/config.fish, then reload or restart the session.

Conda Environment & Dependency Management

Initialization & Environment Lifecycle

  • Installation: Retrieve the Miniconda installer, execute the script, and register the shell hooks: ~/miniconda3/bin/conda init fish. Activate with source ~/.config/fish/config.fish.
  • conda create -n data-pipeline python=3.11 pandas numpy: Provision an isolated workspace with specific runtimes and libraries.
  • conda activate data-pipeline / conda deactivate: Toggle environment state on Unix/macOS systems.
  • conda env list / conda info --envs: Display registered environments and highlight the active scope.
  • conda create -n backup --clone data-pipeline: Duplicate configurations. To rename, clone to a new name, then remove the original: conda remove -n old-env --all.

Dependency Resolution & Channel Routing

  • conda install -c conda-forge scikit-learn: Fetch packages from alternate distribution channels.
  • conda update --all: Resolve and upgrade the entire dependency tree (verify compatibility before execution).
  • conda list / conda search tensorflow: Audit installed binaries or query the repository index.
  • conda clean --all -y: Purge index caches, unused tarballs, and extracted sources to reclaim disk space.
  • Mirror Configuration: ``` conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes
    
     Revert with `conda config --remove-key channels` and verify routing via `conda config --show channels`.
    
    

Serialization

  • conda env export -f environment-lock.yml: Generate a reproducible manifest including exact build strings.
  • conda env create -f environment-lock.yml: Reconstruct an environment from the exported manifest.

Python Package Index (pip) Workflow

  • pip install requests==2.31.0 / pip install numpy --upgrade: Pin versions or bump to latest stable releases.
  • pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com: Batch install using a requirements file while routing through a domestic index.
  • pip uninstall flask -y: Remove packages silently.
  • pip list --outdated --format=columns: Generate a tabular report of packages pending updates.
  • pip show pandas: Inspect installation directory, dependencies, and metadata.
  • pip freeze > project-deps.txt: Capture exact version hashes for deterministic deployment.
  • python3 -m pip install --upgrade pip: Self-upgrade the package manager using the module execution pattern to avoid executable shadowing.

Python Interpreter & Virtualization

  • python3 --version: Verify the active interpreter release.
  • python3: Launch the REPL. Exit via Ctrl+D.
  • Virtual Environment Isolation:
    • python3 -m venv .venv: Scaffold an isolated environment containing a dedicated interpreter and site-packages directory.
    • source .venv/bin/activate: Inject environment variables and PATH overrides. The shell prompt will reflect the active scope.
    • deactivate: Restore system PATH and exit the isolated workspace.
  • Script Execution: python3 process_data.py dataset.csv --threshold 0.85 ``` import sys input_params = sys.argv[1:] print(f"Processing {len(input_params)} CLI arguments:", input_params)
  • python3 -c "import sys; print(sys.executable)": Print the absolute filesystem path of the running interpreter binary.
  • pip cache purge: Clear the local wheel cache to force fresh downloads during dependency resolution.

Tags: homebrew fish-shell oh-my-fish starship-prompt conda-environments

Posted on Tue, 19 May 2026 01:19:04 +0000 by qartis