From 67bfffc10e63ee7c4409dbe58fcb09dc93f5299c Mon Sep 17 00:00:00 2001 From: Alexey Samoshkin Date: Tue, 5 Dec 2017 15:02:45 +0200 Subject: [PATCH] Make install script runnable on Alpine Linux bash. Do not use rsync,tput, etc --- install.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index a2e8e49..9a0abe1 100755 --- a/install.sh +++ b/install.sh @@ -2,6 +2,7 @@ set -e set -u +set -o pipefail is_app_installed() { type "$1" &>/dev/null @@ -11,13 +12,13 @@ REPODIR="$(cd "$(dirname "$0")"; pwd -P)" cd "$REPODIR"; if ! is_app_installed tmux; then - printf "$(tput setaf 1)WARNING:$(tput sgr0) \"tmux\" command is not found. \ + printf "WARNING: \"tmux\" command is not found. \ Install it first\n" exit 1 fi if [ ! -e "$HOME/.tmux/plugins/tpm" ]; then - printf "$(tput setaf 1)WARNING:$(tput sgr0) Cannot found TPM (Tmux Plugin Manager) \ + printf "WARNING: Cannot found TPM (Tmux Plugin Manager) \ at default location: \$HOME/.tmux/plugins/tpm.\n" git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm fi @@ -26,16 +27,17 @@ if [ -e "$HOME/.tmux.conf" ]; then printf "Found existing .tmux.conf in your \$HOME directory. Will create a backup at $HOME/.tmux.conf.bak\n" fi -rsync -aq ./tmux/ "$HOME"/.tmux +cp -f "$HOME/.tmux.conf" "$HOME/.tmux.conf.bak" 2>/dev/null || true +cp -a ./tmux/. "$HOME"/.tmux/ +ln -sf .tmux/tmux.conf "$HOME"/.tmux.conf; -ln -sf --backup --suffix=.bak .tmux/tmux.conf "$HOME"/.tmux.conf; - -# Install TPM plugins. +# Install TPM plugins. # TPM requires running tmux server, as soon as `tmux start-server` does not work # create dump __noop session in detached mode, and kill it when plugins are installed +printf "Install TPM plugins\n" tmux new -d -s __noop >/dev/null 2>&1 || true tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "~/.tmux/plugins" "$HOME"/.tmux/plugins/tpm/bin/install_plugins || true tmux kill-session -t __noop >/dev/null 2>&1 || true -printf "$(tput setaf 2)OK:$(tput sgr0) Completed\n" +printf "OK: Completed\n"