AI-enhanced terminal aliases for developers — streamline workflows with custom Zsh shortcuts like pfiles, ptree, and ChatGPT-assisted commands in a futuristic coding environment.

To streamline project analysis and improve collaboration with ChatGPT, I created a set of aliases: pfiles, pfilescd, ptree, ptreecd, pg, and pgcd. These aliases generate .txt files that provide a comprehensive overview of a project's structure and codebase. These files can be uploaded to ChatGPT for help with coding, debugging, and refactoring.


Aliases Overview

1. pfiles

  • Purpose: Concatenates all .ts, .tsx, .json, and .md files in the src directory into a single file.
  • Output File: -files-YYYY-MM-DD.txt
  • Usage:
pfiles

2. pfilescd

  • Purpose: Concatenates all text-based files in the current directory (excluding common build/system folders and .txt files), prefixing each section with the filename.
  • Output File: -files-YYYY-MM-DD__.txt
  • Usage:
pfilescd

3. ptree

  • Purpose: Creates a tree view of the src directory, excluding ignored folders and files.
  • Output File: -structure-YYYY-MM-DD.txt
  • Usage:
ptree

4. ptreecd

  • Purpose: Creates a tree view of the current directory with filtering.
  • Output File: -structure-YYYY-MM-DD__.txt
  • Usage:
ptreecd

5. pg The g stands for GO!

  • Purpose: Runs pfiles and then ptree in sequence.
  • Usage:
pg

6. pgcd

  • Purpose: Runs pfilescd and then ptreecd in sequence.
  • Usage:
pgcd

Setting Up Custom Aliases in .zshrc and .bash_profile

This section shows how to create a reusable alias file (~/.zshrc_my_aliases), import it into your main shell config (.zshrc or .bash_profile), and make sure it's sourced properly.


Step 1: Create the Alias File

Open the alias file using VS Code:

code ~/.zshrc_my_aliases

Paste the following content into it:

# pfiles alias: Finds and concatenates files in the 'src' directory (with extensions .ts, .tsx, .json, .md) into a file named -files-YYYY-MM-DD.txt.
alias pfiles="find src -type f \\( -name '*.ts' -o -name '*.tsx' -o -name '*.json' -o -name '*.md' \\) -exec echo '===== {} =====' \\; -exec cat {} \\; > $(basename $(pwd))-files-$(date +%Y-%m-%d).txt 2>/dev/null && echo '✅ $(basename $(pwd))-files-$(date +%Y-%m-%d).txt created.'"

# pfilescd alias: Finds and concatenates all text-based files in the current directory (excluding 'node_modules', '.git', '.next', '/temp', and '.txt' files) into a file named -files-YYYY-MM-DD__.txt. Each file's content is prefixed with its path for clarity.
alias pfilescd='project_name=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)") && current_dir=$(basename "$PWD") && date_str=$(date +%F) && filename="${project_name}-files-${date_str}__${current_dir}.txt" && find . -type f \( -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.json" -o -name "*.md" -o -name "*.html" -o -name "*.css" \) ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/.next/*" ! -path "*/temp/*" ! -name "*.txt" -exec sh -c '"'"'for file; do echo "===== $file ====="; cat "$file"; echo; done'"'"' sh {} + > "$filename" && echo "Saved to $filename"'

# ptree alias: Generates a directory tree structure for the 'src' directory only, excluding 'node_modules', '.git', 'dist', '.next', and '.txt' files. Saves the output to a file named -structure-YYYY-MM-DD.txt.
alias ptree="tree src -I 'node_modules|.git|dist|.next|*.txt' -L 10 > $(basename $(pwd))-structure-$(date +%Y-%m-%d).txt 2>/dev/null && echo '✅ $(basename $(pwd))-structure-$(date +%Y-%m-%d).txt created.'"

# ptreecd alias: Generates a directory tree structure for the current directory (excluding 'node_modules', '.git', 'dist', '.next', '/temp', and '.txt' files) and saves it to a file named -structure-YYYY-MM-DD__.txt.
alias ptreecd='project_name=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)") && current_dir=$(basename "$PWD") && date_str=$(date +%F) && filename="${project_name}-structure-${date_str}__${current_dir}.txt" && tree -I "node_modules|.git|dist|.next|temp|*.txt" > "$filename" && echo "Saved to $filename"'

# pg alias: Runs pfiles first to create a file list, then runs ptree to generate a directory tree structure.
alias pg="pfiles && ptree"

# pgcd alias: Runs pfilescd followed by ptreecd to generate both the concatenated file contents and the directory structure of the current project.
alias pgcd='pfilescd && ptreecd'

Step 2: Import into .zshrc

Edit your .zshrc file:

code ~/.zshrc

Add the following line at the end:

source ~/.zshrc_my_aliases

Then reload your terminal config:

source ~/.zshrc

Step 3: Bash Users – Import into .bash_profile

If you're using Bash:

code ~/.bash_profile

Add this line:

source ~/.zshrc_my_aliases

Then reload:

source ~/.bash_profile

Example Output Files

Assume your project is called ai-chat-assistant.

1. ai-chat-assistant-files-2025-03-23.txt

Contains the contents of all matching files in src.

Example:

// ===== src/app/layout.tsx =====
import type { Metadata } from 'next'
import { Geist, Geist_Mono } from 'next/font/google'
import './globals.css'

...

// ===== src/app/page.tsx =====
import React from 'react'

export default function Page() {
    return (
        <div>
            <h1 className="text-lg font-bold">App Page</h1>
            <p>This is the app page content.</p>
        </div>
    )
}

...

2. ai-chat-assistant-structure-2025-03-23.txt

Contains the tree structure of the src folder.

Example:

src
├── app
│   ├── layout.tsx
│   └── page.tsx
└── components
    └── ui
        ├── button.tsx
        └── card.tsx

How to Use with ChatGPT

  1. Generate the .txt files using pg or pgcd.
  2. Upload them in the ChatGPT chat window.
  3. Use a prompt like:
I'm working on a Next.js TypeScript project called `ai-chat-assistant`.

1. `ai-chat-assistant-files-2025-03-23.txt`: all code content.
2. `ai-chat-assistant-structure-2025-03-23.txt`: directory layout.

Can you help debug `src/app/api/chat/route.ts`?

Benefits

  • Quickly packages relevant project files for review.
  • Gives ChatGPT proper context.
  • Works across directories and project structures.
  • Easy to reuse and extend.