-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
48 lines (38 loc) · 1.37 KB
/
install.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
#!/bin/bash
# Function to install @cloudimpl-inc/cpm npm package globally
installCpmPackage() {
sudo npm install -g @cloudimpl-inc/cpm
}
# Function to add cpm-git plugin globally
addCpmGitPlugin() {
cpm plugin add -g @cloudimpl-inc/cpm-git
}
# Function to install @cloudimpl-inc/cpm package and add cpm-git plugin globally
installAndConfigureCpm() {
installCpmPackage
addCpmGitPlugin
}
# Function to set aliases
setAliases() {
local startupFiles=("$HOME/.bashrc" "$HOME/.zshrc")
local cpmPath
# Check if cpm alias already exists in any of the shell startup files
for startupFile in "${startupFiles[@]}"; do
# Create the file if it doesn't exist
touch "$startupFile"
if ! grep -q "alias cpm=" "$startupFile"; then
# Determine the full path of the cpm command
cpmPath=$(command -v cpm)
# Append the alias for cpm to the shell startup file
echo "alias cpm=\"source $cpmPath\"" >> "$startupFile"
echo -e "\033[0;32mAlias added: cpm=\"source $cpmPath\" to $startupFile"
echo -e "\033[0;33mRestart your terminal to use the 'cpm' command.\033[0m"
else
echo "Alias 'cpm' already exists in $startupFile"
fi
done
}
# Call the function to install and configure @cloudimpl-inc/cpm
installAndConfigureCpm
# Call the setAliases function
setAliases