gotab

command module
v0.0.0-...-909ef36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2016 License: BSD-3-Clause Imports: 14 Imported by: 0

README

Tab completion for Go binary

Introduction

This program provides tab completion information for the Go binary. Currently, this only works with the doc tool in the go binary for version 1.5.

Furthermore, this only works for bash, but thin wrappers can be used to make it work with other shells.

Installation

  1. Get and build the binary: go get github.com/dsnet/gotab
  2. If necessary, place $GOPATH/bin in your $PATH. Otherwise, copy the binary from $GOPATH/bin/gotab to somewhere reachable from $PATH.
  3. Add the following to your bashrc file: complete -C gotab -o nospace go

Usage

Use the go binary and hit tab to auto-complete if possible.

Thus, when you type the following and hit tab:

$ go doc runtime CP

It will auto-complete to the following:

$ go doc runtime CPUProfile

If there are more than one possible completion, then they will be listed:

$ go doc runtime Read
ReadMemStats   ReadTrace

Documentation

Overview

GoTab is helper program that provides information for tab completion on the Go command.

To install:

  1. Build the gotab binary and place it in your PATH.
  2. Add the following to your bashrc file: complete -C gotab -o nospace go

This program works by taking advantage of the built-in complete command for bash. The complete command above informs bash to call gotab for suggestions anytime tab completion is used on the go binary. When gotab is called by bash, it will be provided with the environment variables COMP_LINE and COMP_POINT where COMP_LINE contains the user's current command line and COMP_POINT points to the location of the user's cursor. This program ignores any characters in COMP_LINE that lies beyond COMP_POINT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL