func terminalWidth() (int, error) {
	if !istty {
		return 0, errors.New("Not Supported")
	}
	echoLockMutex.Lock()
	defer echoLockMutex.Unlock()
	fd := int(tty.Fd())
	ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ)
	if err != nil {
		return 0, err
	}
	return int(ws.Col), nil
}
terminalWidth returns width of the terminal.
package pb
import (
	"errors"
	"fmt"
	"os"
	"os/signal"
	"sync"
	"syscall"
	"golang.org/x/sys/unix"
)
var ErrPoolWasStarted = errors.New("Bar pool was started")
var (
	echoLockMutex    sync.Mutex
	origTermStatePtr *unix.Termios
	tty              *os.File
	istty            bool
)
func init() {
	echoLockMutex.Lock()
	defer echoLockMutex.Unlock()
	var err error
	tty, err = os.Open("/dev/tty")
	istty = true
	if err != nil {
		tty = os.Stdin
		istty = false
	}
}