Skip to main content
Display file contents with automatic syntax highlighting based on file extension.

Syntax

adist view <file>

Arguments

file
string
required
Path to the file to view. Can be relative to current directory or project directory.

Behavior

  1. Attempts to find file in current working directory
  2. If not found, searches in current project directory
  3. Applies syntax highlighting based on file extension
  4. Displays full file contents with line numbers

Supported Languages

Automatic detection for:
  • JavaScript (.js, .jsx)
  • TypeScript (.ts, .tsx)
  • Python (.py)
  • Go (.go)
  • Rust (.rs)
  • Java (.java)
  • C/C++ (.c, .cpp, .h)
  • JSON (.json)
  • YAML (.yaml, .yml)
  • Markdown (.md)
  • HTML (.html)
  • CSS (.css, .scss, .sass)
  • Shell (.sh, .bash)
  • And many more…

Examples

View file in current directory

adist view README.md

View file in project

adist view src/index.ts

View configuration file

adist view package.json

View nested file

adist view src/components/Button/index.tsx

Output Format

File: src/index.ts
Location: /home/user/project/src/index.ts

[Syntax-highlighted file contents]

File Resolution

Search Order

  1. Current working directory
    • ./file
    • Relative to where command is run
  2. Current project directory
    • Falls back if not found in CWD
    • Uses project path from config

Absolute Paths

Absolute paths work from any location:
adist view /home/user/project/src/app.js

Error Handling

# File not found
 Error viewing file: ENOENT: no such file or directory

# No project selected
No project is currently selected. Run "adist init" or "adist switch" first.

# Permission denied
 Error viewing file: EACCES: permission denied

Use Cases

  • Quick preview of files from search results
  • View files without opening editor
  • Check file contents during development
  • Review code with syntax highlighting in terminal

Comparison with Other Tools

ToolSyntax HighlightingProject-AwareLine Numbers
catNoNoNo
batYesNoYes
adist viewYesYesYes

Tips

  • Combine with adist get to find then view files
  • Use relative paths when inside project directory
  • Output can be piped to other commands

Build docs developers (and LLMs) love