Skip to content

Commit

Permalink
Merge branch 'feature/ghi-#4-snowblock-bash' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
arcticicestudio committed Jan 18, 2017
2 parents 3e5b053 + a006190 commit 0b664c7
Show file tree
Hide file tree
Showing 19 changed files with 1,270 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# +------------+
# + Snowblocks +
# +------------+
# +--- bash ---+
snowblocks/bash/**/*.local
snowblocks/bash/.log


# +--- git ---+
gitconfig_auth
snowblocks/git/gitconfig_auth
23 changes: 23 additions & 0 deletions snowblocks/bash/bin/colors
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
# title Color Table +
# project igloo +
# repository https://github.com/arcticicestudio/igloo +
# author Arctic Ice Studio +
# email [email protected] +
# copyright Copyright (C) 2017 +
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
DOTS='•••'
printf "\n 40m 41m 42m 43m 44m 45m 46m 47m\n";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m'; do
FG=${FGs// /}
printf " $FGs \033[$FG $DOTS "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do
printf "$EINS \033[$FG\033[$BG $DOTS \033[0m";
done
printf "\n"
done
printf "\n"
unset -v DOTS
36 changes: 36 additions & 0 deletions snowblocks/bash/bin/keybase-stop
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
# title Keybase Stopper +
# project igloo +
# repository https://github.com/arcticicestudio/igloo +
# author Arctic Ice Studio +
# email [email protected] +
# copyright Copyright (C) 2017 +
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# Stops any running keybase services.
set -e -u -o pipefail

if killall Keybase &> /dev/null; then
printf "\e[32m=>\e[0m Keybase GUI\n"
else
printf "\e[31mX\e[0m Keybase GUI\n"
fi

if fusermount -uz /keybase &> /dev/null; then
printf "\e[32m=>\e[0m \e[34m/keybase\e[0m unmount\n"
else
printf "\e[31mX\e[0m \e[34m/keybase\e[0m unmount\n"
fi

if killall kbfsfuse &> /dev/null; then
printf "\e[32m=>\e[0m kbfsfuse\n"
else
printf "\e[31mX\e[0m kbfsfuse\n"
fi

if killall keybase &> /dev/null; then
printf "\e[32m=>\e[0m keybase service\n"
else
printf "\e[31mX\e[0m keybase service\n"
fi
48 changes: 48 additions & 0 deletions snowblocks/bash/bin/treed
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
# title Colored Directory Tree +
# project igloo +
# repository https://github.com/arcticicestudio/igloo +
# author Arctic Ice Studio +
# email [email protected] +
# copyright Copyright (C) 2017 +
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# Prints an numbered advanced, recursive and colored directory treeview.
#
# @throws 1 Invalid option
# @throws 2 Missing argument
# @throws 3 invalid argument

__cleanup() {
unset -v
unset -f help usage __cleanup
}

while getopts ":h" option ; do
case "$option" in
h)
help
exit 0
;;
\?)
printf "Invalid option: -%s" "$OPTARG"
exit 1
;;
:)
printf "-%s requires an argument." "$OPTARG"
exit 2
;;
esac
done

# +--- Null Parameter Handling ---+
if [ -z "$1" -o "$1" = "-" ]; then
help
exit 2
fi

tree -aC -I ".git|node_modules|bower_components" --dirsfirst "$@" | less -FRNX

__cleanup
exit 0
144 changes: 144 additions & 0 deletions snowblocks/bash/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/usr/bin/env bash
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
# title Bash Snowblock Bootstrap +
# project igloo +
# repository https://github.com/arcticicestudio/igloo +
# author Arctic Ice Studio +
# email [email protected] +
# copyright Copyright (C) 2017 +
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# [References]
# StackOverflow
# (http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script/677212#677212)


__snowblock_bash::get_bootstrap_link_target() {
printf "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
}

__snowblock_bash::get_bootstrap_link_source() {
printf "$(readlink $(__snowblock_bash::get_bootstrap_link_target))"
}

