-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.sh
More file actions
executable file
·53 lines (43 loc) · 1.19 KB
/
utils.sh
File metadata and controls
executable file
·53 lines (43 loc) · 1.19 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
#!/usr/bin/env zsh
print_header() {
echo "=== $1 ==="
}
print_footer() {
echo "=== $1 ✅ ==="
echo ""
}
safe_create_folder() {
folder_path=$1
if [[ ! -d $folder_path ]]; then
mkdir -p $folder_path
echo -e "- created $folder_path folder 🆕"
else
echo -e "- $folder_path folder already exists 🗂"
fi
}
DATETIME_FORMAT="%Y-%m-%d_%H-%M-%S"
create_backup() {
mkdir -p "$HOME/.bury-setup-backups/"
if [ -f "$1" ]; then
cp "$1" "$HOME/.bury-setup-backups/$(basename $1)_$(date +$DATETIME_FORMAT)"
fi
}
setup_extra_source_scripts() {
local dest_dir="$HOME/zshrc-scripts"
[ -d "$dest_dir" ] || mkdir -p "$dest_dir"
# Define the source files
local source_file_prefix=".zshrc_"
local scan_dir=$1
local source_files=($(find $scan_dir -type f -name "$source_file_prefix*.sh"))
# Loop over the source files
for source_file in "${source_files[@]}"; do
# Extract the filename from the source file path
local file_name=$(basename "$source_file")
# Check if the source file exists and copy it
if [ -f "$source_file" ]; then
cp "$source_file" "$dest_dir/$file_name"
else
echo "Source file $source_file does not exist."
fi
done
}