Skip to content

A .gitignore wizard in your command line written in Golang

License

Notifications You must be signed in to change notification settings

ntk148v/goignore

Repository files navigation

GoIgnore

Warning

I have switched to a shell script based on fzf to replace goignore. Therefore, this tool won't be updated.

function gi() {
    selections=$(curl -sL https://www.toptal.com/developers/gitignore/api/list\?format\=lines | fzf -m --height=80% \
        --prompt='' --pointer='' \
        --border=sharp \
        --preview='curl -sL https://www.toptal.com/developers/gitignore/api/{}' \
        --preview-window='45%,border-sharp' \
        --prompt='gitignore ▶ ' \
        --bind='ctrl-r:reload(curl -sL https://www.toptal.com/developers/gitignore/api/list\?format\=lines)' \
        --bind='ctrl-p:toggle-preview' \
        --header '
--------------------------------------------------------------
* Tab/Shift-Tab:       mark multiple items
* ENTER:               append the selected to .gitignore file
* Ctrl-r:              refresh the list
* Ctrl-p:              toggle preview
* Ctrl-q:              exit
* Shift-up/Shift-down: scroll the preview
--------------------------------------------------------------
')

    if [[ ${#selections[@]} == 0 ]]; then
        echo "▶ Nothing selected"
        return 0
    fi

    # allow multi-select
    touch $PWD/.gitignore
    while IFS= read -r s; do
        url="https://www.toptal.com/developers/gitignore/api/$s"
        if grep -q "$url" "$PWD/.gitignore"; then
            echo "$s already added in gitignore, skipping ..."
            continue
        fi
        curl -sL "$url" >>$PWD/.gitignore
        echo "▶ Appended: $s"
    done <<<"$selections"
}

A .gitignore wizard which generates .gitignore files from the command line for you. Inspired by joe

1. Features

  • No installation necessary - just use the binary.
  • Works on Linux, Windows & MacOS.
  • Interactive user interface with bubbletea: Pagination, Filtering, Help...
  • Supports all Github-supported .gitignore files.

2. Install

  • Download the latest binary from the Release page. It's the easiest way to get started with goignore.
  • Make sure to add the location of the binary to your $PATH.

3. Usage

  • Just run.
chmod a+x goignore
goignore
  • At the first time, goignore will download the Gitignore templates from Github. It may take a few seconds (depend on your network).

  • The list of gitignore templates.

  • Show help.

  • Filter.

  • Result, the current gitignore is updated.