-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-tmux.sh
executable file
·47 lines (37 loc) · 1.42 KB
/
setup-tmux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
is_app_installed() {
type "$1" &>/dev/null
}
REPODIR="$(cd "$(dirname "$0")"; pwd -P)"
cd "$REPODIR";
if ! is_app_installed tmux; then
printf "WARNING: \"tmux\" command is not found. \
Install it first\n"
exit 1
fi
if [ ! -e "${HOME}/.tmux/plugins/tpm" ]; then
printf "WARNING: Cannot find TPM (Tmux Plugin Manager) \
at default location: ${HOME}/.tmux/plugins/tpm.\n"
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
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
cp -f "${HOME}/.tmux.conf" "${HOME}/.tmux.conf.bak" 2>/dev/null || true
ln -sf "${HOME}"/dotfiles/tmux/tmux.conf "${HOME}"/.tmux.conf;
ln -sf "${HOME}"/dotfiles/tmux/tmux.remote.conf "${HOME}"/.tmux/tmux.remote.conf;
# Install dependencies
printf "Installing dependencies\n"
sudo apt install gawk net-tools coreutils -y
# 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 "Installing 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 "OK: Completed\n"