← Back to Home

Table of Contents

This guide demonstrates the tab completion and platform-aware execution functionality in gosh. Tab completion helps you work more efficiently by automatically completing commands, file names, and paths. Gosh adapts its tab completion behavior to match your operating system's conventions - by gosh, it's smart!

Testing Command Completion

Test built-in command completion by following these steps:

  1. Start the shell: ./gosh
  2. Type ec and press TAB - should complete to echo
  3. Type ex and press TAB - should complete to exit and export
  4. Type h and press TAB - should show help and history
  5. Type qu and press TAB - should complete to quota (not ququota)
gosh - Command Completion
gosh> ec[TAB]
gosh> echo
gosh> ex[TAB]
exit export

Platform-Specific Tab Completion Behavior

Gosh adapts its tab completion behavior to match your operating system's conventions - gosh, it's like having a native shell on every platform!

🖥️ Platform-Aware Tab Completion

  • Windows: Case-insensitive tab completion (EC[TAB] → echo)
  • Linux/Unix/macOS: Case-sensitive tab completion (EC[TAB] → no match, ec[TAB] → echo)
  • Command Execution: Case-insensitive on ALL platforms (ECho works everywhere!)

Testing on Windows

On Windows, tab completion is case-insensitive to match Windows conventions:

  1. Type EC and press TAB - should complete to echo
  2. Type EX and press TAB - should show exit and export
  3. Type PW and press TAB - should complete to pwd
  4. Type HEL and press TAB - should complete to help

Testing on Linux/Unix/macOS

On Unix-like systems, tab completion is case-sensitive to match Unix conventions:

  1. Type EC and press TAB - should NOT complete (no matches)
  2. Type ec and press TAB - should complete to echo
  3. Type EX and press TAB - should NOT complete (no matches)
  4. Type ex and press TAB - should show exit and export
gosh - Platform-Specific Completion
# On Windows:
gosh> EC[TAB]
gosh> echo
# On Linux/Unix/macOS:
gosh> EC[TAB]
# No completion - case sensitive!
gosh> ec[TAB]
gosh> echo

🎯 Why Platform-Specific?

This behavior matches what users expect on each platform. Windows users are accustomed to case-insensitive file systems and commands, while Unix users expect case-sensitive behavior. Gosh respects these conventions - gosh, it's intuitive!

Case-Insensitive Execution

Gosh provides case-insensitive execution with platform-specific behavior:

This approach respects platform conventions while providing convenience for gosh's built-in functionality. Gosh, that's the best of both worlds!

Testing Case-Insensitive Execution

Built-in commands work case-insensitively on ALL platforms:

  1. Type EXit and press ENTER - should exit the shell
  2. Type ECho "Hello World" and press ENTER - should print "Hello World"
  3. Type PWd and press ENTER - should print current directory
  4. Type HeLp and press ENTER - should show help information
  5. Type CLEAR and press ENTER - should clear the screen

External commands on Unix/Linux/macOS:

gosh - Case-Insensitive Built-ins (All Platforms)
gosh> ECho "Hello World"
Hello World
gosh> PWd
/Users/user/Projects/go/gosh
gosh> HeLp
Available commands: cd, echo, exit, help, pwd...

💡 Case-Insensitive Execution Benefits

  • User-Friendly: No need to remember exact capitalization for built-ins - gosh, that's forgiving!
  • Platform-Aware: Respects OS conventions for external commands
  • Flexible: Type built-in commands however feels natural
  • Error Prevention: Reduces "command not found" errors for gosh built-ins - gosh darn it, that's helpful!

Testing File/Directory Completion

Test file and directory completion:

  1. Type cd (with space) and press TAB - should show directories in current folder
  2. Type ls *. and press TAB - should show files starting with dot
  3. Type cat README and press TAB - should complete to README.md
  4. Navigate to examples/ directory and type ./case then press TAB - should complete to ./case_statement_demo.sh
