-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoBackupConfigs
More file actions
executable file
·58 lines (47 loc) · 1.54 KB
/
autoBackupConfigs
File metadata and controls
executable file
·58 lines (47 loc) · 1.54 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
#!/usr/bin/env bash
admin="$(id -nu 1000)"
USER_HOME=/home/$admin
CONFIGS=(
"$USER_HOME/.config/fastfetch/config.jsonc"
"$USER_HOME/.config/kitty/kitty.conf"
"/etc/locale.conf"
"/etc/dracut.conf.d/myflags.conf"
"$USER_HOME/.config/ohmyposh/myprofile.yaml"
"$USER_HOME/.zshrc"
"$USER_HOME/.config/ghostty/config"
"$USER_HOME/.zen/tizo6sbm.Default (release)/chrome/userChrome.css"
"$USER_HOME/.zen/tizo6sbm.Default (release)/chrome/userContent.css"
"$USER_HOME/.zen/tizo6sbm.Default (release)/chrome/natsumi-config.css"
"$USER_HOME/.config/wofi/config"
"$USER_HOME/.config/wofi/style.css"
"$USER_HOME/.config/yazi/init.lua"
"$USER_HOME/.config/yazi/keymap.toml"
"$USER_HOME/.config/yazi/theme.toml"
"$USER_HOME/.config/yazi/yazi.toml"
)
DEST_FOLDER="$USER_HOME/Dev/Linux/Config/$(hostname)"
mkdir -p "$DEST_FOLDER"
chown "$admin":"$admin" "$DEST_FOLDER"
# Backing up configs
for config in "${CONFIGS[@]}"; do
if ! [[ -f $config ]]; then
continue
fi
FILE_NAME=$(basename "$config")
if [[ $(dirname "$config") == "$USER_HOME" ]]; then
FILE_DIR="user"
else
FILE_DIR=$(basename "$(dirname "$config")")
fi
# This check is to make dot files (hidden files) visible
if [[ $FILE_NAME == .* ]]; then
FILE_NAME="${FILE_NAME#?}"
fi
# This check is to make dot folders (hidden folders) visible
if [[ $FILE_DIR == .* ]]; then
FILE_DIR="${FILE_DIR#?}"
fi
mkdir -p "$DEST_FOLDER"/"$FILE_DIR"
chown "$admin":"$admin" "$DEST_FOLDER"/"$FILE_DIR"
cp "$config" "$DEST_FOLDER"/"$FILE_DIR"/"$FILE_NAME"
done