-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·39 lines (30 loc) · 948 Bytes
/
install.sh
File metadata and controls
executable file
·39 lines (30 loc) · 948 Bytes
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
#!/usr/bin/env bash
set -e
# ensure ~/.local/bin exists
mkdir -p "$HOME/.local/bin"
TARGET_PATH='export PATH="$HOME/.local/bin:$PATH"'
# detect shell config file (macOS defaults to zsh)
if [ -n "$ZSH_VERSION" ] || [ "$(basename "$SHELL")" = "zsh" ]; then
RC_FILE="$HOME/.zshrc"
elif [ -n "$BASH_VERSION" ]; then
RC_FILE="$HOME/.bashrc"
else
RC_FILE="$HOME/.profile"
fi
if ! echo "$PATH" | grep -q "$HOME/.local/bin"; then
echo "$TARGET_PATH" >> "$RC_FILE"
echo "Added ~/.local/bin to PATH in $RC_FILE"
fi
# apply
export PATH="$HOME/.local/bin:$PATH"
# finally, install tool
echo "Installing path..."
SCRIPT_URL="https://raw.githubusercontent.com/sophb-ccjt/path-cli/main/path.sh"
INSTALL_DIR="$HOME/.local/bin"
INSTALL_PATH="$INSTALL_DIR/path"
mkdir -p "$INSTALL_DIR"
echo
curl -fsSL "$SCRIPT_URL" -o "$INSTALL_PATH"
chmod +x "$INSTALL_PATH"
echo "path installed to $INSTALL_PATH"
echo "Make sure $INSTALL_DIR is in your PATH."