Skip to content

Instantly share code, notes, and snippets.

@dpastoor
Last active August 24, 2023 16:56
Show Gist options
  • Select an option

  • Save dpastoor/b4acfcd00836bd2ae56f04b755bb619d to your computer and use it in GitHub Desktop.

Select an option

Save dpastoor/b4acfcd00836bd2ae56f04b755bb619d to your computer and use it in GitHub Desktop.

Revisions

  1. dpastoor revised this gist Aug 24, 2023. 1 changed file with 22 additions and 0 deletions.
    22 changes: 22 additions & 0 deletions lefthook
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/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
  2. dpastoor created this gist Aug 22, 2023.
    21 changes: 21 additions & 0 deletions add-local-bin.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/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