-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sh
122 lines (103 loc) · 3.13 KB
/
script.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# Function to detect the distribution
detect_distro() {
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$ID
else
echo "Could not detect distribution."
exit 1
fi
}
# Function to install packages based on distribution
install_packages() {
case "$DISTRO" in
ubuntu|debian)
echo "Detected Debian-based system. Installing packages..."
sudo apt update && sudo apt upgrade -y
sudo apt install -y apache2 bind9 build-essential curl dnsutils fail2ban git htop lsof \
ncdu net-tools neovim nginx nmap rsync shellcheck sysstat tmux tree unzip
;;
arch)
echo "Detected Arch Linux system. Installing packages..."
sudo pacman -Syu --noconfirm
sudo pacman -S --noconfirm apache base-devel bind curl fail2ban git htop inetutils lsof \
ncdu neovim nginx nmap rsync sysstat tmux tree unzip
;;
fedora)
echo "Detected Fedora-based system. Installing packages..."
sudo dnf update -y
sudo dnf install -y apache bind bind-utils curl fail2ban firewalld git htop lsof ncdu \
net-tools neovim nginx nmap rsync shellcheck sysstat tmux tree unzip
;;
*)
echo "Unsupported distribution: $DISTRO"
exit 1
;;
esac
}
# Function to install Starship
install_starship() {
echo "Installing Starship..."
curl -sS https://starship.rs/install.sh | sh -s -- -y
}
# Function to configure Starship
configure_starship() {
echo "Configuring Starship..."
mkdir -p ~/.config
curl -o ~/.config/starship.toml https://starship.rs/presets/toml/no-nerd-font.toml
# Add Starship initialization to shell profile
echo 'eval "$(starship init bash)"' >> ~/.bashrc
echo 'eval "$(starship init zsh)"' >> ~/.zshrc
}
# Function to configure Tmux
configure_tmux() {
echo "Configuring Tmux..."
cat << 'EOF' > ~/.tmux.conf
# Enable mouse mode
set -g mouse on
# Set prefix to Ctrl-a
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Split panes using | and -
bind | split-window -h
bind - split-window -v
# Set default terminal mode to 256color
set -g default-terminal "screen-256color"
# Set the status bar to use Starship
set-option -g status off
EOF
}
# Function to configure Neovim
configure_neovim() {
echo "Configuring Neovim..."
mkdir -p ~/.config/nvim
cat << 'EOF' > ~/.config/nvim/init.vim
" Basic Neovim settings
" Set line numbers
set number
" Enable syntax highlighting
syntax on
" Set tab and indentation
set tabstop=4
set shiftwidth=4
set expandtab
" Enable mouse support
set mouse=a
" Configure clipboard to use system clipboard
set clipboard=unnamedplus
" Set color scheme
colorscheme desert
EOF
}
# Main installation and configuration flow
detect_distro
install_packages
install_starship
configure_starship
configure_tmux
configure_neovim
# Final message
echo "Installation and configuration complete!"
echo "Restart your terminal or source your shell profile to start using Starship."