-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·84 lines (67 loc) · 2.32 KB
/
install
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
#!/bin/bash
echo " __ ____"
echo " ____ ___ __ _______/ /_ ___ / / /"
echo " / __ __ \/ / / / ___/ __ \/ _ \/ / / "
echo " / / / / / / /_/ (__ ) / / / __/ / / "
echo " /_/ /_/ /_/\__, /____/_/ /_/\___/_/_/ "
echo " /____/ Installer"
echo ""
read -p "Are you sure you want to install myshell? [Y/n] " answer
if [ "$answer" != "${answer#[Nn]}" ] ;then
echo "Installation cancelled"
exit 0
fi
echo "Installing..."
echo "Creating directories..."
cd $HOME
mkdir .myshell -p
cd .myshell
mkdir bin -p
# Get meta data from the latest release
echo "Looking for the latest release..."
json=$(curl -s https://api.github.com/repos/cophilot/msh/releases/latest)
# get the tag name of the latest release
version=$(echo $json | grep -Po '"tag_name": "\K.*?(?=")')
echo "Found version: $version"
# Add myshell script
echo "Adding msh..."
url=https://github.com/cophilot/msh/releases/download/$version/msh
curl -sL $url > bin/msh
chmod +x bin/msh
# Add scripts
echo "Adding scripts..."
curl -s https://raw.githubusercontent.com/cophilot/msh/main/uninstall > bin/msh-uninstall
chmod +x bin/msh-uninstall
curl -s https://raw.githubusercontent.com/cophilot/msh/main/update > bin/msh-update
chmod +x bin/msh-update
curl -s https://raw.githubusercontent.com/cophilot/msh/main/mshx > bin/mshx
chmod +x bin/mshx
# Add scripts directory
mkdir scripts -p
# Add configuration files
echo "Adding configuration files..."
# only if the file does not exist
if [ ! -f .conf ]; then
curl -s https://raw.githubusercontent.com/cophilot/msh/main/.conf.template > .conf
fi
if [ ! -f .mshrc ]; then
curl -s https://raw.githubusercontent.com/cophilot/msh/main/.mshrc.template > .mshrc
chmod +x .mshrc
fi
curl -s https://raw.githubusercontent.com/cophilot/msh/main/LICENSE > LICENSE
# Edit .bashrc/.zshrc
rc_file="$HOME/.bashrc"
if [ -f ~/.zshrc ] && [ "$SHELL" == "/bin/zsh" ]; then
rc_file="$HOME/.zshrc"
fi
echo "Editing $rc_file..."
if ! grep -q "export MSH_HOME*" $rc_file; then
echo "" >> $rc_file
echo "# msh" >> $rc_file
echo 'export MSH_HOME="$HOME/.myshell"' >> $rc_file
fi
if ! grep -q "source \$MSH_HOME/.mshrc" $rc_file; then
echo 'source $MSH_HOME/.mshrc' >> $rc_file
fi
echo "Installation complete"
echo "Please restart your terminal or run 'source $rc_file' to start using myshell"