1
0
mirror of https://github.com/samoshkin/tmux-config.git synced 2026-01-03 08:18:02 +00:00

Make install script runnable on Alpine Linux bash. Do not use rsync,tput, etc

This commit is contained in:
Alexey Samoshkin
2017-12-05 15:02:45 +02:00
parent 867f377bbc
commit 67bfffc10e

View File

@@ -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
ln -sf --backup --suffix=.bak .tmux/tmux.conf "$HOME"/.tmux.conf;
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;
# 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"