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:
- Start the shell:
./gosh
- Type
ec
and press TAB - should complete toecho
- Type
ex
and press TAB - should complete toexit
andexport
- Type
h
and press TAB - should showhelp
andhistory
- Type
qu
and press TAB - should complete toquota
(notququota
)
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:
- Type
EC
and press TAB - should complete toecho
- Type
EX
and press TAB - should showexit
andexport
- Type
PW
and press TAB - should complete topwd
- Type
HEL
and press TAB - should complete tohelp
Testing on Linux/Unix/macOS
On Unix-like systems, tab completion is case-sensitive to match Unix conventions:
- Type
EC
and press TAB - should NOT complete (no matches) - Type
ec
and press TAB - should complete toecho
- Type
EX
and press TAB - should NOT complete (no matches) - Type
ex
and press TAB - should showexit
andexport
🎯 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:
- Windows: All commands (built-ins and external) are case-insensitive
- Linux/Unix/macOS: Only built-in commands, aliases, and user-defined functions are case-insensitive. External commands follow the platform's case-sensitive nature
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:
- Type
EXit
and press ENTER - should exit the shell - Type
ECho "Hello World"
and press ENTER - should print "Hello World" - Type
PWd
and press ENTER - should print current directory - Type
HeLp
and press ENTER - should show help information - Type
CLEAR
and press ENTER - should clear the screen
External commands on Unix/Linux/macOS:
LS
- may not work (depends on system PATH)ls
- works correctlyCAT file.txt
- may not workcat file.txt
- works correctly
💡 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:
- Type
cd
(with space) and press TAB - should show directories in current folder - Type
ls *.
and press TAB - should show files starting with dot - Type
cat README
and press TAB - should complete toREADME.md
- Navigate to
examples/
directory and type./case
then press TAB - should complete to./case_statement_demo.sh
Testing Tilde Expansion Completion
Test tilde expansion and home directory completion with cross-platform path separator support:
- Type
ls ~/
and press TAB - should show files and directories in your home directory - Type
cd ~/D
and press TAB - should complete to directories starting with 'D' in your home - Type
ls ~/Documents/
and press TAB - should show contents of ~/Documents/ directory - Type
echo ~
and press TAB - should complete toecho ~/
- Type
cd ~/
and press TAB - should not expand further (no completions shown) - 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:
- Type
cd ~\
and press TAB - should show directories in your home directory - Type
ls ~\Documents\
and press TAB - should show contents of ~\Documents\ directory - Type
cd ~\D
and press TAB - should complete to directories starting with 'D' in your home
Testing Glob Pattern Completion
Test glob pattern matching and completion:
- Create test files:
touch file1. file2. test.
- Type
ls .
and press TAB - should show files ending with dots - Create test files:
touch test.txt example.txt sample.go
- Type
ls *.txt
and press TAB - should show .txt files - Type
ls test.*
and press TAB - should show files starting with "test" - Test with directories:
mkdir dir1 dir2
thenls dir*
+ TAB
Testing PATH Command Completion
Test completion of external commands from your PATH:
- Type
l
and press TAB - should show commands likels
,ln
, etc. - Type
g
and press TAB - should show commands likegit
,grep
, etc.
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
- Double TAB: Press TAB twice to see all available completions when there are multiple matches - gosh, that's thorough!
- Partial Typing: Type a few characters before pressing TAB to narrow down completions
- Context Matters: The shell understands whether you're typing a command or an argument
- Platform-Aware Completion: Tab completion adapts to your OS (case-insensitive on Windows, case-sensitive on Unix)
- Universal Case-Insensitive Execution: Built-in commands, aliases, and functions work regardless of case on ALL platforms (e.g., "EXIT", "exit", "Exit")
- File System Case: File and directory completion respects your platform's case sensitivity conventions
- Hidden Files: Start with a dot (.) to complete hidden files and directories - gosh, even the secrets are accessible!
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!