-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive-nvim.sh
executable file
·65 lines (49 loc) · 1.29 KB
/
archive-nvim.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
#!/bin/bash
if [ -d ./out ]; then
rm -rf out
fi
mkdir -p out/config
mkdir -p out/data
cp -r ~/.config/nvim out/config/
cp -r ~/.local/share/nvim out/data/
if [ -f /usr/local/bin/rust-analyzer ]; then
sudo cp /usr/local/bin/rust-analyzer out/rust-analyzer
fi
cat <<EOF >out/move.sh
#!/bin/bash
rm -rf ~/.config/nvim
rm -rf ~/.local/share/nvim
mv config/nvim ~/.config/
mv data/nvim ~/.local/share/
if [ -f rust-analyzer ]; then
sudo mv rust-analyzer /usr/local/bin/
fi
EOF
cat <<"EOF" >out/update_links.sh
#!/bin/bash
# Define the old and new user
OLD_DIR=""
NEW_DIR=""
# Loop through all symbolic links in the current directory
for link in *; do
# Check if it is a symbolic link
if [ -L "$link" ]; then
# Get the current target of the symbolic link
current_target=$(readlink "$link")
echo "$current_target"
# Check if the target contains the old directory path
if [[ "$current_target" == "$OLD_DIR"* ]]; then
# Replace the old directory path with the new directory path
new_target=${current_target//$OLD_DIR/$NEW_DIR}
# Remove the old symbolic link
rm "$link"
# Create a new symbolic link with the updated target
ln -s "$new_target" "$link"
echo "Updated $link -> $new_target"
fi
fi
done
EOF
chmod +x out/move.sh out/update_links.sh
tar -zcvf out.tar.gz out
rm -rf out