forked from latitudesh/lsh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·56 lines (45 loc) · 1.54 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
49
50
51
52
53
54
55
56
#!/bin/bash
OS=$(uname -s)
ARCH=$(uname -m)
BASE_FILENAME="lsh_%s_%s"
FILENAME=$(printf "$BASE_FILENAME" "$OS" "$ARCH")
# The latest release will be the most recent non-prerelease, non-draft release.
LATEST=$(curl -L -s \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/latitudesh/lsh/releases/latest | grep "tag_name" | cut -d "\"" -f 4)
URL="https://github.com/latitudesh/lsh/releases/download/$LATEST/$FILENAME.tar.gz"
echo -e "[lsh] Download started!\n"
curl -L -o lsh.tar.gz $URL
echo -e "[lsh] Download finished!\n"
echo -e "[lsh] Setting up the CLI\n"
HOME_DIR=$(echo ~)
INSTALL_DIR="$HOME_DIR/.lsh"
mkdir -p $INSTALL_DIR
tar -xzf lsh.tar.gz
mv "$FILENAME/lsh" $INSTALL_DIR
# Detect the current shell and add the directory to the user's PATH
SHELL_NAME=$(basename "$SHELL")
SHELL_CONFIG_PATH=""
case "$SHELL_NAME" in
"bash")
SHELL_CONFIG_PATH=~/.bashrc
echo "export PATH=$PATH:$HOME_DIR/.lsh" >> $SHELL_CONFIG_PATH
;;
"zsh")
SHELL_CONFIG_PATH=~/.zshrc
echo "export PATH=$PATH:$HOME_DIR/.lsh" >> $SHELL_CONFIG_PATH
;;
"fish")
SHELL_CONFIG_PATH=~/.config/fish/config.fish
echo 'set -gx PATH $PATH $HOME_DIR/.lsh' >> $SHELL_CONFIG_PATH
;;
*)
echo "Unsupported shell: $SHELL_NAME"
;;
esac
echo -e "[lsh] Removing installation files\n"
rm lsh.tar.gz
rm -rf $FILENAME
echo -e "[lsh] Installation finished! To enable the lsh command, run: \n"
echo -e " source $SHELL_CONFIG_PATH \n"