<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Evander Q. L. Darrow</title>
    <description>The latest articles on DEV Community by Evander Q. L. Darrow (@eqld).</description>
    <link>https://dev.to/eqld</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3018178%2Fe6148c47-87fb-4259-9169-9e7abe67eb4b.png</url>
      <title>DEV Community: Evander Q. L. Darrow</title>
      <link>https://dev.to/eqld</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/eqld"/>
    <language>en</language>
    <item>
      <title>Neural Shell (nlsh): Your AI-Powered Command Line Assistant</title>
      <dc:creator>Evander Q. L. Darrow</dc:creator>
      <pubDate>Sat, 05 Apr 2025 18:20:27 +0000</pubDate>
      <link>https://dev.to/eqld/neural-shell-nlsh-your-ai-powered-command-line-assistant-4kbh</link>
      <guid>https://dev.to/eqld/neural-shell-nlsh-your-ai-powered-command-line-assistant-4kbh</guid>
      <description>&lt;h2&gt;
  
  
  Neural Shell (nlsh): Your AI-Powered Command Line Assistant
&lt;/h2&gt;

&lt;p&gt;Have you ever found yourself spending precious minutes Googling the right shell commands or asking ChatGPT for help? The command line is powerful, but its cryptic syntax can be a significant barrier to productivity.&lt;/p&gt;

&lt;p&gt;Enter &lt;strong&gt;Neural Shell (nlsh)&lt;/strong&gt; – an AI-driven command-line assistant that transforms natural language into shell commands tailored to your system context. It bridges the gap between what you want to do and the exact command syntax needed to do it.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem: Command Line Friction
&lt;/h3&gt;

&lt;p&gt;The command line interface (CLI) offers unparalleled power and flexibility for developers and system administrators. However, this power comes with a steep learning curve and cognitive overhead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Syntax Complexity&lt;/strong&gt;: Each shell has its own syntax quirks and command variations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parameter Overload&lt;/strong&gt;: Commands like &lt;code&gt;find&lt;/code&gt;, &lt;code&gt;awk&lt;/code&gt;, or &lt;code&gt;sed&lt;/code&gt; have dozens of options and flags&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Switching&lt;/strong&gt;: Looking up commands interrupts your workflow and breaks concentration&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;System Differences&lt;/strong&gt;: Commands that work on one OS or shell might fail on another (e.g., macOS vs. Linux)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These friction points slow us down and introduce opportunities for errors – some of which could be costly or dangerous when working with system commands.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Neural Shell Solves These Problems
&lt;/h3&gt;

&lt;p&gt;Neural Shell acts as a bridge between natural language and shell commands. Instead of remembering exact syntax, you describe what you want to accomplish &lt;strong&gt;right in your terminal&lt;/strong&gt;, and nlsh generates the appropriate command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Instead of trying to remember the exact find syntax&lt;/span&gt;
nlsh find all log files larger than 10MB modified &lt;span class="k"&gt;in &lt;/span&gt;the last week
&lt;span class="c"&gt;# Suggested: find . -name "*.log" -size +10M -mtime -7&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) y&lt;/span&gt;
&lt;span class="c"&gt;# Executing:&lt;/span&gt;
&lt;span class="c"&gt;# (command output appears here)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The tool never executes commands automatically – it always shows you the suggested command and waits for your confirmation, allowing you to learn while using it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features That Make nlsh Special
&lt;/h3&gt;

&lt;h4&gt;
  
  
  🔄 Multi-Backend LLM Support
&lt;/h4&gt;

