Skip to content

Commit

Permalink
Make install script runnable on Alpine Linux bash. Do not use rsync,t…
Browse files Browse the repository at this point in the history
…put, etc
  • Loading branch information
samoshkin committed Dec 5, 2017
1 parent 867f377 commit 67bfffc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -e
set -u
set -o pipefail

is_app_installed() {
type "$1" &>/dev/null
Expand All @@ -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
Expand All @@ -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"

0 comments on commit 67bfffc

Please sign in to comment.