Skip to content

RubaXa/bashkit

Repository files navigation

~/.bashkit/

It is the toolset for the developing bash scripts.

Usage

iterm2

#!/bin/bash

if [ ! -d $HOME/.bashkit/ ]; then echo 'Install `~/.bashkit/`'; git clone git@github.com: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 📑
  • Verbose mode ✴️ (just add --verbose)

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

About

~/.bashkit/ — it is the toolset for the developing bash scripts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages