This commit is contained in:
Jorge Morante 2023-08-15 16:14:23 +02:00
parent 46b7c0f0f4
commit 94dd000661
2 changed files with 55 additions and 10 deletions

58
install-wizard.sh Normal file → Executable file
View File

@ -2,20 +2,62 @@
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PLATFORM=$(uname -s) PLATFORM=$(uname -s)
action=$1
# set up exit trap
function finish {
exit_code=$?
# only intercept exit code when there is an action defined (download, or
# build from source), otherwise we'll enter an infinte loop of sourcing
# tmux.conf
if [[ -z "$action" ]]; then
exit $exit_code
fi
if [[ $exit_code -eq 0 ]]; then
echo "Reloading tmux.conf"
tmux source ~/.tmux.conf
exit 0
else
echo "Something went wrong. Please any key to close this window"
read -n 1
exit 1
fi
}
trap finish EXIT
function install_from_source() {
echo "Installing from source..."
# check if shards is installed
if ! command -v shards >/dev/null 2>&1; then
echo "crystal is not installed. Please install it first."
exit 1
fi
pushd $CURRENT_DIR > /dev/null
shards build --production
popd > /dev/null
echo "Build complete!"
exit 0
}
if [[ "$1" == "download-binary" ]]; then if [[ "$1" == "download-binary" ]]; then
echo "Downloading binary..." echo "Downloading binary..."
exit 0 exit 1
fi fi
if [[ "$1" == "install-with-brew" ]]; then if [[ "$1" == "install-with-brew" ]]; then
echo "Installing with brew..." echo "Installing with brew..."
exit 0 exit 1
fi fi
if [[ "$1" == "install-fromsource" ]]; then if [[ "$1" == "install-from-source" ]]; then
echo "Install from source..." install_from_source
exit 0
fi fi
function binary_or_brew_label() { function binary_or_brew_label() {
@ -42,9 +84,7 @@ tmux display-menu -T "tmux-fingers" \
"- It looks like it is the first time you are running the plugin. We need the binary first for things to work. " "" "" \ "- It looks like it is the first time you are running the plugin. We need the binary first for things to work. " "" "" \
"- " "" ""\ "- " "" ""\
"" \ "" \
"$(binary_or_brew_label)" b "popup \"bash $CURRENT_DIR/install-wizard.sh $(binary_or_brew_action)\"" \ "$(binary_or_brew_label)" b "popup -E \"$CURRENT_DIR/install-wizard.sh $(binary_or_brew_action)\"" \
"Build from source" s "popup \"bash $CURRENT_DIR/install-wizard.sh install-from-source\"" \ "Build from source" s "popup -E \"$CURRENT_DIR/install-wizard.sh install-from-source\"" \
"" \ "" \
"Exit" q "" "Exit" q ""
exit 0

View File

@ -1,9 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "sourcing tmux-fingers.tmux" >> /tmp/wat.log
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ ! -f "$CURRENT_DIR/bin/tmux-fingers" ]; then if [ ! -f "$CURRENT_DIR/bin/tmux-fingers" ]; then
bash $CURRENT_DIR/install-wizard.sh tmux run-shell -b "bash $CURRENT_DIR/install-wizard.sh"
exit 0
fi fi
echo "running bin/tmux-fingers load-config" >> /tmp/wat.log
"$CURRENT_DIR/bin/tmux-fingers" "load-config" "$CURRENT_DIR/bin/tmux-fingers" "load-config"
exit $?