Adds a part to the current prompt parts
- ( void )addPromptPart:( NSString * )part;
Only applicable if the prompt hierarchy is enabled.
Checks if a shell command is available
- ( BOOL )commandIsAvailable: ( NSString * )command;
Commands are found using `which`, invoked through the logn shell.
YES is the command is available, otherwise NO
Gets the instance representing the current shell
+ ( instancetype )currentShell;
Although a `SKShell` can be instanciated, it is advised to alyways use this shared instance.
Gets the paths of a shell command
- ( nullable NSString * )pathForCommand: ( NSString * )command;
Commands are found using `which`, invoked through the logn shell.
The full path to the command, or nil
Prints an error
- ( void )printError: ( nullable NSError * )error;
If the `error` param is nil, this method will print a generic error message. Errors are printed in red if colors are available/enabled and with an error sign if status icons are enabled.
Prints an error message
- ( void )printErrorMessage: ( NSString * )format, ... NS_FORMAT_FUNCTION( 1, 2 );
Prints an info message
- ( void )printInfoMessage: ( NSString * )format, ... NS_FORMAT_FUNCTION( 1, 2 );
Info messages are printed in blue if colors are available/enabled and with an info sign if status icons are enabled.
Prints a message
- ( void )printMessage: ( NSString * )format, ... NS_FORMAT_FUNCTION( 1, 2 );
Prints a message with a color
- ( void )printMessage: ( NSString * )format color: ( SKColor )color, ... NS_FORMAT_FUNCTION( 1, 3 );
Colors will only be printed if the terminal supports them and if they are enabled.
Prints a message with a color
- ( void )printMessage: ( NSString * )format status: ( SKStatus )status
color: ( SKColor )color, ... NS_FORMAT_FUNCTION( 1, 4 );
Statuses will be printed as an emoji, if status icons are enabled. Colors will only be printed if the terminal supports them and if they are enabled.
Prints a message with a status
- ( void )printMessage: ( NSString * )format status: ( SKStatus )status, ... NS_FORMAT_FUNCTION( 1, 3 );
Statuses will be printed as an emoji, if status icons are enabled.
Prints a message with a color
- ( void )printMessage: ( NSString * )format status: ( SKStatus )status
color: ( SKColor )color, ... NS_FORMAT_FUNCTION( 1, 4 );
Statuses will be printed as an emoji, if status icons are enabled. Colors will only be printed if the terminal supports them and if they are enabled.
Prints a success message
- ( void )printSuccessMessage: ( NSString * )format, ... NS_FORMAT_FUNCTION( 1, 2 );
Success messages are printed in green if colors are available/enabled and with a checkmark sign if status icons are enabled.
Prints an warning message
- ( void )printWarningMessage: ( NSString * )format, ... NS_FORMAT_FUNCTION( 1, 2 );
Warnings are printed in yellow if colors are available/enabled and with an warning sign if status icons are enabled.
Removes the last part of the current prompt parts
- ( void )removeLastPromptPart;
Only applicable if the prompt hierarchy is enabled.
Executes a shell command synchronously
- ( BOOL )runCommand: ( NSString * )command;
Command can be a complex shell commands.
YES if the command executed successfully, otherwise NO
Executes a shell command synchronously
- ( BOOL )runCommand: ( NSString * )command stdandardInput: ( nullable NSString * )input;
Command can be a complex shell commands.
YES if the command executed successfully, otherwise NO
Executes a shell command synchronously
- ( BOOL )runCommand: ( NSString * )command completion: ( nullable SKShellCommandCompletion )completion;
Command can be a complex shell commands.
YES if the command executed successfully, otherwise NO
Executes a shell command synchronously
- ( BOOL )runCommand: ( NSString * )command stdandardInput: ( nullable NSString * )input
completion: ( nullable SKShellCommandCompletion )completion;
Command can be a complex shell commands.
YES if the command executed successfully, otherwise NO
Executes a shell command asynchronously
- ( void )runCommandAsynchronously: ( NSString * )command;
Command can be a complex shell commands.
Executes a shell command asynchronously
- ( void )runCommandAsynchronously: ( NSString * )command
stdandardInput: ( nullable NSString * )input;
Command can be a complex shell commands.
Executes a shell command asynchronously
- ( void )runCommandAsynchronously: ( NSString * )command
completion: ( nullable SKShellCommandCompletion )completion;
Command can be a complex shell commands.
Executes a shell command asynchronously
- ( void )runCommandAsynchronously: ( NSString * )command
stdandardInput: ( nullable NSString * )input completion: ( nullable SKShellCommandCompletion )completion;
Command can be a complex shell commands.
Executes a shell command synchronously
- ( BOOL )runCommand: ( NSString * )command completion: ( nullable SKShellCommandCompletion )completion;
Command can be a complex shell commands.
Executes a shell command synchronously
- ( BOOL )runCommand: ( NSString * )command stdandardInput: ( nullable NSString * )input;
Command can be a complex shell commands.
Executes a shell command synchronously
- ( BOOL )runCommand: ( NSString * )command stdandardInput: ( nullable NSString * )input
completion: ( nullable SKShellCommandCompletion )completion;
Command can be a complex shell commands.
Executes a shell command asynchronously
- ( void )runCommandAsynchronously: ( NSString * )command;
Command can be a complex shell commands.
Executes a shell command asynchronously
- ( void )runCommandAsynchronously: ( NSString * )command
completion: ( nullable SKShellCommandCompletion )completion;
Command can be a complex shell commands.
Executes a shell command asynchronously
- ( void )runCommandAsynchronously: ( NSString * )command
stdandardInput: ( nullable NSString * )input;
Command can be a complex shell commands.
Executes a shell command asynchronously
- ( void )runCommandAsynchronously: ( NSString * )command
stdandardInput: ( nullable NSString * )input completion: ( nullable SKShellCommandCompletion )completion;
Command can be a complex shell commands.
Enables/Disables prompt hierarchy
@property( atomic,
readwrite,
assign ) BOOL allowPromptHierarchy;
Enabled by default. If disabled, setting prompt parts will have no effect.
@property( atomic,
readwrite,
assign ) BOOL colorsEnabled;
Enabled by default. Only applicable if the current terminal supports colors.
Used to get/set the current prompt
@property( atomic,
readwrite,
strong,
nullable ) NSString * prompt;
If a prompt is set, all messages printed with `SKShell` will be prefixed by the prompt.
Used to get/set the promt parts
@property( atomic,
readwrite,
strong,
nullable ) NSArray< NSString * > * promptParts;
Prompt parts may be set to reflect a hierarchy in the prompt. For instance, setting `@[ @"foo", @"bar" ]` as prompt parts will result in a `[ foo ]> [ bar ]>` prompt.
@property( atomic,
readonly,
nullable ) NSString * shell;
Retrieved using the `SHELL` environment variable.
@property( atomic,
readwrite,
assign ) BOOL statusIconsEnabled;
Enabled by default. Status icons are reprensented by unicode emojis.
Set if the current erminal supports color
@property( atomic,
readonly ) BOOL supportsColors;
Completion block for a shell command
typedef void ( ^ SKShellCommandCompletion )(
int status,
NSString *stdandardOutput,
NSString *standardError );