Giter VIP home page Giter VIP logo

bashkit's Introduction

~/.bashkit/

It is the toolset for the developing bash scripts.

Usage

iterm2

#!/bin/bash

if [ ! -d $HOME/.bashkit/ ]; then echo 'Install `~/.bashkit/`'; git clone [email protected]:RubaXa/bashkit.git $HOME/.bashkit; fi
source "$HOME/.bashkit/all.sh";

inputRead "Enter %username%:" name;
hrLine $(logDone "Hi, $name" $(emojiStatus "ok"));

inputReadYesNo "Are you wish to play even/odd?" game $Y;
if [[ $game == $Y ]]; then
	echo "";

	while : ; do
		inputReadChar "Even/Odd (e/o)?:" ans
		num=$RANDOM;
		echo -n "Number $num is" ""

		if (( $num % 2 == 0 )); then echo -n "Even!"; res="e";
		else echo -n "Odd!"; res="o"; fi

		if [[ $res == $ans ]]; then
			echo "" $(colorize $COLOR_DONE "You WIN!") $(emojiStatus done);
		else
			echo "" $(colorize $COLOR_ERR "You LOOSE!") $(emojiStatus err);
		fi

		echo ""
	done
fi

Features

  • AutoUpdate support 🚀
  • Easy and intuitive development 💡
  • Logging (levels supports), Colors and Emoji 😁
  • Documentation 📑

Development

  • ./all.sh --bashkit-docs — Docs generator.

Constants

Functions

riskCreate [branch] [deploy]
  • [branch] — create risk for git-branch
  • [deploy] — push & switch created tarball to risk branch
riskPush name branch
  • name — tarball name
  • branch — risk branch
riskSwitch name branch
  • name — tarball name
  • branch — risk branch
  • name — tarball name
riskRemove name [branch=trb]
  • name — tarball name
  • [branch=trb] — risk branch
  • [branch] — risk branch
riskGetList [branch]
  • [branch] — risk branch

fsGetFiles path [depth=1]
fsWriteFile file content
fsReplaceInFile file pattern value
fsReplaceInFiles path pattern value

inputRead text ref
inputReadChar text ref
inputReadYesNo text ref [def=$N] [attempts=2]
inputSelect text ref ...items
  • ref — will contains a selected index

arrayIncludes value ...list
  • ...list — for example arrayIncludes "y" "x" "y", or arrayIncludes $val ${list[@]}

stringTest regex value
stringGetMatch regex value
stringGetMatches regex value

Constants

Functions

colorize color ...text
colorRemove ...text

Constants

Functions


timeParse value
  • value — ex.: 2s, 5m, 24h or 5d

Constants

Functions

log level ...msg
  • level — msg, ok, done, info, warn, err, verbose
logMsg ...msg
logErr ...msg
logDone ...msg
logWarn ...msg
logInfo ...msg
logVerbose ...msg
hrLine ...msg
logHead text
logFinish [status] [done=DONE] [failed=FAILED]

Constants

Functions

required val errMsg
assignVar ref val
getArg name
RE pattern forSED
range from to
md5hash value

Constants

Functions

  • raw — a result of pkgJsonRead

Constants

Functions

execute cmd [ref-status]
  • [ref-status] — execution result status, $EXEC_OK — success, else failed
executeIf cond cmd [ref-status]
  • cond — $Y/$EXEC_OK or $N
  • [ref-status] — execution result status, $EXEC_OK — success, else failed
executeIfNot cond cmd
  • cond — $Y/$EXEC_OK or $N

emojiStatus [name=done]
  • [name=done] — ok, err or done

recently name period ...fn
  • period — ex: 5m, 24h or 7d

bashkit's People

Contributors

rubaxa avatar

Watchers

James Cloos avatar

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.