&lt;p&gt;Neural Shell isn't tied to a single AI provider. It supports multiple OpenAI-compatible endpoints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Local models via Ollama, LM Studio, etc., for privacy and offline use&lt;/li&gt;
&lt;li&gt;Cloud providers like Groq, DeepSeek, and others&lt;/li&gt;
&lt;li&gt;Easy switching between backends with simple flags (-0, -1, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This flexibility means you can use the model that best fits your needs, budget, and privacy requirements.&lt;/p&gt;

&lt;h4&gt;
  
  
  🧠 System-Aware Context
&lt;/h4&gt;

&lt;p&gt;What sets &lt;code&gt;nlsh&lt;/code&gt; apart from simply asking a general-purpose LLM (like ChatGPT) for shell commands is its system awareness. It automatically gathers information about your environment to generate more relevant commands.&lt;/p&gt;

&lt;p&gt;Neural Shell uses a set of specialized system context tools to gather detailed information about your environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DirLister&lt;/strong&gt;: Lists non-hidden files in the current directory with detailed metadata (file type, size, modification time). This helps the LLM understand what files are available in your working directory and their characteristics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;EnvInspector&lt;/strong&gt;: Reports environment variables (with sensitive information automatically redacted) to ensure compatibility with your system. This includes shell information, PATH entries, and other important environment variables that might affect command execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SystemInfo&lt;/strong&gt;: Provides comprehensive OS, kernel, and architecture context. This includes information about your operating system, version, distribution (for Linux), architecture, and Python environment, helping the LLM generate commands that are compatible with your specific system.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This context enables it to generate commands that are tailored to your specific environment without you having to manually provide this information.&lt;/p&gt;

&lt;h4&gt;
  
  
  🐚 Shell-Aware Generation
&lt;/h4&gt;

&lt;p&gt;Different shells have different syntax requirements. Neural Shell respects this. If &lt;code&gt;nlsh&lt;/code&gt; is configured for the &lt;code&gt;fish&lt;/code&gt; shell (using the &lt;code&gt;NLSH_SHELL&lt;/code&gt; environment variable or the &lt;code&gt;shell&lt;/code&gt; setting in &lt;code&gt;config.yml&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh create a &lt;span class="k"&gt;function &lt;/span&gt;that converts markdown to pdf
&lt;span class="c"&gt;# Suggested: function md2pdf&lt;/span&gt;
&lt;span class="c"&gt;#     pandoc $argv -o (basename $argv .md).pdf&lt;/span&gt;
&lt;span class="c"&gt;# end&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) y&lt;/span&gt;
&lt;span class="c"&gt;# Executing:&lt;/span&gt;
&lt;span class="c"&gt;# Function 'md2pdf' defined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By configuring your preferred shell (bash/zsh/fish/powershell), nlsh ensures the commands it generates will work in your environment.&lt;/p&gt;

&lt;h4&gt;
  
  
  🛡️ Safety First Approach
&lt;/h4&gt;

&lt;p&gt;Neural Shell prioritizes safety:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh find all temporary files
&lt;span class="c"&gt;# Suggested: find . -name "*.tmp" -type f&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) x&lt;/span&gt;

&lt;span class="c"&gt;# Explanation:&lt;/span&gt;
&lt;span class="c"&gt;# ----------------------------------------&lt;/span&gt;
&lt;span class="c"&gt;# This command finds all files with the .tmp extension in the current directory and subdirectories.&lt;/span&gt;
&lt;span class="c"&gt;# - `find .` searches from the current directory&lt;/span&gt;
&lt;span class="c"&gt;# - `-name "*.tmp"` matches files ending with .tmp&lt;/span&gt;
&lt;span class="c"&gt;# - `-type f` ensures we only find regular files, not directories&lt;/span&gt;
&lt;span class="c"&gt;# ----------------------------------------&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The tool:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never executes commands automatically.&lt;/li&gt;
&lt;li&gt;Provides an explanation option ('x') to understand what a command does.&lt;/li&gt;
&lt;li&gt;Allows editing commands before execution ('e').&lt;/li&gt;
&lt;li&gt;Lets you regenerate suggestions if they don't match your intent ('r'). Each regeneration attempt also slightly increases the model's creativity (temperature) to encourage different suggestions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's worth noting that under the hood, &lt;code&gt;nlsh&lt;/code&gt; uses &lt;code&gt;subprocess.Popen&lt;/code&gt; with &lt;code&gt;shell=True&lt;/code&gt; to execute commands, which is necessary for interpreting complex shell syntax. While this carries inherent risks if a malicious command were to be executed, the mandatory confirmation step serves as the primary safeguard. Always review suggested commands carefully before confirming execution.&lt;/p&gt;

&lt;h3&gt;
  
  
  Practical Use Cases
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Daily File Management
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh find duplicate files &lt;span class="k"&gt;in &lt;/span&gt;my downloads folder and show their sizes
&lt;span class="c"&gt;# Suggested: find ~/Downloads -type f -exec md5sum {} \; | sort | uniq -w32 -d --all-repeated=separate | awk '{print $2}' | xargs du -sh&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) y&lt;/span&gt;
&lt;span class="c"&gt;# Executing:&lt;/span&gt;
&lt;span class="c"&gt;# 4.2M  ~/Downloads/report-v2.pdf&lt;/span&gt;
&lt;span class="c"&gt;# 1.8M  ~/Downloads/presentation-draft.pptx&lt;/span&gt;
&lt;span class="c"&gt;# (output truncated for brevity)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Complex Data Processing
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh extract all email addresses from log files and count unique domains
&lt;span class="c"&gt;# Suggested: grep -Eo '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}' *.log | awk -F@ '{print $2}' | sort | uniq -c | sort -nr&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) y&lt;/span&gt;
&lt;span class="c"&gt;# Executing:&lt;/span&gt;
&lt;span class="c"&gt;#      42 gmail.com&lt;/span&gt;
&lt;span class="c"&gt;#      27 company.com&lt;/span&gt;
&lt;span class="c"&gt;#      15 outlook.com&lt;/span&gt;
&lt;span class="c"&gt;#       8 protonmail.com&lt;/span&gt;
&lt;span class="c"&gt;# (output truncated for brevity)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  System Administration
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh find processes using more than 1GB of memory
&lt;span class="c"&gt;# Suggested: ps aux | awk '$6 &amp;gt; 1000000 {print $0}'&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) y&lt;/span&gt;
&lt;span class="c"&gt;# Executing:&lt;/span&gt;
&lt;span class="c"&gt;# user     12345 15.0  8.2 2145328 1345796 ?     Sl   10:23   2:14 /usr/lib/firefox/firefox&lt;/span&gt;
&lt;span class="c"&gt;# user      9876  4.2  6.7 1782540 1098432 ?     Sl   09:45   1:32 /usr/bin/chromium-browser&lt;/span&gt;
&lt;span class="c"&gt;# (output truncated for brevity)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Git Operations with nlgc
&lt;/h4&gt;

&lt;p&gt;Neural Shell also includes a companion tool called &lt;code&gt;nlgc&lt;/code&gt; (Neural Git Commit) that generates meaningful commit messages based on your staged changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# After staging changes&lt;/span&gt;
git add &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# Generate a commit message&lt;/span&gt;
nlgc
&lt;span class="c"&gt;# Suggested commit message:&lt;/span&gt;
&lt;span class="c"&gt;# --------------------&lt;/span&gt;
&lt;span class="c"&gt;# feat: Add nlgc command for AI-generated commit messages&lt;/span&gt;
&lt;span class="c"&gt;# &lt;/span&gt;
&lt;span class="c"&gt;# Implements the nlgc command which analyzes staged git diffs&lt;/span&gt;
&lt;span class="c"&gt;# and uses an LLM to generate conventional commit messages.&lt;/span&gt;
&lt;span class="c"&gt;# Includes configuration options and CLI flags to control&lt;/span&gt;
&lt;span class="c"&gt;# whether full file content is included in the prompt.&lt;/span&gt;
&lt;span class="c"&gt;# --------------------&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Use this message? (y/N/e/r) y&lt;/span&gt;
&lt;span class="c"&gt;# Executing: git commit -m "feat: Add nlgc command..."&lt;/span&gt;
&lt;span class="c"&gt;# Commit successful.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps maintain a clean, informative git history without the mental overhead of manually crafting the perfect commit message. &lt;code&gt;nlgc&lt;/code&gt; also supports flags like &lt;code&gt;--full-files&lt;/code&gt; / &lt;code&gt;--no-full-files&lt;/code&gt; to control context size and &lt;code&gt;-a&lt;/code&gt; / &lt;code&gt;--all&lt;/code&gt; to consider all modified files, not just staged ones. Note that &lt;code&gt;nlgc&lt;/code&gt; currently truncates individual files larger than ~100KB before adding them to the prompt to help prevent context overflows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started
&lt;/h3&gt;

&lt;p&gt;Installation is straightforward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Via pip&lt;/span&gt;
pip &lt;span class="nb"&gt;install &lt;/span&gt;neural-shell

&lt;span class="c"&gt;# Or from source&lt;/span&gt;
git clone https://github.com/eqld/nlsh.git
&lt;span class="nb"&gt;cd &lt;/span&gt;nlsh
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a configuration file by copying the example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ~/.nlsh
&lt;span class="nb"&gt;cp &lt;/span&gt;examples/config.yml ~/.nlsh/config.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, edit &lt;code&gt;~/.nlsh/config.yml&lt;/code&gt; to add your configuration. The config file has a simple structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;zsh"&lt;/span&gt;  &lt;span class="c1"&gt;# Your preferred shell (bash/zsh/fish/powershell)&lt;/span&gt;
&lt;span class="na"&gt;backends&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;local-ollama"&lt;/span&gt;
    &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://localhost:11434/v1"&lt;/span&gt;
    &lt;span class="na"&gt;api_key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ollama"&lt;/span&gt;
    &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;llama3"&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;groq-cloud"&lt;/span&gt;
    &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://api.groq.com/v1"&lt;/span&gt;
    &lt;span class="na"&gt;api_key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;$GROQ_KEY&lt;/span&gt;
    &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;llama3-70b-8192"&lt;/span&gt;
&lt;span class="na"&gt;default_backend&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;  &lt;span class="c1"&gt;# Index of the default backend to use&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll need to add your API keys to the configuration. There are a few main ways to provide them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;In the config file:&lt;/strong&gt; Paste the key directly or reference an environment variable using &lt;code&gt;$VAR&lt;/code&gt; syntax (e.g., &lt;code&gt;api_key: $MY_SECRET_KEY&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;As environment variables:&lt;/strong&gt; Set specific variables like &lt;code&gt;OPENAI_API_KEY&lt;/code&gt; or &lt;code&gt;NLSH_BACKEND_0_API_KEY&lt;/code&gt;. These override any keys specified in the config file.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example, using the second method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;sk-...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you're ready to go!&lt;/p&gt;

&lt;h3&gt;
  
  
  Advanced Features
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Command Interaction Features
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Command Explanation
&lt;/h5&gt;

&lt;p&gt;The 'x' option provides detailed explanations of suggested commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh find all python files with TODO comments
&lt;span class="c"&gt;# Suggested: grep -r "TODO" --include="*.py" .&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) x&lt;/span&gt;

&lt;span class="c"&gt;# Explanation:&lt;/span&gt;
&lt;span class="c"&gt;# ----------------------------------------&lt;/span&gt;
&lt;span class="c"&gt;# This command searches recursively for "TODO" in all Python files:&lt;/span&gt;
&lt;span class="c"&gt;# - `grep -r` performs recursive searching&lt;/span&gt;
&lt;span class="c"&gt;# - `"TODO"` is the text pattern to search for&lt;/span&gt;
&lt;span class="c"&gt;# - `--include="*.py"` limits the search to Python files&lt;/span&gt;
&lt;span class="c"&gt;# - `.` specifies to start the search from the current directory (`.` refers to the current directory)&lt;/span&gt;
&lt;span class="c"&gt;# ----------------------------------------&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This feature is invaluable for learning new commands and understanding complex one-liners.&lt;/p&gt;

&lt;h5&gt;
  
  
  Command Editing
&lt;/h5&gt;

&lt;p&gt;The 'e' option allows you to edit a suggested command before execution, which is useful when you need to make small adjustments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh list files sorted by size
&lt;span class="c"&gt;# Suggested: ls -lS&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) e&lt;/span&gt;
&lt;span class="c"&gt;# (Opens your $EDITOR with 'ls -lS')&lt;/span&gt;
&lt;span class="c"&gt;# (Edit the command, e.g., to 'ls -lSh')&lt;/span&gt;
&lt;span class="c"&gt;# Edited command: ls -lSh&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Command Regeneration
&lt;/h5&gt;

&lt;p&gt;If you're not satisfied with a suggested command, you can ask for a different approach by responding with 'r':&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh find large files
&lt;span class="c"&gt;# Suggested: find . -type f -size +100M&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) r&lt;/span&gt;
&lt;span class="c"&gt;# Regenerating command...&lt;/span&gt;
&lt;span class="c"&gt;# Suggested: du -h -d 1 | sort -hr&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells the model to try a different approach. To encourage more diverse suggestions with each regeneration attempt, the temperature parameter (which controls randomness) is automatically increased by 0.1 for each regeneration, starting from 0.2 and capping at 1.0.&lt;/p&gt;

&lt;h5&gt;
  
  
  Command Fixing
&lt;/h5&gt;

&lt;p&gt;Neural Shell can automatically fix failed commands by analyzing error output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh find files modified today
&lt;span class="c"&gt;# Suggested: find . -mtime 0&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) y&lt;/span&gt;
&lt;span class="c"&gt;# Executing:&lt;/span&gt;
&lt;span class="c"&gt;# find: unknown option -- m&lt;/span&gt;
&lt;span class="c"&gt;# find: `find .mtime' is not a valid expression&lt;/span&gt;
&lt;span class="c"&gt;# &lt;/span&gt;
&lt;span class="c"&gt;# ----------------&lt;/span&gt;
&lt;span class="c"&gt;# Command execution failed with code 1&lt;/span&gt;
&lt;span class="c"&gt;# Failed command: find . -mtime 0&lt;/span&gt;
&lt;span class="c"&gt;# Try to fix? If you confirm, the command output and exit code will be sent to LLM.&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Try to fix this command? (y/N) y&lt;/span&gt;
&lt;span class="c"&gt;# Fixing...&lt;/span&gt;
&lt;span class="c"&gt;# Suggested: find . -type f -mtime 0&lt;/span&gt;
&lt;span class="c"&gt;# [Confirm] Run this command? (y/N/e/r/x) y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This feature helps you quickly recover from command errors by analyzing the error output and exit code, considering your original intent, and generating a corrected version of the command.&lt;/p&gt;

&lt;h4&gt;
  
  
  Model and Prompt Features
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Verbose Mode
&lt;/h5&gt;

&lt;p&gt;For reasoning models, such as &lt;code&gt;deepseek-reasoner&lt;/code&gt;, use the &lt;code&gt;-v&lt;/code&gt; flag to see the AI's reasoning:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh &lt;span class="nt"&gt;-v&lt;/span&gt; find large files consuming disk space
&lt;span class="c"&gt;# Reasoning: To find large files consuming disk space, I'll use the 'find' command&lt;/span&gt;
&lt;span class="c"&gt;# with size filtering, then sort the results by size using 'du'.&lt;/span&gt;
&lt;span class="c"&gt;# Suggested: find . -type f -size +100M -exec du -h {} \; | sort -hr&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This provides insight into how the AI approaches the problem. You can enable this feature by using models marked with &lt;code&gt;is_reasoning_model: true&lt;/code&gt; in your config file and using the &lt;code&gt;-v&lt;/code&gt; flag. For even more detail, use &lt;code&gt;-vv&lt;/code&gt; to include debug information and stack traces if errors occur.&lt;/p&gt;

&lt;h5&gt;
  
  
  Custom Prompts
&lt;/h5&gt;

&lt;p&gt;For more complex or repetitive tasks, you can provide a detailed prompt in a file using &lt;code&gt;nlsh --prompt-file your_prompt.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  System and Logging Features
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Improved Command Execution
&lt;/h5&gt;

&lt;p&gt;Neural Shell executes commands using non-blocking I/O with the &lt;code&gt;select&lt;/code&gt; module to read from stdout/stderr. This approach ensures compatibility with a wide range of commands, including those with pipes (&lt;code&gt;|&lt;/code&gt;) and redirections. The non-blocking implementation prevents deadlocks that can occur with piped commands where one process might be waiting for input before producing output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Use select for non-blocking I/O
&lt;/span&gt;&lt;span class="n"&gt;stdout_fd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fileno&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;stderr_fd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fileno&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;readable_fds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;stdout_fd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stderr_fd&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;readable_fds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Use select to wait for data to be available
&lt;/span&gt;    &lt;span class="n"&gt;ready_to_read&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;readable_fds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Process has exited and no more data to read
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;ready_to_read&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;poll&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;fd&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ready_to_read&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;stdout_fd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# EOF
&lt;/span&gt;                &lt;span class="n"&gt;readable_fds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stdout_fd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;safe_write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;stdout_data&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This implementation ensures that output is displayed in real-time and prevents the command from hanging when dealing with complex pipelines.&lt;/p&gt;

&lt;h5&gt;
  
  
  Request Logging
&lt;/h5&gt;

&lt;p&gt;For teams or audit purposes, you can log all requests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nlsh &lt;span class="nt"&gt;--log-file&lt;/span&gt; ~/.nlsh/logs/requests.log find security vulnerabilities
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The log file will contain JSON entries with timestamps, backend information, prompts, system context, and responses, which can be useful for debugging, auditing, or improving the tool's performance.&lt;/p&gt;

&lt;h5&gt;
  
  
  Note on Interactive Commands
&lt;/h5&gt;

&lt;p&gt;While the &lt;code&gt;select&lt;/code&gt; module implementation works well for most commands, highly interactive commands (like those with progress bars or TUI applications) might not render perfectly during execution via &lt;code&gt;nlsh&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Neural Shell Matters
&lt;/h3&gt;

&lt;p&gt;Neural Shell represents a shift in how we interact with command-line interfaces. Rather than forcing humans to think like computers, it allows computers to understand human intent.&lt;/p&gt;

&lt;p&gt;The benefits include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Reduced Context Switching&lt;/strong&gt;: Stay in the flow without Googling commands&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Faster Problem Solving&lt;/strong&gt;: Convert intentions to actions immediately&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learning Opportunity&lt;/strong&gt;: See, edit, explain, and understand the right commands for each task&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency&lt;/strong&gt;: Generate commands that follow best practices&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safety&lt;/strong&gt;: Review commands before execution to prevent mistakes&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Neural Shell (nlsh) transforms the command-line experience from memorization to conversation. It maintains all the power and flexibility of the CLI while removing much of the friction.&lt;/p&gt;

&lt;p&gt;Whether you're a seasoned sysadmin looking to save time, a developer wanting to stay in flow, or someone learning the command line, nlsh offers a more natural way to interact with your computer.&lt;/p&gt;

&lt;p&gt;Give it a try and experience the future of command-line interfaces today!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Neural Shell is open source under the MIT license. Contributions are welcome at &lt;a href="https://github.com/eqld/nlsh" rel="noopener noreferrer"&gt;github.com/eqld/nlsh&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cli</category>
      <category>productivity</category>
      <category>ai</category>
      <category>python</category>
    </item>
  </channel>
</rss>
