-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·92 lines (74 loc) · 2.81 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·92 lines (74 loc) · 2.81 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
#****************************************************************************
# Filename : setup.sh
# Created : Thu Jun 6 2024
# Author : Zolo
# Github : https://github.com/zolodev
# Description : Automate the installation of dotfiles and configurations.
#****************************************************************************
echo "Installing dot files for current user"
echo $USER
# Getting the full path from where the script is executed from
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
# Unlink previous links if any before remove files
unlink $HOME/.vimrc
unlink $HOME/.vim
unlink $HOME/.bashrc
unlink $HOME/.dir_colors
unlink $HOME/.tmux.conf
unlink $HOME/.start_tmux.sh
unlink $HOME/.hushlogin
# Remove any old files
if [ -f "$HOME/.bashrc" ]; then
mv "$HOME/.bashrc" "$HOME/.bashrc.bak"
fi
rm -rf $HOME/.vimrc
rm -rf $HOME/.vim
rm -rf $HOME/.dir_colors
rm -rf $HOME/.tmux.conf
rm -rf $HOME/.start_tmux.sh
rm -rf $HOME/.hushlogin
# Setup new links
ln -s $SCRIPT_DIR/vimrc $HOME/.vimrc
ln -s $SCRIPT_DIR/vim $HOME/.vim
ln -s $SCRIPT_DIR/bashrc $HOME/.bashrc
ln -s $SCRIPT_DIR/.dir_colors $HOME/.dir_colors
ln -s $SCRIPT_DIR/tmux.conf $HOME/.tmux.conf
ln -s $SCRIPT_DIR/start_tmux.sh $HOME/.start_tmux.sh
ln -s $SCRIPT_DIR/hushlogin $HOME/.hushlogin
# Install tmux plugins
rm -rf "$HOME/.tmux/plugins/tpm"
git clone https://github.com/tmux-plugins/tpm $HOME/.tmux/plugins/tpm
# --- Install tmux.service only if tmux is installed ---
if command -v tmux >/dev/null 2>&1; then
echo "tmux command found, trying to install tmux.service."
# Skip systemd installation inside Toolbox
if [ -f /run/.toolboxenv ]; then
echo "Toolbox environment detected, will NOT install tmux.service."
else
# Installing systemd tmux.service
SERVICE_NAME="tmux.service"
USER_SERVICE_PATH="$HOME/.config/systemd/user/$SERVICE_NAME"
# Remove old user service if it exists
if systemctl --user list-unit-files | grep -q "^$SERVICE_NAME"; then
systemctl --user disable --now tmux.service 2>/dev/null
fi
rm -rf "$USER_SERVICE_PATH"
# Install new user service
mkdir -p "$HOME/.config/systemd/user"
ln -s "$SCRIPT_DIR/tmux.service" "$USER_SERVICE_PATH"
# Remove old system service if it exists
if systemctl list-unit-files | grep -q "^$SERVICE_NAME"; then
systemctl disable --now tmux.service 2>/dev/null
fi
# Reload systemd and enable service
systemctl --user daemon-reload
systemctl --user enable --now tmux.service
fi
else
echo "Cannot find tmux, tmux.service will not be installed."
fi
# Print success message echo "Setup completed successfully"
echo "Setup completed successfully"
# Ensure the script exits with status code 0 exit 0
exit 0