# Advanced Command Line

### [**@git2samus**](https://github.com/git2samus)

this allows invocations as the previous but also permits passing arguments to curl like: gi --proxy somewhere:8080 -- linux python

```bash
function gi() (
    gi_args=()
    for arg; do
        if [[ $arg = -- ]]; then
            curl_args=("${gi_args[@]}")
            gi_args=()
        else
            gi_args+=("$arg")
        fi
    done
    IFS=,
    curl "${curl_args[@]}" https://www.toptal.com/developers/gitignore/api/"${gi_args[*]}"
)
```

### [**@git2samus**](https://github.com/git2samus)

Adds a check to see if curl or wget is installed.

```bash
if hash curl; then
    curl "${curl_args[@]}" https://www.toptal.com/developers/gitignore/api/"${gi_args[*]}"
elif hash wget; then
    wget -O- "${curl_args[@]}" https://www.toptal.com/developers/gitignore/api/"${gi_args[*]}"
else
    echo "please install curl or wget to run this command" >&2
    exit 1
fi
```

### [**@GeorgeErickson**](https://github.com/GeorgeErickson)

Bash one-liner

```bash
function gi { curl https://www.toptal.com/developers/gitignore/api/"$(IFS=, ; echo "$*")"; }
```

### [**@SantoshSrinivas79**](https://github.com/SantoshSrinivas79)

Create a file for the function using vim \~/.config/fish/functions/gi.fish and enter the below code

```
function gi
  curl -L -s https://www.toptal.com/developers/gitignore/api/$argv;
end
```

### [**oh-my-zsh**](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/gitignore/gitignore.plugin.zsh)

Provides completion for zsh

```bash
function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@ ;}

_gitignoreio_get_command_list() {
  curl -sL https://www.toptal.com/developers/gitignore/api/list | tr "," "\n"
}

_gitignoreio () {
  compset -P '*,'
  compadd -S '' `_gitignoreio_get_command_list`
}

compdef _gitignoreio gi
```

### [**@z**ubin](https://github.com/zubin)

Provides completion for fish

```bash
complete -f -c git -n '__fish_git_using_command ignore' -a '(__fish_print_gitignore_list)'

function __fish_print_gitignore_list
if ! set -q __FISH_PRINT_GITIGNORE_LIST
   set -g __FISH_PRINT_GITIGNORE_LIST (curl -sL https://www.toptal.com/developers/gitignore/api/list)
end
echo $__FISH_PRINT_GITIGNORE_LIST | string split ","
end
```

### [**@Phoenix09**](https://github.com/Phoenix09)

Improved git alias `tee` to `.gitignore` and accept multiple parameters

```bash
git config --global alias.ignore \
'!gi() { IFS=","; curl -L -s "https://www.toptal.com/developers/gitignore/api/$*" | tee .gitignore;}; \
gi'

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gitignore.io/use/advanced-command-line.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
