Helper functions refactoring

This commit is contained in:
Bruno Sutic
2015-08-03 15:12:45 +02:00
parent eab403b6d8
commit 5adc9a987f
11 changed files with 59 additions and 97 deletions

View File

@ -1,34 +1,14 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HELPERS_DIR="$CURRENT_DIR/helpers"
source "$CURRENT_DIR/shared_functions.sh"
TMUX_ECHO_FLAG="$1"
# True if invoked as tmux mapping or tmux command,
# false if invoked via command line wrapper from `bin/` directory.
use_tmux_echo() {
[ "$TMUX_ECHO_FLAG" == "--tmux-echo" ]
}
if use_tmux_echo; then
# use tmux specific echo-ing
echo_ok() {
tmux_echo "$*"
}
echo_err() {
tmux_echo "$*"
}
else
echo_ok() {
echo "$*"
}
echo_err() {
fail_helper "$*"
}
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
source "$HELPERS_DIR/tmux_echo_functions.sh"
else # shell output functions
source "$HELPERS_DIR/shell_echo_functions.sh"
fi
clean_plugins() {