-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.zsh
executable file
·59 lines (55 loc) · 1.67 KB
/
init.zsh
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
#!/usr/bin/env zsh
declare -r dir_plugin="mlc-ai"
declare -r dir_repository="zed"
declare -r tag_version=$(tail -n 1 "releases.tags") # Latest tag supported by the plugin
declare -r url_repository="https://github.com/zed-industries/zed"
# Clone/Pull Repository
if [ -d $dir_repository ]
then
cd $dir_repository
if [ $tag_version != $(git describe --exact-match --tags) ]
then
git pull
git reset --hard
git checkout tags/$tag_version
fi
cd ..
else
git clone --recursive $url_repository $dir_repository
cd $dir_repository
git checkout tags/$tag_version
cd ..
fi
for file_action in $(find $dir_plugin | awk -F $dir_plugin'/' '{print $NF}' | grep --extended-regexp ".*\.(copy|link|patch)$")
do
action=$(echo $file_action | awk -F '.' '{print $NF}')
file_path_name=$(echo $file_action | awk -F '.'$action '{print $1}')
file_name=$(echo $file_path_name | awk -F '/' '{print $NF}')
file_dir=$(echo $file_path_name | awk -F '/'$file_name '{print $1}')
case $action in
"copy")
# Copy new files
if [ ! -d $dir_repository/$file_dir ]
then
mkdir -p $dir_repository/$file_dir
fi
cp -f "$dir_plugin/$file_action" "$dir_repository/$file_path_name"
;;
"link")
# Create symbolic links
ln -sF "$(cat $dir_plugin/$file_action)" "$dir_repository/$file_path_name"
;;
"patch")
# Patch existent files
patch --version-control=none "$dir_repository/$file_path_name" "$dir_plugin/$file_action"
;;
esac
done
unset action
unset file
unset file_dir
unset file_name
unset file_path_name
cd $dir_repository
cargo build
./target/debug/zed