GitHub - wick3dr0se/bashin: BASH framework
source link: https://github.com/wick3dr0se/bashin
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
bashin
A minimal pure BASH framework
Bashin is a framework intended to be as minimal and clean as possible. Wrote in pure BASH, bashin aims for speed and ingenuity
Many scripters resort to external commands that could be instead handled elegantly with builtins. Bashin can be used as a calculator e.g. ADD 5+7
output: 12
, among many other things; Ran interactively or from within another script
Bashin handles things like ANSI escape sequences that make coloring, positioning and other modifications much more simple (like a TUI)
Contents
Setup
clone the repository
git clone https://github.com/wick3dr0se/bashin && cd bashin/
copy bashin to your home directory
cp .bashin $HOME/
source bashin
. ~/.bashin
append to your .bashrc to use interactively & globally
How to Use
ANSI [4BIT]
4BIT '<string>' <fg-color> <bg-color> <style>
4BIT '<string>' <fg-color> <style>
[4BIT]-foreground color & background color params:
black
- set fg/bg color to blackred
- set fg/bg color to redgreen
- set fg/bg color to greenyellow
- set fg/bg.color to yellowblue
- set fg/bg color to bluepurple
- set fg/bg color to purplelight-blue
- set fg/bg color to light bluewhite
- set fg/bg color to white
[4BIT]-style params:
bold
- set bold styledim
- set faint styleitalic
- set italic styleunderline
- set underline styleblink
- set blinking styleblink-fast
- set rapid blinking styleinverse
- set inverse stylehidden
- set hidden stylestrike
- set cross out style
ANSI [VT100]
VT100 '<cursor>' '<erase>'
[VT100]-cursor params:
home
- move cursor to 0,0position-n-n
- move cursor to row #n, col $nup-n
- move up #n rowsdown-n
- move down #n rowsright-n
- move right #n columnsleft-n
- move left #n columns^down-n
- move down to beginning of row #n^up-n
- move up to beginning of row #ncol-n
- move cursor to column #ncursor
- get cursor positionup-scroll
- move up 1 row & scrollsave
- save cursor positionrestore
- restore cursor to the last save position
[VT100]-erase params:
cursor
- erase from cursor to end of screen^cursor
- erase from beg of screen to cursorscreen
- erase entire screensaved
- erase saved rowsrow
- erase from cursor to end of row^row
- erase start of row to cursor^row$
- erase the entire row
ANSI [RAINBOW]
RAINBOW '<string>'
Arithmetic
[INCREMENT]
INCREMENT <start> + <increment> = <max>
[DECREMENT]
DECREMENT <start> - <decrement> = <max>
[MULTIPLY]
MULTIPLY <x> * or x <y>
[DIVIDE]
DIVIDE <numerator> / <denominator>
[MODULO]
MODULO <numerator> % <denominator>
[ADD]
ADD <x> + <y>
[SUBTRACT]
SUBTRACT <x> - <y>
String Manipulation
[RANDOM_ELEMENT]
RANDOM_ELEMENT "<array[@]>"
[UNIQUE_ELEMENT]
UNIQUE_ELEMENT "<array1[@]>" "<array2[@]>"
Miscellaneous
[ABSOLUTE_PATH]
ABSOLUTE_PATH '<script_name>'
Communication
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK