Red Hat


Æsh Utils

Æsh provide several utility methods to make it easier for the developer to create commands, completions and extensions.

Parser

When working with command-based programs there is always a lot of text parsing, sorting, ordering, etc…
Parser provide a method formatDisplayList to format lists in the same way it is sorted in Bash. Æsh use this method internally to sort completions and filenames/directories when redirecting. Several extensions also use it for displaying filenames/directories.

Another useful method is findWordClosestToCursor. This method will return the word closest to the cursor (from the left) and also merge words that are diveded by escaped spaces. Eg: the word foo\ bar and cursor is on the position after ‘r’, the method will return “foo\ bar”. If the word didnt have escaped space, but “normal” space like: “foo bar” the same method would return "bar.

FileLister

FileLister have one very useful method: listMatchingDirectories. Based on a text given as input in addition to the current working directory it will try to find every file/folder that match the given input. If no input is given it will list the current working directory.An example: given the input text: /var/log/s the method will add every file and folder starting with ‘e’ in the /var/log directory to the Completion object given as parameter to the method. Note that this can be used oustide a complete operation too. Just fetch the possible files/directories with: CompletionOperation.getCompletionCandidates().

Colors and Text types

Since Æsh is targeting ANSI terminals it also provide a API to easily generate ANSI codes to help the developer communicate with the terminal.

TerminalCharacter

TerminalCharacter is a value object that describes how a character should be displayed in the terminal. It is possible to specify the background and text color and the character type.

TerminalString

TerminalString is a value object that describes how a String object should be displayed in the terminal. It has the same background and text color and character type attributes as TerminalCharacter.

If these classes do not suit your need Æsh also provide a class ANSI that provides many methods like:

  • changing text color
  • changing background color
  • reseting
  • bold text
  • invert background
  • normal backround
  • switch between main and alternate buffer screen
back to top