-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwslfedora.sh
executable file
·154 lines (134 loc) · 3.92 KB
/
wslfedora.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
dnf_packages=(
antigen
zsh
neovim
fira-code-fonts
skopeo
starship
golang
nodejs
docker
kubectl
helm
k9s
rust
terraform
awscli
ImageMagick
htop
jq
php
# composer
mailx
xdotool # No direct equivalent for k6, using xdotool as a placeholder
)
snap_packages=(
# Example: vscode, which is available as a snap package
# code
)
flatpak_packages=(
# Example: Spotify, which is available as a flatpak package
# com.spotify.Client
)
command_exists() {
command -v "$1" >/dev/null 2>&1
}
dnf_package_exists() {
dnf list installed "$1" &>/dev/null || command_exists "$1"
}
install_packages() {
echo "Updating dnf..."
# sudo dnf update -y
sudo dnf copr enable atim/starship -y
sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:zsh-users:antigen/Fedora_Rawhide/shells:zsh-users:antigen.repo
echo "Installing dnf packages..."
for package in "${dnf_packages[@]}"; do
if ! dnf_package_exists $package; then
echo "Installing $package..."
sudo dnf install -y "$package"
else
echo "$package is already installed."
fi
done
echo "Installing snap packages..."
for package in "${snap_packages[@]}"; do
if ! command_exists $package; then
echo "Installing $package..."
sudo snap install "$package"
else
echo "$package is already installed."
fi
done
echo "Installing flatpak packages..."
for package in "${flatpak_packages[@]}"; do
if ! flatpak list | grep -q "$package"; then
echo "Installing $package..."
flatpak install -y "$package"
else
echo "$package is already installed."
fi
done
# Composer global require as an example of post-install command
# composer global require laravel/installer
}
move_dotfiles() {
backup_folder="$HOME/.dotbackup"
mkdir -p "$backup_folder"
copy_with_backup() {
local source="$1"
local dest="$2"
# if [ -e "$dest/$source" ]; then
# echo "Backing up existing $dest$source..."
# mv "$dest$source" "$backup_folder/$(basename "$source").$(date +%Y%m%d%H%M%S)"
# fi
echo "Copying $source to $dest..."
# Use cp without -l for cross-device copying
cp -l "$source" "$dest"
}
copy_no_hardlink() {
local source="$1"
local dest="$2"
# if [ -e "$dest/$source" ]; then
# echo "Backing up existing $dest$source..."
# mv "$dest$source" "$backup_folder/$(basename "$source").$(date +%Y%m%d%H%M%S)"
# fi
echo "Copying $source to $dest..."
cp "$source" "$dest"
}
# Check if file exists before copying
[ -e .zprofile-fedora ] && copy_with_backup .zprofile-fedora ~/.zprofile
[ -e .zshrc-fedora ] && copy_with_backup .zshrc-fedora ~/.zshrc
[ -e .wezterm.lua ] && copy_no_hardlink .wezterm.lua ~/winhome/
# if [ -d ~/.config ]; then
# echo "Backing up existing ~/.config..."
# mv ~/.config "$backup_folder/.config.$(date +%Y%m%d%H%M%S)"
# fi
echo "Copying .config to ~/"
# Use cp -r without -l for directories, especially across devices
cp -lr .config ~/
}
echo "What would you like to do?"
echo "1. Install packages"
echo "2. Move dotfiles"
echo "3. Both (install packages and move dotfiles)"
read -p "Enter your choice (1/2/3): " choice
case $choice in
1)
install_packages
;;
2)
move_dotfiles
;;
3)
install_packages
move_dotfiles
;;
*)
echo "Invalid choice. Exiting."
exit 1
;;
esac
echo "Done. Please consider your terminal and desktop environment for further customization."
echo "Please install https://github.com/tonsky/FiraCode/releases for Fira Code font."
chsh -s $(which zsh)