
templates.bin.stool-function Maven / Gradle / Ivy
# Stool shell functions for bash
# Source this file in your ~/.bashrc
export STOOL_INVOCATION=${{stool.bin}}/lib/run/users/.stool-invocation-$$-$(date +%N)
${{man.path}}
stool() {
if [ "$1" = "-service" ] ; then
# don't use invocation file because PS1 would be empty and USER is undefined
local interactiveArgs=""
shift
else
local interactiveArgs="-invocation $STOOL_INVOCATION"
fi
# Special variable handling: they are private and you cannot export them on Mac OS.
# We make them available to the java code under the EXPORTED_ prefix
export EXPORTED_PS1="$PS1"
# adjust this to configure a specific java version
local java=java
local bin=${{stool.bin}}
local cp
local verbose=false
local command="empty"
for arg in $* ; do
case "$arg" in
-v) verbose=true ;;
-*) true ;;
*)
if [ $command = "empty" ] ; then
command=$arg
fi
;;
esac
done
if [ $command = "reselect" ]; then
if [ -f $bin/lib/run/users/$USER ]; then
if $verbose ; then
echo "reselect"
fi
. $bin/lib/run/users/$USER
else
if $verbose ; then
echo "reselect none"
fi
fi
else
if [ -z $STOOL_SOURCE ] ; then
cp="$bin/stool.jar"
else
# for stool development
cp=$STOOL_SOURCE/setup/target/setup-stool
if [ ! -e $cp ] ; then
echo "$cp not found. Check your STOOL_SOURCE variable and re-build."
return
fi
fi
for jar in $bin/lib/extensions/*.jar; do
# caution: if the extensions directory is empty, $jar is the pattern ...
if [ -f $jar ] ; then
cp="$cp:$jar"
fi
done
STOOL_BIN=$bin $java $STOOL_OPTS -cp $cp net.oneandone.stool.Main $interactiveArgs "$@"
result=$?
if [ -f $STOOL_INVOCATION ] ; then
. $STOOL_INVOCATION
# I've seen an empty $USER when running stool from a cron jobs
mv -f $STOOL_INVOCATION $bin/lib/run/users/$USER || (echo "cannot move invocation file, check USER variable: $USER"; rm $STOOL_INVOCATION)
fi
fi
unset EXPORTED_PS1
return $result
}
stoolIndicatorColor() {
local RED="\033[0;31m"
local BLUE_BACKGROUND="\033[44;1;37m"
local DIR=${{stool.bin}}/lib/backstages/$STOOL_SELECTED/anchor
if [ ! -e $DIR ] ; then
echo -e "$BLUE_BACKGROUND"
else
if [ `uname` = Darwin ] ; then
local fmt=-f
else
local fmt=--format
fi
if [ $(id -u) = $(stat -L $fmt %u $DIR) ] ; then
echo -e ""
else
echo -e "$RED"
fi
fi
}
if [ "x$BASH" != "x" ] ; then
export -f stool stoolIndicatorColor
. ${{stool.bin}}/stool-complete
fi
© 2015 - 2025 Weber Informatics LLC | Privacy Policy