Expand file tree
/
Copy pathinstall.bash
More file actions
106 lines (84 loc) · 4.13 KB
/
Copy pathinstall.bash
File metadata and controls
106 lines (84 loc) · 4.13 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env bash
# In short, this script will install the KrabbaScript compiler from https://github.com/KrabbaTek/krabbascript
# It will do the following things:
# - run `go install https://github.com/KrabbaTek/krabbascript`
# - set up the KrabbaScript modules directory (~/.kscript/libs) if it doesn't already exist
# - prompt you to install Cranium (the KrabbaScript package manager — more information can be found here: https://github.com/KrabbaTek/Cranium-cli)
# To get and run this script in a pretentious one-liner, run:
# /bin/bash -c "$(curl -fsSL https://github.com/_gh/raw/Centurion774477/krabbascript/refs/heads/dev/install.bash)"
# You could also do this if you don't mind the verbosity:
# curl -fsSL https://github.com/_gh/raw/Centurion774477/krabbascript/refs/heads/dev/install.bash | install.bash
# bash install.bash
# This will save the script as install.bash, and then run that script via Bash.
# Written by Reece Turner
# check if Golang is installed, since we cannot run `go install` without Golang
if ! command -v go >/dev/null 2>&1
then
echo "You don't have Golang installed."
echo "Sadly, I cannot install this for you, so you'll need to visit https://go.dev/doc/install and install Golang yourself."
exit 1
fi
# install KrabbaScript if not already installed
# somehow this check doesn't work.
# I'm keeping it nevertheless because it could work on somebody else's machine
if ! command -v krabbascript >/dev/null 2>&1
then
# I might want to pipe the output of this into /dev/null
go install github.com/KrabbaTek/krabbascript@latest
# if command failed
if [ $? -ne 0 ]
then
echo "Something went wrong installing KrabbaScript."
exit 1
fi
# add ~/go/bin to PATH unless it's already there
# todo: fix this to check for other shells
if ! grep -qs 'go/bin' ~/.zshrc; then
echo "KrabbaScript was installed, but it has not yet been added to your PATH."
read -p "Would you like to add ~/go/bin to your PATH? [Y/n] ~> " path_answer < /dev/tty
# downcase the input
path_answer=$(echo "$path_answer" | tr '[:upper:]' '[:lower:]')
if [[ "$path_answer" == "y" || -z "$input" ]]
then
# find the correct config file
for RC_FILE in "$HOME/.zshrc" "$HOME/.bashrc" "$HOME/.bash_profile" "$HOME/.profile"
do
# next unless this config file exists
[[ -f "$RC_FILE" ]] || continue
if ! grep -qs 'go/bin' "$RC_FILE"; then
echo 'export PATH="$PATH:$HOME/go/bin"' >> "$RC_FILE"
fi
done
echo "Added go/bin to your path. Remember to restart your terminal for the changes to be applied."
else
echo "Understood, just remember to add KrabbaScript to your PATH. You can find the code in ~/go/bin"
fi
fi
fi
# create libs directory if it doesn't exist
if [ ! -d ~/".kscript/libs" ]
then
echo $'\n\nWould you like to create the libs directory in ~/.kscript/libs?'
echo "This will store any libraries installed from Cranium or anywhere else."
read -p "You should skip this if you don't plan on using any external libraries, otherwise I recommend creating it. [Y/n] ~> " input < /dev/tty
input=$(echo "$input" | tr '[:upper:]' '[:lower:]')
if [[ "$input" == "y" || -z "$input" ]]
then
mkdir -p ~/".kscript/libs"
# check if the command ran successfully
if [ $? -ne 0 ]
then
echo "Sorry, but something went wrong creating ~/.kscript/libs."
else
echo "Successfully created libraries directory."
fi
fi
fi
# check if Cranium is installed, and don't prompt them if it is
if ! command -v cranium >/dev/null 2>&1
then
echo "You might want to consider installing Cranium — the package manager for KrabbaScript."
echo "More information — and an install script — for Cranium can be found here: https://github.com/KrabbaTek/Cranium-cli"
echo "If you want a purely local version, then check out Cranium Off the Grid here: https://github.com/KrabbaTek/Cranium-off-the-grid"
fi
echo "Kiitos paljon, hei hei!"