Last active
August 24, 2023 16:56
-
-
Save dpastoor/b4acfcd00836bd2ae56f04b755bb619d to your computer and use it in GitHub Desktop.
add-local-bin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if ~/.local/bin directory exists, if not, create it | |
if [ ! -d "$HOME/.local/bin" ]; then | |
mkdir -p "$HOME/.local/bin" | |
echo "Created ~/.local/bin directory" | |
fi | |
# Check if ~/.profile file exists, if not, create it and add ~/.local/bin to PATH | |
if [ ! -f "$HOME/.profile" ]; then | |
touch "$HOME/.profile" | |
echo "Created ~/.profile file" | |
echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.profile" | |
echo "Added ~/.local/bin to PATH in ~/.profile" | |
else | |
# Check if ~/.profile already contains the PATH modification, if not, add it | |
if ! grep -q -F 'export PATH="$HOME/.local/bin:$PATH"' "$HOME/.profile"; then | |
echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.profile" | |
echo "Added ~/.local/bin to PATH in ~/.profile" | |
fi | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
url="https://github.com/evilmartians/lefthook/releases/download/v1.4.9/lefthook_1.4.9_Linux_x86_64" | |
install_path="$HOME/.local/bin" | |
binary_name="lefthook" | |
# Create the installation directory if it doesn't exist | |
mkdir -p "$install_path" | |
# Download the binary | |
echo "Downloading $binary_name..." | |
curl -L "$url" -o "$install_path/$binary_name" | |
# Add execute permissions | |
chmod +x "$install_path/$binary_name" | |
# Check if the binary is successfully installed | |
if [ -x "$(command -v $binary_name)" ]; then | |
echo "$binary_name is installed successfully at $install_path" | |
else | |
echo "Installation of $binary_name failed" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment