Repository navigation
feat: implement alias and unalias builtins with tab completion support - #9
Merged
Merged
Conversation
- Add AliasManager with set, get, remove, clear and getAll methods - Implement recursive alias expansion with depth limit of 10 - Prevent infinite recursion for self-referencing aliases (e.g. alias ls='ls --color') - Use LinkedHashMap to preserve insertion order for listing - Add AliasManager to Environment as shared shell state
- Add AliasBuiltin to set aliases via alias name=value - List all aliases with alias output format when no args given - Print specific alias with alias name - Strip surrounding single and double quotes from alias values - Report error for unknown alias names - Register as environment-dependent builtin in BuiltinFactory
- Add UnaliasBuiltin to remove aliases by name - Support -a flag to remove all aliases at once - Report error for unknown alias names - Register as environment-dependent builtin in BuiltinFactory
- Call AliasManager.expand() on input before history expansion - Save original input to history, not the expanded form - Alias expansion happens after VAR=value detection
- Add aliasCompleter as StringsCompleter from AliasManager keys - Complete alias names at word index 0 alongside builtins and binaries - Update CandidateCollector.of() factory to accept and wire alias completer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
aliasandunaliasbuiltins with recursive alias expansion,self-reference protection, and tab completion integration.
Changes
AliasManager
AliasManagerto store aliases in insertion-orderLinkedHashMapalias ls='ls --color'doesn't recurse)AliasManagertoEnvironmentas shared shell statealiasBuiltinalias— list all aliases inalias name='value'formatalias name=value— set a new aliasalias name— print specific aliasunaliasBuiltinunalias name— remove specific aliasunalias -a— remove all aliasesShell Integration
Shell.handleInputbefore tokenizingVAR=valuedetectionTab Completion
Testing
Manually verified:
alias ll='ls'thenlllists directory correctlyalias say='echo'thensay hello worldprintshello worldalias a='echo hello'; alias b='a'; bprintshelloalias ls='ls --color'doesn't cause infinite loopunalias llremoves aliasunalias -aremoves all aliases