Customize silent running processes with frame animations and text in Linux Bash shells.
If you like this project and care to donate to my PayPal:
Or Buy Me A Coffee if your prefer:
- ProcSpin
This Linux Bash command line utility can attach itself to any process by PID and run a custom animation of frames by string or array with the addition of prepended and appended text with the animation and the ability to change the speed of the animations by spreading the frames over seconds with the '-s' switch (e.g. -s 3, spreads over 3 seconds). This is great for silent processes, especially in sub shells or scripts. This tool works with any color and otherformatting that can be used with printf
.
I work in many shells for many reasons and not everything I do has verbose output (of course) and sometimes it's nice to have something visual to represent what's going on in the background. If for anything else, but to know if it's still runing or not without having to type a command.
'ProcSpin' is a utility written specifially for the Bash
environment in GNU
/Linux
and is dependant only on the utilities and libraries that are already provided in said environment.
This is a command line/shell/terminal/console utility written specifically for the Linux Bash environment and as such can be used in any method that you can use any other executable bin or script in said environment.
This program comes in 3 forms:
- A sourceable and executable script.
- A function that can be pull from the script.
- An executable AppImage.
The script can be sourced and used as a function (or the function can be stripped and used wherever you like) or it can be used by normal script execution. Sourcing the script provides Bash Completion.
You can, of course, name the script to anything you like.
To source the files and use the function with Bash Completion:
$ . /path/to/procspin.bash
or
$ source /path/to/procspin.bash
Then use the function with Bash Completion in your terminal:
# Run silent sub-shell command with the default spiner, but added text.
(silent_command_script_or_executable) & procspin -i $! -p " prepended text [" -a "] "
No Bash Completion unless you copy the completion code into your own configs from my provided 'complete' code in the script.
# Run silent sub-shell command with the default spiner, but added text.
(silent_command_script_or_executable) & ./procspin.bash $! -p " prepended text [" -a "] "
The AppImage
is only executable and used exactly like the executable script above. All AppImages can be renamed to something easier and especially removing the .AppImage extension. This is just another delivery method in which some people prefer.
# Run silent sub-shell command with the default spiner, but added text.
(silent_command_script_or_executable) & ./procspin-x86_64.AppImage $! -p " prepended text [" -a "] "
Switch | Switch - Alt | Description |
---|---|---|
-h | --help | This help message. |
-i | --pid | Integer ID of process. |
-f | --frames | STRING or ARRAY of animation frames. |
-p | --prepend | STRING to prepend to spinner. |
-a | --append | STRING to append to spinner. |
-s | --spread | Time in INTEGER seconds to spread frames over. |
Example | Description |
---|---|
2345 (any integer) | Direct PID |
$$ | PID of current shell. |
$! | PID of last ran process/sub-shell. |
Example |
---|
array=('> ',' > ',' > ',' >') |
A comma delimited array of animation frames where you can create positional animations by creating each frame the same character length and, of course, filling empty spaces with spaces. |
As stated above Bash Completion is provided when sourcing the script, but it can also be added to any of your 'profile' or 'dot' configs by pasting the following code (or from the script) into your own files.
complete -W "-h --help -a --append -p --prepend -s --spread" procspin
This comes with a default animation embedded as an array in the main function, but with the -f,--frames
switch you can use your own set from a string or array of your own characters. These can be single or multiple characters usually using spaces to as empty space where there's not character at that specific frame as I will show you in the example. When using multi-character animations I recommend using arrays of strings rather than trying to format a long string. I really recommend using arrays at all times, but you do what you like, of course.
NOTE
: These default frames may or may not display in some browsers or in a small amount of terminals, but they work in most places and can easily be changed in both the function and by providing your own.
array=('','','','','','','','','','','' \
'','','','','','','','','','','','','','')
frame_array=(\
'▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶ '\
,' ▶')
Silently run find
to log all files to a file with a custom animation with the above frames (after enabling sudo
with some other command, of course):
$ (sudo find / > ~/files.log 2>/dev/null) & procspin -i $! -p " <~ Running 'find'... ~> [" -a "] " -f "${frame_array[@]}"
[4] 53354
<~ Running 'find'... ~> [ ▶]
The best thing to do is to choose the script or AppImage from the 'Continuous Release" page as that should be the most updated versions of each, but the files from the 'Direct Links' should reflect the same versions.
What | Link |
---|---|
Continuous Release - Recommended | https://github.com/Lateralus138/ProcSpin/releases/tag/Continuous |
This Repo - Themed | http://lateralus138.github.io/ProcSpin |
This Repo | https://github.com/Lateralus138/ProcSpin |
OpenDesktop/Pling | https://www.pling.com/p/1435385/ |
File | Description |
---|---|
procspin.bash | Main Bash script. |
procspin-x86_64.AppImage | AppImage format. |
Link | Description |
---|---|
ProcSpin Demo 1 | My special APT Update script. |
ProcSpin Demo 1 | Random demonstration. |
Description | Status |
---|---|
Project Release Date | |
Total downloads for this project | |
Complete repository size | |
Commits in last month | |
Commits in last year | |
Project Quality |
Description | Status | Number of Downloads |
---|---|---|
Latest Release version |
MD5 |
---|
Build |
Status |
MD5 |
---|---|---|
Release | Information | Date |
---|---|---|
Continuous | Initial release. | October, 2021 |
Continuous | Bug fix with bad regex match in --frames argument switch and a major refactor the best of my abilities. |
March 3rd, 2021 |
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.