__snowblock_bash::get_base_dir() {
if hash realpath 2>/dev/null; then
printf "$(dirname $(realpath "${BASH_SOURCE[0]}"))"
else
printf "$(dirname $(__snowblock_bash::get_bootstrap_link_source))"
fi
}

__snowblock_bash::get_module_basename() {
printf "$($SNOWBLOCK_BASH_BASE_DIR/$(basename "${BASH_SOURCE[0]}"))"
}

__snowblock_bash::log_error() {
printf "\e[31m%s\e[0m\n" "$*" 1>&2
}

__snowblock_bash::log_warning() {
printf "\e[33m%s\e[0m\n" "$*"
}

__snowblock_bash::log_success() {
printf "\e[32m%s\e[0m\n" "$*"
}

__snowblock_bash::log_info() {
printf "\e[34m%s\e[0m\n" "$*"
}

__snowblock_bash::log_debug() {
if [ "$SNOWBLOCK_BASH_DEBUG" = true ]; then
printf "\e[01;30m[\e[0;35m%s\e[01;30m] \e[0;35m%s\e[0m\n" "$(\date "+%Y-%m-%d %H:%M:%S")" "$*"
fi
}

__snowblock_bash::setup_history() {
if [ "$SNOWBLOCK_BASH_HISTORY" = true ]; then
mkdir -p $SNOWBLOCK_BASH_BASE_DIR/.log 2> /dev/null
export HISTFILE=$SNOWBLOCK_BASH_BASE_DIR/.log/`\date "+%Y-%m-%d"`
else
export HISTFILE=
fi
}

__snowblock_bash::load_core_modules() {
local __self_name="$(basename $(readlink "${BASH_SOURCE[0]}"))"

if [ "$#" -eq 0 ]; then
__snowblock_bash::log_debug "[$__self_name] Missing parameter while calling function $FUNCNAME"
__snowblock_bash::log_error "[$__self_name] Error while loading core modules"
return 1
fi
local module

for module in $*; do
module=$SNOWBLOCK_BASH_BASE_DIR/core/$module
if [ -f $module ]; then
. $module
if [ $? -eq 0 ]; then
__snowblock_bash::log_debug "[$__self_name] Core module $(basename $module) successfully loaded"
else
__snowblock_bash::log_debug "[$__self_name] Error while loading core module $(basename $module)"
fi
else
__snowblock_bash::log_error "[$__self_name] Core module $(basename $module) not found"
return 1
fi
done
}

__snowblock_bash::load_third_party_scripts() {
local __self_name="$(basename $(readlink "${BASH_SOURCE[0]}"))"

if [ "$#" -eq 0 ]; then
__snowblock_bash::log_debug "[$__self_name] Missing parameter while calling function $FUNCNAME"
__snowblock_bash::log_error "[$__self_name] Error while loading third-party scripts"
return 1
fi
local script

for script in $*; do
if [ -f $script ]; then
. $script
if [ $? -eq 0 ]; then
__snowblock_bash::log_debug "[$__self_name] Third-Party script $script successfully loaded"
else
__snowblock_bash::log_debug "[$__self_name] Error while loading third-party script $script"
fi
else
__snowblock_bash::log_debug "[$__self_name] Third-Party script $script not found"
fi
done
}

__snowblock_bash::register_binaries() {
export PATH="${PATH}:$SNOWBLOCK_BASH_BINARIES"
}

export SNOWBLOCK_BASH_BASE_DIR="$(__snowblock_bash::get_base_dir)"
export SNOWBLOCK_BASH_HISTORY=true
export SNOWBLOCK_BASH_DEBUG=false
export SNOWBLOCK_BASH_BINARIES=$SNOWBLOCK_BASH_BASE_DIR/bin

# +--------------+
# + Core Modules +
# +--------------+
__snowblock_bash::load_core_modules loader/env loader/pkg
__snowblock_bash::load_core_modules aliases functions prompt shelloptions

# +--------------------+
# +Third-Party Scripts +
# +--------------------+
# Git prompt bash support.
__snowblock_bash::load_third_party_scripts /usr/share/git/completion/git-prompt.sh

