Package org.jline.shell
Interface AliasManager
- All Known Implementing Classes:
DefaultAliasManager
public interface AliasManager
Manages command aliases for the shell.
An alias maps a short name to a longer command expansion. When the shell encounters an alias name as the first word of a command line, it substitutes the alias expansion before executing.
Implementations may optionally support persistence via load() and
save().
- Since:
- 4.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaliases()Returns all defined aliases.Expands aliases in a command line string.Returns the expansion for an alias.default voidload()Loads aliases from persistent storage.booleanremoveAlias(String name) Removes an alias.default voidsave()Saves aliases to persistent storage.voidDefines or redefines an alias.
-
Method Details
-
setAlias
-
removeAlias
Removes an alias.- Parameters:
name- the alias name- Returns:
- true if the alias existed and was removed
-
getAlias
-
aliases
-
expand
Expands aliases in a command line string.The first word of the line is checked against defined aliases. If it matches, the alias expansion is substituted. Supports parameter markers (
$1,$2,$@) in expansions. Includes a recursion guard to prevent infinite expansion.- Parameters:
line- the command line to expand- Returns:
- the expanded command line
-
load
Loads aliases from persistent storage.The default implementation does nothing.
- Throws:
IOException- if loading fails
-
save
Saves aliases to persistent storage.The default implementation does nothing.
- Throws:
IOException- if saving fails
-