-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-alias.sh
44 lines (37 loc) · 1.06 KB
/
install-alias.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
#!/bin/bash
# Clean build and dist folders
if [ "$1" = "--fast" ]
then
# remove all files in build folder except six.py, which comes from some dependency
find ./build/ -maxdepth 1 ! -name 'six.py' -type f -exec rm -f {} +
rm -rf build/src
else
rm -rf build/*
fi
rm -rf build/logos
rm -rf dist/*
# Copy files to build folder
[ -d build ] || mkdir build
cp -r src build/src
cp -r logos build/logos
cp __main__.py build/__main__.py
# Install dependencies to build folder
if [ "$1" = "--fast" ]
then
echo "Using deps already in build folder"
else
python3 -m pip install -r requirements.txt --target build
fi
# Package App
[ -d dist ] || mkdir dist
python3 -m zipapp "$(pwd)/build" -o "$(pwd)/dist/previewer.pyz"
# Check if alias is already in .bashrc before adding it
if grep -Fxq "alias preview=\"python3 $(pwd)/dist/previewer.pyz\"" ~/.bashrc
then
# code if found
printf "alias found in ~/.bashrc, leaving as is\n"
else
printf 'alias not found in ~/.bashrc. Adding it\n'
echo "alias preview=\"python3 $(pwd)/dist/previewer.pyz\"" >> ~/.bashrc
fi
exit 0