GithubHelp home page GithubHelp logo

kissbash's Introduction

kissbash - A Simple and Stupid Bash Script Library

Despite what people say, I decide to write a bash script library.

If nobody cares, at least it will benefit myself.

How to use

Set the KISSBASH_PATH environment variable and you are good to go.

$ git clone https://github.com/yyu/kissbash.git ~/.kissbash
$ export KISSBASH_PATH=~/.kissbash/kissbash

Example

$ cat > /tmp/myscript << "EOF"
. "$KISSBASH_PATH/console/lines"
echos 3; echo line1
echo line2 | line_pre_echo_control up1 up1 up1
echo line3
echos 10
cat /tmp/myscript | line_pre_echo_control up1 up1
echos 7
EOF

output:

$ bash4 /tmp/myscript

line2
line3
line1

echos 7
cat /tmp/myscript | line_pre_echo_control up1 up1
echos 10
echo line3
echo line2 | line_pre_echo_control up1 up1 up1
echos 3; echo line1
. "$KISSBASH_PATH/console/lines"

$

Document

console/lines

echos

One argument:

$ . $KISSBASH_PATH/console/lines
$ (echos 2; echo hello) | cat -n
     1	
     2	
     3	hello

More than one argument:

$ . $KISSBASH_PATH/console/lines
$ (echos 3 .; echo hello) | cat -n
     1	...hello

serr_with_color

$ . $KISSBASH_PATH/console/lines
$ echo hello | serr_with_color red
hello

You should see red hello in your console.

tee_serr_with_color

$ . $KISSBASH_PATH/console/lines
$ echo hello | tee_serr_with_color red
hello
hello
$ echo hello | tee_serr_with_color red > /dev/null
hello

You should see red hello for stderr and normal hello for stdout.

line_pre_echo_control

$ . $KISSBASH_PATH/console/lines
$ echo -e "\none\n"; echo two; echo three

one

two
three
$ echo -e "\none\n"; echo two | line_pre_echo_control up1; echo three

one
two
three

exec/explicitly

$ . $KISSBASH_PATH/exec/explicitly
$ explicitly echo "2+3" | bc
echo 2+3
5

testing

$ t/test-all
Running /.../kissbash/t/bash/test-assoc-array
PASS test_bash_version_too_low
PASS test_bash_version_ok
PASS test_bash_version_high

Running /.../kissbash/t/util/test-explicitly-exec
PASS test_explicitly_good

**************************************DONE**************************************

for details,
cat /var/folders/yd/c3kph1693ns3rtft7jwscyj5snhf_t/T/tmp.qWVmW057
```

Tip: t/test-all -v will automatically show details.

kissbash's People

Contributors

yyu avatar

Stargazers

Joe avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

joe-nano

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.