diff --git a/install-wizard.sh b/install-wizard.sh index 1cab74f..0badb81 100755 --- a/install-wizard.sh +++ b/install-wizard.sh @@ -46,6 +46,16 @@ function install_from_source() { exit 0 } +function install_with_brew() { + echo "Installing with brew..." + brew tap morantron/tmux-fingers + brew install tmux-fingers + + echo "Installation complete!" + exit 0 +} + + function download_binary() { mkdir -p $CURRENT_DIR/bin # TODO check architecture @@ -71,6 +81,7 @@ fi if [[ "$1" == "install-with-brew" ]]; then echo "Installing with brew..." + install_with_brew exit 1 fi @@ -95,7 +106,6 @@ function binary_or_brew_action() { } function get_message() { - # if FINGERS_UPDATE is 1 if [[ "$FINGERS_UPDATE" == "1" ]]; then echo "It looks like tmux-fingers has been updated. We need to rebuild the binary." else diff --git a/tmux-fingers.tmux b/tmux-fingers.tmux index d58040f..0294613 100755 --- a/tmux-fingers.tmux +++ b/tmux-fingers.tmux @@ -2,13 +2,23 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -if [ ! -f "$CURRENT_DIR/bin/tmux-fingers" ]; then +if command -v "tmux-fingers" &>/dev/null; then + FINGERS_BINARY="tmux-fingers" +elif [[ -f "$CURRENT_DIR/bin/tmux-fingers" ]]; then + FINGERS_BINARY="$CURRENT_DIR/bin/tmux-fingers" +fi + +if [[ -z "$FINGERS_BINARY" ]]; then + tmux display-message "running wisar because binary not found" tmux run-shell -b "bash $CURRENT_DIR/install-wizard.sh" exit 0 fi -CURRENT_FINGERS_VERSION="$($CURRENT_DIR/bin/tmux-fingers version)" +CURRENT_FINGERS_VERSION="$($FINGERS_BINARY version)" + +pushd $CURRENT_DIR &> /dev/null CURRENT_GIT_VERSION=$(git describe --tags | sed "s/-.*//g") +popd &> /dev/null SKIP_WIZARD=$(tmux show-option -gqv @fingers-skip-wizard) SKIP_WIZARD=${SKIP_WIZARD:-0} @@ -22,5 +32,5 @@ if [ "$SKIP_WIZARD" = "0" ] && [ "$CURRENT_FINGERS_VERSION" != "$CURRENT_GIT_VER fi fi -"$CURRENT_DIR/bin/tmux-fingers" "load-config" +tmux run "$FINGERS_BINARY load-config" exit $?