Skip to content

Instantly share code, notes, and snippets.

@dpastoor
Last active August 24, 2023 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpastoor/b4acfcd00836bd2ae56f04b755bb619d to your computer and use it in GitHub Desktop.
Save dpastoor/b4acfcd00836bd2ae56f04b755bb619d to your computer and use it in GitHub Desktop.
add-local-bin
#!/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
#!/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