-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfedora_setup.sh
executable file
·117 lines (102 loc) · 3.55 KB
/
fedora_setup.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
#!/usr/bin/env bash
# Exit on error and print all commands
set -e
set -o pipefail # Ensure the pipeline returns the error of the last failed command
# Log file
LOG_FILE="$HOME/setup_log.txt"
exec > >(tee -a "$LOG_FILE") 2>&1 # Redirect all output to both stdout and a log file
# Function to log messages
log_msg() {
local msg="$1"
echo "$(date "+%Y-%m-%d %H:%M:%S") - $msg"
}
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Refresh the shell environment for updates to take effect
refresh_env() {
log_msg "Refreshing shell environment..."
# Source the shell configuration to apply environment changes
if [[ -f "$HOME/.bashrc" ]]; then
. "$HOME/.bashrc"
elif [[ -f "$HOME/.bash_profile" ]]; then
. "$HOME/.bash_profile"
fi
}
# Function to install packages
install_packages() {
log_msg "Installing packages: $@"
sudo dnf install -y "$@" || { log_msg "Failed to install packages: $@"; exit 1; }
}
# Update system packages
log_msg "Updating system..."
sudo dnf update -y || { log_msg "System update failed"; exit 1; }
refresh_env # Refresh after system update
# Install essential development tools and libraries
log_msg "Installing development tools and libraries..."
install_packages gcc gcc-c++ make cmake perl-core openssl-devel
# Install system utilities and other tools
log_msg "Installing system utilities..."
install_packages \
file ffmpeg p7zip jq poppler-utils fd-find ripgrep fzf zoxide \
ImageMagick xclip wl-clipboard xsel jetbrains-mono-fonts-all \
gtk3-devel clang ninja-build git stow openssh
# Clone and set up dotfiles
log_msg "Setting up dotfiles..."
if [ ! -d "$HOME/dotfiles" ]; then
git clone https://github.com/atheeq-rhxn/dotfiles.git "$HOME/dotfiles"
fi
cd "$HOME/dotfiles"
stow -t "$HOME/.config" config
stow -t "$HOME" home
cd "$HOME"
refresh_env # Refresh after dotfiles setup
# Install Ghostty
log_msg "Installing Ghostty..."
if ! command_exists ghostty; then
sudo dnf copr enable -y pgdev/ghostty
sudo dnf install -y ghostty || { log_msg "Failed to install Ghostty"; exit 1; }
else
log_msg "Ghostty is already installed."
fi
refresh_env # Refresh after installing Ghostty
# Install Rust
log_msg "Installing Rust..."
if ! command_exists rustup; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y || { log_msg "Rust installation failed"; exit 1; }
else
log_msg "Rust is already installed."
fi
refresh_env # Refresh after installing Rust
# Install Cargo packages in a batch
log_msg "Installing Cargo packages..."
cargo install --locked yazi-fm yazi-cli nu starship ouch gitui zellij || { log_msg "Cargo package installation failed"; exit 1; }
refresh_env # Refresh after Cargo packages
# Install xremap
log_msg "Setting up xremap..."
if ! command_exists xremap; then
sudo dnf copr enable -y blakegardner/xremap
sudo dnf install -y xremap || { log_msg "xremap installation failed"; exit 1; }
else
log_msg "xremap is already installed."
fi
cd "$HOME/dotfiles"
./setup-xremap.sh || { log_msg "Failed to set up xremap"; exit 1; }
cd "$HOME"
refresh_env # Refresh after setting up xremap
# Install Helix Editor
log_msg "Installing Helix..."
mkdir -p "$HOME/src"
cd "$HOME/src"
if [ ! -d "helix" ]; then
git clone https://github.com/helix-editor/helix
cd helix
cargo install --path helix-term --locked || { log_msg "Helix installation failed"; exit 1; }
else
log_msg "Helix is already installed."
fi
cd "$HOME"
refresh_env # Refresh after installing Helix
# Final message
log_msg "Setup complete! Please log out and log back in for all changes to take effect."