+ We're excited to announce a groundbreaking integration that brings the power of ChatGPT directly
+ into your Nushell environment. This integration represents our vision for the future of
+ command-line interfaces: intelligent, intuitive, and incredibly powerful.
+
+
+
Why AI in a Shell?
+
+ The command line has always been a powerful tool, but it comes with a steep learning curve.
+ Commands have cryptic flags, syntax varies between tools, and documentation can be overwhelming.
+ By integrating ChatGPT, we're making the shell accessible to everyone while enhancing productivity
+ for experienced users.
+
+
+
Key Features
+
+
Natural Language Commands: Ask questions in plain English and get working commands
+
Code Generation: Generate complex scripts and pipelines instantly
+
Interactive Learning: Learn as you work with contextual explanations
+
Error Resolution: Get intelligent suggestions when commands fail
+
Multiple Models: Choose between GPT-4, GPT-4 Turbo, and GPT-3.5 based on your needs
+
+
+
How It Works
+
+ Our integration uses OpenAI's powerful GPT models through a secure backend API. The frontend
+ provides a clean, intuitive interface where you can:
+
+
+
Ask questions about Nushell commands and features
+
Request code examples and explanations
+
Get help debugging issues
+
Learn best practices and advanced techniques
+
+
+
Real-World Applications
+
+ Imagine asking: "How do I parse this JSON file and extract all email addresses?" Instead of
+ searching through documentation, you get an immediate, working solution tailored to your needs.
+ Or: "Why is my pipeline failing?" and receive specific debugging advice.
+
+
+
Privacy and Security
+
+ We take your privacy seriously. The integration is designed with security in mind:
+
+
+
API keys are stored securely and never exposed
+
Conversations are not logged or stored
+
You have full control over what data is sent
+
Open-source implementation for transparency
+
+
+
Get Started Today
+
+ Ready to experience the future of shell interaction? Visit our
+ Live Chatbot page to try it out,
+ or check out our tutorials
+ to learn how to set it up locally.
+
+
+
+ This is just the beginning. We're constantly improving the integration and adding new features.
+ Join our community on Discord
+ to share feedback and ideas!
+
+
+ β Back to Blog
+
+
+
+
+
+
+
diff --git a/docs/blog/cross-platform-journey.html b/docs/blog/cross-platform-journey.html
new file mode 100644
index 0000000000000..49e86d93b2f8d
--- /dev/null
+++ b/docs/blog/cross-platform-journey.html
@@ -0,0 +1,192 @@
+
+
+
+
+
+ Building a True Cross-Platform Shell Experience - Blog - Nushell
+
+
+
+
+
+
+
+
+ In today's heterogeneous computing environment, developers and system administrators work
+ across multiple platforms daily. Yet most shells are tied to specific operating systemsβbash
+ on Linux/macOS, PowerShell on Windows. Nushell was built from the ground up to work
+ identically everywhere.
+
+
+
The Cross-Platform Challenge
+
+ Creating a truly cross-platform shell isn't just about running on different operating systems.
+ It's about providing a consistent experience while respecting platform differences. File paths,
+ environment variables, process management, and system commands all vary between Windows, macOS,
+ and Linux.
+
+
+
Rust: The Foundation
+
+ We chose Rust as our implementation language for several key reasons:
+
+
+
Native Cross-Platform Support: Rust's standard library abstracts platform differences
+
Performance: Compiled code runs fast on all platforms
+
Safety: Memory safety without garbage collection
+
Ecosystem: Rich ecosystem of cross-platform crates
+
+
+
Unified Path Handling
+
+ One of the trickiest aspects of cross-platform development is path handling. Windows uses
+ backslashes and drive letters; Unix systems use forward slashes and a single root. Nushell
+ provides a unified path system that works everywhere:
+
+
+
Paths are represented consistently across platforms
+
Commands work the same way regardless of OS
+
Automatic path conversion when needed
+
Clear error messages for platform-specific limitations
+
+
+
Consistent Command Set
+
+ Traditional shells rely heavily on external commands that vary by platform. Nushell includes
+ a rich set of built-in commands that work identically everywhere:
+
+
+
File Operations: ls, cp, mv, rm work the same on all platforms
+
Process Management: ps, kill, and job control unified
+
System Information: sys command provides consistent OS details
+
Network Operations: http and other network commands standardized
+
+
+
Respecting Platform Differences
+
+ While consistency is important, we don't ignore platform-specific features. Nushell
+ gracefully handles differences:
+
+
+
Windows registry access on Windows
+
Permissions model adapted to each platform
+
Platform-specific environment variables
+
Native process handling for each OS
+
+
+
Testing Across Platforms
+
+ Ensuring true cross-platform compatibility requires rigorous testing. Our CI/CD pipeline
+ runs on Windows, macOS, and Linux, catching platform-specific issues early. We also have
+ active community members on all platforms helping identify and fix edge cases.
+
+
+
The Benefits
+
+ This cross-platform approach delivers real benefits:
+
+
+
Learn Once, Use Everywhere: Master Nushell on one platform, use it on all
+
Portable Scripts: Write scripts that work without modification
+
Team Consistency: Everyone uses the same shell regardless of OS
+
Reduced Mental Overhead: No more remembering platform-specific commands
+
+
+
Community-Driven Development
+
+ Our cross-platform success wouldn't be possible without our diverse community. Contributors
+ from around the world, using different operating systems, help ensure Nushell works well
+ everywhere. If you encounter platform-specific issues, we want to hear about them!
+
+
+
The Future
+
+ We're continuously improving cross-platform support. Upcoming features include better
+ integration with platform-specific tools, enhanced terminal capabilities across different
+ terminal emulators, and more seamless handling of platform differences.
+
+
+
Get Started Today
+
+ Ready to experience true cross-platform shell consistency? Download Nushell for your
+ platform and see the difference. Check our
+ tutorials for
+ installation instructions and getting started guides.
+
+
+ β Back to Blog
+
+
+
+
+
+
+
diff --git a/docs/blog/index.html b/docs/blog/index.html
new file mode 100644
index 0000000000000..a78259e2b9efa
--- /dev/null
+++ b/docs/blog/index.html
@@ -0,0 +1,113 @@
+
+
+
+
+
+ Blog - Nushell
+
+
+
+
+
+
+
Blog
+
Latest updates, insights, and stories from the Nushell community
+ π November 5, 2024 |
+ π€ Nushell Team |
+ π·οΈ AI, Integration, ChatGPT
+
+
+
+ Discover how we've integrated ChatGPT into Nushell to provide intelligent command assistance,
+ code generation, and interactive help. This integration represents a significant step forward
+ in making shell interactions more intuitive and powerful.
+
+ π November 1, 2024 |
+ π€ Nushell Team |
+ π·οΈ Data, Features, Pipeline
+
+
+
+ Traditional shells treat everything as text, but Nushell takes a different approach.
+ Learn how structured data pipelines transform the way you work with JSON, CSV, TOML,
+ and other data formats directly from the command line.
+
+ π October 28, 2024 |
+ π€ Nushell Team |
+ π·οΈ Cross-Platform, Development, Community
+
+
+
+ One shell to rule them all! Explore the journey of making Nushell work seamlessly across
+ Windows, macOS, and Linux. Learn about the challenges we faced and how we achieved
+ true cross-platform compatibility without compromises.
+
+ For decades, Unix shells have treated everything as text streams. While this simplicity was
+ revolutionary in its time, modern workflows demand more. Nushell reimagines the shell with
+ structured data at its core, transforming how we interact with information.
+
+
+
The Text-Only Problem
+
+ Traditional shells pass text between commands. Want to extract the third column from a CSV?
+ You'll need tools like awk, cut, or sed, each with
+ their own syntax quirks. Processing JSON requires external tools like jq.
+ The result? Complex pipelines that are hard to read, write, and maintain.
+
+
+
Nushell's Structured Approach
+
+ Nushell treats data as structured from the start. Files aren't just textβthey're tables,
+ records, or lists with known types. This fundamental shift makes data manipulation intuitive:
+
+
+
# Open a JSON file
+open data.json
+
+# Filter and select columns
+open data.json | where status == "active" | select name email
+
+# Convert between formats
+open data.csv | to json | save output.json
+
+
Built-in Format Support
+
+ Nushell natively understands numerous data formats:
+
+
+
JSON: Parse and manipulate JSON without external tools
+ With structured data comes type safety. Nushell knows the difference between a number,
+ a string, and a date. This prevents common errors and enables intelligent operations:
+
+
+
# Math operations work naturally
+ls | where size > 1mb | get name
+
+# Date comparisons are intuitive
+ps | where start_time < (date now) - 1hr
+
+
Pipeline Visualization
+
+ Because data is structured, Nushell can visualize it beautifully. Tables are formatted
+ automatically, and you can explore nested structures interactively. No more piping to
+ less or counting columns manually.
+
+
+
Real-World Impact
+
+ This structured approach isn't just theoreticalβit transforms daily workflows:
+
+
+
DevOps: Parse API responses and logs without complex scripts
+
Data Analysis: Explore datasets interactively at the command line
+
System Administration: Query and filter system information naturally
+
Development: Process build outputs and test results efficiently
+
+
+
Learning Curve?
+
+ You might think this power comes with complexity, but the opposite is true. Nushell's
+ structured data makes commands more predictable and easier to learn. Once you understand
+ basic operations like where, select, and each,
+ you can apply them consistently across all data types.
+
+
+
Try It Yourself
+
+ Ready to experience structured data in action? Check out our
+ tutorials section for
+ hands-on examples, or try Nushell today and see the difference yourself.
+
+
+ β Back to Blog
+
+
+
+
+
+
+
diff --git a/docs/chatbot/chatbot.js b/docs/chatbot/chatbot.js
new file mode 100644
index 0000000000000..c036ae4b24ed7
--- /dev/null
+++ b/docs/chatbot/chatbot.js
@@ -0,0 +1,342 @@
+// Simulated AI responses for demo purposes
+const simulatedResponses = {
+ 'filter files larger than 1mb': {
+ response: `To filter files larger than 1MB in Nushell, you can use the \`where\` command with a size comparison:
+
+\`\`\`
+ls | where size > 1mb
+\`\`\`
+
+This command:
+1. Lists all files in the current directory with \`ls\`
+2. Filters the results using \`where\` to show only files where \`size > 1mb\`
+
+You can also combine this with other filters:
+
+\`\`\`
+# Show only files (not directories) larger than 1MB
+ls | where type == "file" and size > 1mb
+
+# Sort by size and show top 10
+ls | where size > 1mb | sort-by size --reverse | first 10
+\`\`\`
+
+The size comparison supports units like \`kb\`, \`mb\`, \`gb\`, etc.`
+ },
+ 'where and select': {
+ response: `Great question! \`where\` and \`select\` serve different purposes in Nushell:
+
+**where** - Filters rows (records)
+- Keeps rows that match a condition
+- Works like a SQL WHERE clause
+- Example: \`ls | where size > 1mb\` (keeps only large files)
+
+**select** - Selects columns (fields)
+- Chooses which columns to display
+- Works like a SQL SELECT clause
+- Example: \`ls | select name size\` (shows only name and size columns)
+
+**Common Usage Pattern:**
+\`\`\`
+ls | where size > 1mb | select name size modified
+\`\`\`
+
+This filters to large files (where), then shows only specific columns (select).
+
+**Key Difference:**
+- \`where\` reduces the number of rows
+- \`select\` reduces the number of columns
+
+Think of \`where\` as asking "which items?" and \`select\` as asking "which information about those items?"`
+ },
+ 'json to csv': {
+ response: `Converting JSON to CSV in Nushell is straightforward using the \`to csv\` command:
+
+\`\`\`
+# Basic conversion
+open data.json | to csv | save output.csv
+
+# With custom delimiter (e.g., tab-separated)
+open data.json | to csv --separator "\\t" | save output.tsv
+
+# Without headers
+open data.json | to csv --noheaders | save output.csv
+\`\`\`
+
+**Example with real data:**
+\`\`\`
+# Convert user data
+open users.json | to csv | save users.csv
+
+# Select specific fields before converting
+open users.json | select name email age | to csv | save contacts.csv
+\`\`\`
+
+**For nested JSON:**
+If your JSON has nested objects, you might need to flatten it first:
+\`\`\`
+open data.json | flatten | to csv | save output.csv
+\`\`\`
+
+The conversion preserves the structure and automatically handles the CSV formatting for you!`
+ },
+ 'group data by column': {
+ response: `To group data by a column in Nushell, use the \`group-by\` command:
+
+\`\`\`
+# Basic grouping by a single column
+open data.csv | group-by category
+
+# Group and count items in each group
+open data.csv | group-by status | each { |key, values|
+ {
+ status: $key,
+ count: ($values | length)
+ }
+}
+
+# Group and calculate sum
+open sales.csv | group-by region | each { |key, values|
+ {
+ region: $key,
+ total_sales: ($values | get amount | math sum),
+ avg_sales: ($values | get amount | math avg)
+ }
+}
+\`\`\`
+
+**Real Example - Sales by Region:**
+\`\`\`
+open sales.csv
+ | group-by region
+ | each { |key, values|
+ {
+ region: $key,
+ total: ($values | get amount | math sum),
+ count: ($values | length),
+ average: ($values | get amount | math avg)
+ }
+ }
+ | sort-by total --reverse
+\`\`\`
+
+This groups sales data by region and calculates totals, counts, and averages for each region.`
+ },
+ 'parse analyze log files': {
+ response: `Here's how to parse and analyze log files with Nushell:
+
+**1. Read and Filter Logs:**
+\`\`\`
+# Read log file and filter by keyword
+open app.log | lines | where $it =~ "ERROR"
+
+# Count errors by hour
+open app.log | lines | where $it =~ "ERROR" | length
+\`\`\`
+
+**2. Parse Structured Logs:**
+\`\`\`
+# Parse common log format
+open access.log
+ | lines
+ | parse "{ip} - - [{timestamp}] \"{method} {path} {protocol}\" {status} {size}"
+ | where status >= 400
+
+# For JSON logs
+open app.json | lines | each { |line| $line | from json } | where level == "error"
+\`\`\`
+
+**3. Aggregate Statistics:**
+\`\`\`
+# Count status codes
+open access.log
+ | lines
+ | parse "{ip} - - [{timestamp}] \"{method} {path} {protocol}\" {status} {size}"
+ | group-by status
+ | each { |key, values| { status: $key, count: ($values | length) } }
+ | sort-by count --reverse
+
+# Find most accessed paths
+open access.log
+ | lines
+ | parse "{ip} - - [{timestamp}] \"{method} {path} {protocol}\" {status} {size}"
+ | group-by path
+ | each { |key, values| { path: $key, hits: ($values | length) } }
+ | sort-by hits --reverse
+ | first 10
+\`\`\`
+
+**4. Time-based Analysis:**
+\`\`\`
+# Errors in the last hour
+open app.log
+ | lines
+ | where $it =~ "ERROR"
+ | where modified > ((date now) - 1hr)
+\`\`\`
+
+Nushell makes log analysis powerful and intuitive!`
+ },
+ 'default': {
+ response: `I'm a simulated chatbot demonstrating Nushell AI capabilities. Here are some things I can help with:
+
+**Common Topics:**
+- Basic Nushell commands and syntax
+- Data filtering and transformation
+- Working with structured data (JSON, CSV, TOML)
+- Pipeline operations
+- File and directory operations
+- Data aggregation and analysis
+
+**For Real AI Assistance:**
+Follow our [AI Integration Setup Tutorial](../tutorials/ai-integration-setup.html) to connect to ChatGPT for comprehensive, personalized help.
+
+**Try asking:**
+- "How do I filter files larger than 1MB?"
+- "What's the difference between where and select?"
+- "How can I convert JSON to CSV?"
+
+What would you like to know about Nushell?`
+ }
+};
+
+// DOM elements
+const messagesContainer = document.getElementById('messages');
+const userInput = document.getElementById('user-input');
+const sendBtn = document.getElementById('send-btn');
+const modelSelect = document.getElementById('model-select');
+const questionBtns = document.querySelectorAll('.question-btn');
+
+// Initialize
+let messageCount = 0;
+
+// Add event listeners
+sendBtn.addEventListener('click', sendMessage);
+userInput.addEventListener('keypress', (e) => {
+ if (e.key === 'Enter') {
+ sendMessage();
+ }
+});
+
+questionBtns.forEach(btn => {
+ btn.addEventListener('click', () => {
+ userInput.value = btn.textContent;
+ sendMessage();
+ });
+});
+
+function sendMessage() {
+ const message = userInput.value.trim();
+ if (!message) return;
+
+ // Clear empty state on first message
+ if (messageCount === 0) {
+ messagesContainer.innerHTML = '';
+ }
+
+ // Add user message
+ addMessage(message, 'user');
+ userInput.value = '';
+ userInput.disabled = true;
+ sendBtn.disabled = true;
+
+ // Show typing indicator
+ const typingIndicator = addTypingIndicator();
+
+ // Simulate AI response delay
+ setTimeout(() => {
+ removeTypingIndicator(typingIndicator);
+ const response = getSimulatedResponse(message);
+ addMessage(response, 'assistant');
+ userInput.disabled = false;
+ sendBtn.disabled = false;
+ userInput.focus();
+ }, 1500 + Math.random() * 1000);
+
+ messageCount++;
+}
+
+function addMessage(text, type) {
+ const messageDiv = document.createElement('div');
+ messageDiv.className = `message ${type}-message`;
+
+ if (type === 'assistant') {
+ // Parse markdown-style code blocks
+ text = text.replace(/```(\w*)\n?([\s\S]*?)```/g, (match, lang, code) => {
+ return `
${escapeHtml(code.trim())}
`;
+ });
+ // Parse inline code
+ text = text.replace(/`([^`]+)`/g, '$1');
+ // Parse bold
+ text = text.replace(/\*\*([^*]+)\*\*/g, '$1');
+ // Preserve line breaks
+ text = text.replace(/\n/g, ' ');
+
+ messageDiv.innerHTML = text;
+ } else {
+ messageDiv.textContent = text;
+ }
+
+ messagesContainer.appendChild(messageDiv);
+ messagesContainer.scrollTop = messagesContainer.scrollHeight;
+
+ return messageDiv;
+}
+
+function addTypingIndicator() {
+ const indicator = document.createElement('div');
+ indicator.className = 'typing-indicator active';
+ indicator.innerHTML = '';
+ messagesContainer.appendChild(indicator);
+ messagesContainer.scrollTop = messagesContainer.scrollHeight;
+ return indicator;
+}
+
+function removeTypingIndicator(indicator) {
+ if (indicator && indicator.parentNode) {
+ indicator.parentNode.removeChild(indicator);
+ }
+}
+
+function getSimulatedResponse(question) {
+ const lowerQuestion = question.toLowerCase();
+
+ // Match keywords to responses
+ for (const [key, data] of Object.entries(simulatedResponses)) {
+ if (key !== 'default' && lowerQuestion.includes(key)) {
+ return data.response;
+ }
+ }
+
+ // Default response
+ return simulatedResponses.default.response;
+}
+
+function escapeHtml(text) {
+ const div = document.createElement('div');
+ div.textContent = text;
+ return div.innerHTML;
+}
+
+// Show welcome message after a short delay
+setTimeout(() => {
+ if (messageCount === 0) {
+ messagesContainer.innerHTML = '';
+ addMessage(
+ `Hello! I'm your Nushell AI Assistant. π
+
+I can help you with:
+- Understanding Nushell commands
+- Writing pipelines and filters
+- Working with structured data
+- Converting between file formats
+- And much more!
+
+**Note:** This is a demo with simulated responses. For real ChatGPT assistance, check out our [setup tutorial](../tutorials/ai-integration-setup.html).
+
+Try clicking a suggested question below or ask me anything about Nushell!`,
+ 'assistant'
+ );
+ messageCount++;
+ }
+}, 500);
diff --git a/docs/chatbot/index.html b/docs/chatbot/index.html
new file mode 100644
index 0000000000000..14b4c39b9e715
--- /dev/null
+++ b/docs/chatbot/index.html
@@ -0,0 +1,392 @@
+
+
+
+
+
+ Live AI Chatbot - Nushell
+
+
+
+
+
+
+
+
Live AI Chatbot
+
Experience AI-powered assistance for Nushell
+
+
+
+
+ βΉοΈ Demo Mode: This is a simulated chatbot demonstrating the AI integration concept.
+ For the full experience with real ChatGPT responses, follow the
+ setup tutorial.
+
+
+
+
+
π€ Nushell AI Assistant
+
Ask questions about Nushell commands, features, and best practices
+
+
+
+
+
+
+
+
+
+
+
+
Start a conversation! Ask me anything about Nushell.
+
+
+
+
+
+
+
+
+
+
+
+
π‘ Suggested Questions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/index.html b/docs/index.html
new file mode 100644
index 0000000000000..2a509529e891a
--- /dev/null
+++ b/docs/index.html
@@ -0,0 +1,125 @@
+
+
+
+
+
+ Nushell - A Modern Shell with AI Integration
+
+
+
+
+
+
+
+ Nushell is a modern shell that brings together the Unix philosophy of shells, modern CLI tools,
+ and structured data. It's designed to work with any data source and provides powerful features
+ for data manipulation and automation.
+
+
+ With integrated AI capabilities powered by ChatGPT, Nushell offers an enhanced command-line
+ experience that combines traditional shell power with intelligent assistance.
+
+
+
+
+
+
Why Choose Nushell?
+
+
+
π― Structured Data
+
Work with structured data naturally using tables, lists, and pipelines
+
+
+
π§ Modern Tools
+
Built-in commands for JSON, CSV, TOML, and more
+
+
+
π Cross-Platform
+
Works seamlessly on Windows, macOS, and Linux
+
+
+
π€ AI-Powered
+
Integrated ChatGPT for intelligent command assistance
+
+
+
π Data Visualization
+
Transform and visualize data directly in the shell
+ Learn how to set up and use the ChatGPT integration in Nushell. This powerful feature brings
+ AI-powered assistance directly to your command line, helping you write commands, debug issues,
+ and learn Nushell more efficiently.
+
Copy the key immediatelyβyou won't be able to see it again!
+
+
+
+ β οΈ Security Warning: Never share your API key or commit it to version control.
+ Treat it like a passwordβanyone with your key can use your OpenAI account.
+
+
+
3. Installing the Backend
+
+
Navigate to the Integration Directory
+
cd chatgpt-integration/backend
+
+
Install Python Dependencies
+
pip install -r requirements.txt
+
+
+ This installs Flask (the web framework) and the OpenAI Python library.
+
+
+
4. Configuring the Environment
+
+
Create Environment File
+
cd ..
+cp .env.example .env
+
+
Edit the .env File
+
+ Open the .env file in your favorite text editor and add your API key:
+
+ π‘ Tip: The .env file is already in .gitignore, so it won't be accidentally
+ committed to version control.
+
+
+
5. Starting the Backend Server
+
cd backend
+python server.py
+
+
+ You should see output indicating the server is running:
+
+
* Running on http://127.0.0.1:5000
+ * Press CTRL+C to quit
+
+
6. Accessing the Frontend
+
+
Option 1: Direct File Access
+
+ Open frontend/index.html directly in your web browser by double-clicking the file.
+
+
+
Option 2: Local Web Server (Recommended)
+
+ In a new terminal window:
+
+
cd chatgpt-integration/frontend
+python -m http.server 8000
+
+
+ Then open your browser to http://localhost:8000
+
+
+
7. Using the Chatbot
+
+
Basic Usage
+
+
Select your preferred model (GPT-4, GPT-4 Turbo, or GPT-3.5)
+
Type your question in the input field
+
Press Enter or click "Send"
+
Wait for the AI response
+
+
+
Example Questions
+
How do I list all files larger than 1GB in Nushell?
+
+What's the difference between 'where' and 'filter' in Nushell?
+
+Write a Nushell command to parse JSON and extract email addresses.
+
+How can I convert a CSV file to JSON in Nushell?
+
+
8. Choosing the Right Model
+
+
GPT-4: Most accurate, best for complex questions. Slower and more expensive.
+
GPT-4 Turbo: Faster than GPT-4, good balance of speed and quality.
+
GPT-3.5 Turbo: Fastest and cheapest, good for simple questions.
+
+
+
+ π‘ Tip: Start with GPT-3.5 Turbo for quick questions. Upgrade to GPT-4
+ for complex scenarios or when you need the highest accuracy.
+
+
+
9. Cost Management
+
+
Understanding Costs
+
+ OpenAI charges based on tokens (roughly 4 characters = 1 token):
+
+
+
GPT-4: ~$0.03 per 1K input tokens, ~$0.06 per 1K output tokens
+
GPT-3.5 Turbo: ~$0.0005 per 1K input tokens, ~$0.0015 per 1K output tokens
+
+
+
Cost-Saving Tips
+
+
Use GPT-3.5 for simple questions
+
Be concise in your prompts
+
Set usage limits in your OpenAI dashboard
+
Monitor usage regularly
+
+
+
10. Troubleshooting
+
+
Backend Won't Start
+
+
Check Python version: python --version (should be 3.8+)
+ Pipelines are the heart of Nushell. In this tutorial, you'll learn how to chain commands
+ together to filter, transform, and analyze data efficiently. These skills will make you
+ significantly more productive with Nushell.
+
+
+
1. Understanding Pipelines
+
+ In Nushell, data flows through pipelines using the | operator. Unlike traditional
+ shells that pass text, Nushell passes structured dataβtables, records, and listsβthrough the pipeline.
+
+
# Simple pipeline: list files and filter
+ls | where size > 1mb
+
+
2. The where Command
+
+ The where command filters data based on conditions:
+
+
+
Basic Filtering
+
# Filter by exact match
+ls | where type == "file"
+
+# Filter by comparison
+ls | where size > 1mb
+
+# Filter by string pattern
+ls | where name =~ ".txt"
+
+
Complex Conditions
+
# Multiple conditions with 'and'
+ls | where type == "file" and size > 1mb
+
+# Multiple conditions with 'or'
+ls | where name =~ ".txt" or name =~ ".md"
+
+# Negation with 'not'
+ls | where not (type == "dir")
+
+
3. The select Command
+
+ Use select to choose which columns to display:
+
+
# Select single column
+ls | select name
+
+# Select multiple columns
+ls | select name size modified
+
+# Rename columns while selecting
+ls | select name file_size:size
+
+
4. Transforming Data with each
+
+ The each command applies an operation to each item in the pipeline:
+
+
# Convert all file names to uppercase
+ls | select name | each { |it| $it.name | str upcase }
+
+# Add .backup extension to all files
+ls | select name | each { |it| $it.name + ".backup" }
+
+# Calculate size in MB for each file
+ls | each { |it| $it.size / 1mb }
+
+
5. Working with JSON Data
+
+
Reading JSON
+
# Open and parse JSON file
+open data.json
+
+# Example: users.json with array of users
+open users.json | where age > 25 | select name email
+
+
Transforming JSON
+
# Extract nested data
+open config.json | get database.host
+
+# Filter array within JSON
+open api-response.json | get results | where status == "active"
+
+
Creating JSON
+
# Convert table to JSON
+ls | select name size | to json
+
+# Save as JSON file
+ls | select name size | to json | save output.json
+
+
6. Working with CSV Data
+
+
Reading CSV
+
# Open CSV file (automatically parsed as table)
+open sales.csv
+
+# Filter and analyze
+open sales.csv | where amount > 1000 | get total | math sum
+
+
Converting Formats
+
# CSV to JSON
+open data.csv | to json | save data.json
+
+# JSON to CSV
+open data.json | to csv | save data.csv
+
+
7. Aggregation and Math
+
+
Basic Math Operations
+
# Sum of all file sizes
+ls | get size | math sum
+
+# Average file size
+ls | get size | math avg
+
+# Find maximum
+ls | get size | math max
+
+# Find minimum
+ls | get size | math min
+
+
Grouping Data
+
# Group files by type
+ls | group-by type
+
+# Count items in each group
+ls | group-by type | each { |key, values| { type: $key, count: ($values | length) } }
+
+
8. The reduce Command
+
+ reduce combines all values in a list into a single value:
+
# Get first 5 items
+ls | first 5
+
+# Get last 3 items
+ls | last 3
+
+# Skip first 10 items
+ls | skip 10
+
+# Take items from middle
+ls | skip 5 | first 5
+
+
11. Real-World Examples
+
+
Example 1: Find Large Files
+
# Find files larger than 10MB, sort by size, show top 10
+ls **/*
+ | where type == "file" and size > 10mb
+ | sort-by size --reverse
+ | first 10
+ | select name size
+ Welcome to Nushell! This tutorial will guide you through your first steps with this modern,
+ structured-data shell. By the end, you'll understand the basics and be ready to explore more
+ advanced features.
+
+
+
1. Installation
+
+
On macOS and Linux
+
# Using Homebrew
+brew install nushell
+
+# Or download from GitHub releases
+# https://github.com/nushell/nushell/releases
+
+
On Windows
+
# Using winget
+winget install nushell
+
+# Or using Chocolatey
+choco install nushell
+
+
Verify Installation
+
# Check the version
+nu --version
+
+
2. Starting Nushell
+
+ Simply type nu in your terminal to start Nushell:
+
+
nu
+
+
+ You'll see a welcome message and a prompt. Congratulationsβyou're now in Nushell!
+
+
+
3. Basic Navigation
+
+
Listing Files
+
+ The ls command shows directory contents, but unlike traditional shells,
+ it returns a structured table:
+
+
ls
+
+
+ Notice how the output is formatted as a table with columns like name, type, size, and modified date.
+ This is structured data!
+
+
+
Changing Directories
+
cd Documents
+cd ..
+cd ~
+
+
Current Directory
+
pwd
+
+
4. Working with Structured Data
+
+
Filtering Results
+
+ Here's where Nushell shines. You can filter the ls output like database queries:
+
+
# Show only directories
+ls | where type == dir
+
+# Show files larger than 1MB
+ls | where size > 1mb
+
+# Show files modified in the last week
+ls | where modified > ((date now) - 7day)
+
+
Selecting Columns
+
# Show only names
+ls | select name
+
+# Show name and size
+ls | select name size
+
+
Sorting
+
# Sort by size
+ls | sort-by size
+
+# Sort by size in reverse order
+ls | sort-by size --reverse
+
+
5. File Operations
+
+
Creating Files and Directories
+
# Create a directory
+mkdir my-project
+
+# Create a file
+touch hello.txt
+
+# Create a file with content
+"Hello, Nushell!" | save greeting.txt
+
+
Copying and Moving
+
# Copy a file
+cp source.txt destination.txt
+
+# Move a file
+mv oldname.txt newname.txt
+
+# Copy a directory
+cp -r source-dir dest-dir
+
+
Removing Files
+
# Remove a file
+rm unwanted.txt
+
+# Remove a directory
+rm -r old-directory
+
+
+ π‘ Tip: Nushell will ask for confirmation before deleting files by default,
+ making it safer than traditional shells.
+
+
+
6. Reading File Contents
+
+
Plain Text Files
+
# View file contents
+open file.txt
+
+# View with pagination
+open large-file.txt | less
+
+
Structured Files
+
+ Nushell automatically parses common file formats:
+
+
# Open JSON file (automatically parsed)
+open data.json
+
+# Open CSV file (automatically parsed as table)
+open data.csv
+
+# Open TOML configuration
+open config.toml
+
+
7. Your First Pipeline
+
+ Let's combine what we've learned into a powerful pipeline:
+
+
# Find the 5 largest files in the current directory
+ls | where type == file | sort-by size --reverse | first 5 | select name size
+
+
+ This command:
+
+
+
Lists all items with ls
+
Filters to only files with where type == file
+
Sorts by size (largest first) with sort-by size --reverse
+
Takes the first 5 items with first 5
+
Shows only name and size columns with select name size
+
+
+
8. Getting Help
+
+ Nushell has excellent built-in documentation:
+
+
# Get help for any command
+help ls
+help where
+help open
+
+# List all commands
+help commands
+
+# Search for commands
+help commands | where name =~ "date"
+
+
9. Useful Built-in Commands
+
+
System Information
+
# View system information
+sys
+
+# Check CPU info
+sys cpu
+
+# Check memory usage
+sys mem
+
+
Process Management
+
# List running processes
+ps
+
+# Find specific processes
+ps | where name =~ "chrome"
+
+
Date and Time
+
# Current date and time
+date now
+
+# Format dates
+date now | format date "%Y-%m-%d"
+
+
10. Next Steps
+
+ Congratulations! You've learned the basics of Nushell. Here's what to explore next:
+
+ Your first steps with Nushell! Learn how to install Nushell, understand basic concepts,
+ and run your first commands. This tutorial covers navigation, file operations, and
+ the fundamentals of working with structured data.
+
+ Unlock the power of Nushell's pipeline system. Learn how to filter, transform, and
+ manipulate structured data. Work with JSON, CSV, and other formats. Master commands
+ like where, select, each, and reduce.
+
+ Configure and use the ChatGPT integration in Nushell. Learn how to set up your API key,
+ use the chatbot for command assistance, generate scripts with AI, and leverage
+ intelligent features to boost your productivity.
+