How to use the command 'sm' (with examples)
- Linux
- November 5, 2023
The sm
command is a useful tool for displaying short messages in fullscreen. It allows you to customize the message’s appearance by applying inverted colors, custom foreground and background colors, rotating the message, and even using the output from another command as the message.
Use case 1: Display a message in full-screen
Code:
sm "Hello World!"
Motivation: You can use this use case when you want to display a simple message in fullscreen, perhaps as a notification or a reminder to yourself.
Explanation: The sm
command is followed by the desired message, enclosed in quotation marks. In this case, “Hello World!” is displayed in full-screen on the terminal.
Example OUTPUT:
Hello World!
Use case 2: Display a message with inverted colors
Code:
sm -i "Hello World!"
Motivation: Inverting the colors of a message can make it stand out more and grab the attention of the viewer. This is useful when you want to emphasize a particular message or alert.
Explanation: The -i
flag is used to indicate that the message should be displayed with inverted colors. The message “Hello World!” is displayed in full-screen with the colors inverted.
Example OUTPUT:
Hello World!
Use case 3: Display a message with a custom foreground color
Code:
sm -f blue "Hello World!"
Motivation: Customizing the foreground color of a message can help differentiate it from other messages or make it more visually appealing. This is useful when you want to add a personal touch to your messages or make them match a specific theme.
Explanation: The -f
flag is followed by the desired color for the foreground, in this case, “blue”. The message “Hello World!” is displayed in full-screen with the foreground color set to blue.
Example OUTPUT:
Hello World!
Use case 4: Display a message with a custom background color
Code:
sm -b #008888 "Hello World!"
Motivation: Adding a custom background color to a message can make it more prominent and eye-catching. This is useful when you want to make sure the message is easily noticed and read.
Explanation: The -b
flag is followed by the desired color for the background, in this case, “#008888” (a shade of greenish-blue). The message “Hello World!” is displayed in full-screen with the background color set to #008888.
Example OUTPUT:
Hello World!
Use case 5: Display a message rotated 3 times
Code:
sm -r 3 "Hello World!"
Motivation: Rotating a message can add a playful or creative touch to its display. This is useful when you want to grab someone’s attention or present a message in an unconventional way.
Explanation: The -r
flag is followed by the desired rotation count, in this case, “3”. The message “Hello World!” is displayed in full-screen and rotated counterclockwise three times, with each rotation being 90 degrees.
Example OUTPUT:
Hello World!
Use case 6: Display a message using the output from another command
Code:
echo "Hello World!" | sm -
Motivation: Using the output of another command as a message can automate the process of displaying dynamic or real-time information. This is useful when you want to incorporate the result of a command into a notification or status display.
Explanation: In this case, the echo
command is used to generate the message “Hello World!”. The output of this command is then piped (|) to the sm
command using the hyphen (-) as the argument. This informs sm
to read the message from the standard input.
Example OUTPUT:
Hello World!
Conclusion:
The sm
command is a versatile tool for displaying short messages in fullscreen. With its various options, you can customize the appearance of the messages to your liking. Whether you want to highlight important information, add personal touch, or present messages in a creative way, sm
has got you covered. Utilize the examples provided to unleash the full potential of this command in your workflow.