gosh - File Completion
gosh> cd [TAB]
doc/ examples/
gosh> cat README[TAB]
gosh> cat README.md

Testing Tilde Expansion Completion

Test tilde expansion and home directory completion with cross-platform path separator support:

  1. Type ls ~/ and press TAB - should show files and directories in your home directory
  2. Type cd ~/D and press TAB - should complete to directories starting with 'D' in your home
  3. Type ls ~/Documents/ and press TAB - should show contents of ~/Documents/ directory
  4. Type echo ~ and press TAB - should complete to echo ~/
  5. Type cd ~/ and press TAB - should not expand further (no completions shown)
  6. Type cat ~/.* and press TAB - should show hidden files in home directory

Windows Backslash Support

On Windows, gosh also supports backslash path separators for tilde expansion:

  1. Type cd ~\ and press TAB - should show directories in your home directory
  2. Type ls ~\Documents\ and press TAB - should show contents of ~\Documents\ directory
  3. Type cd ~\D and press TAB - should complete to directories starting with 'D' in your home
gosh - Tilde Expansion
gosh> ls ~/[TAB]
Desktop/ Documents/ Downloads/ Pictures/
gosh> cd ~/D[TAB]
Desktop/ Documents/ Downloads/

Testing Glob Pattern Completion

Test glob pattern matching and completion:

  1. Create test files: touch file1. file2. test.
  2. Type ls . and press TAB - should show files ending with dots
  3. Create test files: touch test.txt example.txt sample.go
  4. Type ls *.txt and press TAB - should show .txt files
  5. Type ls test.* and press TAB - should show files starting with "test"
  6. Test with directories: mkdir dir1 dir2 then ls dir* + TAB
gosh - Glob Patterns
gosh> touch test.txt example.txt sample.go
gosh> ls *.txt[TAB]
example.txt test.txt
gosh> ls test.*[TAB]
test.txt

Testing PATH Command Completion

Test completion of external commands from your PATH:

  1. Type l and press TAB - should show commands like ls, ln, etc.
  2. Type g and press TAB - should show commands like git, grep, etc.
gosh - PATH Completion
gosh> l[TAB]
ls ln less locate
gosh> g[TAB]
git grep gunzip gzip

Features Implemented

Gosh includes comprehensive tab completion support - gosh, it's feature-packed!

Built-in Commands

Complete built-in commands like exit, cd, pwd, echo, etc. - gosh, that's handy!

External Commands

Complete external commands from your PATH environment

File & Directory

Complete file and directory names with proper context awareness

Path Completion

Complete file paths including ./ and ../ prefixes

Tilde Expansion

Complete ~ and ~/path with home directory expansion

Alias Completion

Complete user-defined aliases and their expansions

Context Awareness

Smart completion based on command context (commands vs arguments)

Hidden Files

Complete hidden files when prefix starts with dot

Directory Indicators

Automatically add trailing slash for directories

Smart Sorting

Remove duplicates and sort completions alphabetically

🆕

Platform-Aware Completion

Case-insensitive on Windows, case-sensitive on Unix - gosh, it's adaptive!

🆕

Case-Insensitive Execution

Execute commands, aliases, and functions regardless of case on all platforms

Tips for Effective Tab Completion and Execution

Keyboard Shortcuts

TAB - Complete current word (platform-aware case sensitivity) TAB TAB - Show all possible completions Ctrl+C - Cancel current completion Ctrl+L - Clear screen (preserves current line)

🧠 Gosh, That's Smart!

The platform-aware tab completion means you get the behavior you expect on each operating system. Windows users get case-insensitive completion (just like cmd.exe and PowerShell), while Unix users get case-sensitive completion (just like bash and zsh).

For command execution, gosh strikes the perfect balance:

  • Built-in commands are always case-insensitive for convenience
  • External commands respect platform conventions

This gives you the familiarity of your native shell with the convenience of gosh's built-in features!