# Programmable bash completion features.
__snowblock_bash::load_third_party_scripts /usr/share/bash-completion/bash_completion

__snowblock_bash::setup_history
__snowblock_bash::register_binaries

__snowblock_bash::log_debug "[$(basename $(__snowblock_bash::get_bootstrap_link_source))] bootstrap completed"
1 change: 1 addition & 0 deletions snowblocks/bash/config/env/archbook
37 changes: 37 additions & 0 deletions snowblocks/bash/config/env/igloo
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
# title Igloo Environment +
# project igloo +
# repository https://github.com/arcticicestudio/igloo +
# author Arctic Ice Studio +
# email [email protected] +
# copyright Copyright (C) 2017 +
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
export LANG=en_US.UTF-8
export LC_MESSAGES=POSIX

export STORE_RUN=$HOME/store/run
export BITFROEST_HOME=$HOME/store/bitfroest

export ATOM_HOME=$STORE_RUN/atom
export AUDACITY_PATH=$STORE_RUN/audacity
export FZ_DATADIR=$STORE_RUN/filezilla
export GIMP2_DIRECTORY=$STORE_RUN/gimp
export GRADLE_USER_HOME=$STORE_RUN/gradle
export INKSCAPE_PROFILE_DIR=$STORE_RUN/inkscape
export _JAVA_AWT_WM_NONREPARENTING=1
export JAVA_HOME=/usr/lib/jvm/default
export M2_REPO=$STORE_RUN/apache-maven-3/repository
export PURPLEHOME=$STORE_RUN/pidgin

if [[ -e igloo.env.local ]]; then
. igloo.env.local
else
unset -v GNUPGHOME
fi

PATH_NPM_PACKAGES=$STORE_RUN/npm/bin
PATH_RUBY_GEMS="$HOME/.gem/ruby/2.2.0/bin;$HOME/.gem/ruby/2.3.0/bin"
PATH_INTELLIJ_IDEA_U_HOME=/opt/intellij-idea-u/bin
PATH_GIT_DIFF_HIGHLIGHT=/usr/share/git/diff-highlight
export PATH="${PATH}:$JAVA_HOME/bin:$PATH_NPM_PACKAGES:$PATH_RUBY_GEMS:$PATH_ANI2ICO:$PATH_INTELLIJ_IDEA_U_HOME:$PATH_GIT_DIFF_HIGHLIGHT"
1 change: 1 addition & 0 deletions snowblocks/bash/config/env/illuvigaq
48 changes: 48 additions & 0 deletions snowblocks/bash/config/pkg/grep
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
# title grep Configuration +
# project igloo +
# repository https://github.com/arcticicestudio/igloo +
# author Arctic Ice Studio +
# email [email protected] +
# copyright Copyright (C) 2017 +
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# [References]
# GNU grep
# (http://www.gnu.org/software/grep/manual/grep.html)
# terminfo(5)

# +--------+
# + Colors +
# +--------+
# Set the terminfo capabilitiy substrings for the color environment variable interpreted by the "termcap" compatibility
# application interface.
#
# "sl"
# Whole selected lines. Default is empty.
# "cx"
# Whole context lines. Default is empty.
# "rv"
# Boolean value that reverses (swaps) the meanings of the "sl" and "cx" capabilities. Default is "false".
# "mt"
# Matching non-empty text in any matching line.
# "ms"
# Matching non-empty text in a selected line.
# "mc"
# Matching non-empty text in a context line.
# "fn"
# File names prefixing any content line.
# "ln"
# Line numbers prefixing any content line.
# "bn"
# Byte offsets prefixing any content line.
# "se"
# Separators that are inserted between
# - selected line fields (':')
# - context line fields ('-')
# - groups of adjacent lines when nonzero context is specified ("--")
# "ne"
# Boolean value that prevents clearing to the end of line using erase in line (EL) to Right ("\33[K") each time a
# colorized item ends.
export GREP_COLORS="fn=34:mt=01;34:ln=01;30:se=30"
Loading

0 comments on commit 0b664c7

Please sign in to comment.