gosh icon indicating copy to clipboard operation
gosh copied to clipboard

Shell utilies for gophers.

gosh

Shell utilies for gophers.

Why?

Cryptic syntax of bash, sed, awk and subtle differences between sed/gsed, awk/gawk... I always had a hard time memorising all these stuff. I wanted simple / universal way to manipulate strings in command line like Fish's string builtin. But then I thought it would be much better if we can have some kind of standard shell libraries not just for strings, but for others also, based on Go.

Examples

Install

  • Seperate packages

    go get -u github.com/aca/gosh/gostrings
    go get -u github.com/aca/gosh/gonet
    go get -u github.com/aca/gosh/gofilepath
    go get -u github.com/aca/gosh/gourl
    
  • Unified packages

    go get -u github.com/aca/gosh
    
    # Set alias
    # alias gostrings="gosh gostrings"
    # alias gonet="gosh gonet"
    # alias gofilepath="gosh gofilepath"
    # alias gourl="gosh gourl"
    
  • Completion

    # check installation guide for each command
    gostrings completion --help
    

Usage

gostrings

$ gostrings --help
Usage:
  gostrings [command]

Available Commands:
  compare     func Compare(a, b string) int
  completion  Generate completion script
  contains    func Contains(s, substr string) bool
  containsany func ContainsAny(s, chars string) bool
  count       func Count(s, substr string) int
  fields      func Fields(s string) []string
  hasprefix   func HasPrefix(s, prefix string) bool
  hassuffix   func HasSuffix(s, suffix string) bool
  help        Help about any command
  index       func Index(s, substr string) int
  index       func LastIndex(s, substr string) int
  indexany    func LastIndexAny(s, chars string) int
  indexany    func IndexAny(s, chars string) int
  indexrune   func IndexRune(s string, r rune) int
  repeat      func Repeat(s string, count int) string
  replace     func Replace(s, old, new string, n int) string
  replaceall  func ReplaceAll(s, old, new string) string
  split       func Split(s, sep string) []string
  splitafter  func SplitAfter(s, sep string) []string
  splitaftern func SplitAfterN(s, sep string, n int) []string
  splitn      func SplitN(s, sep string, n int) []string
  title       func Title(s string) string
  tolower     func ToLower(s string) string
  totitle     func ToTitle(s string) string
  toupper     func ToUpper(s string) string
  trim        func Trim(s, cutset string) string
  trimleft    func TrimLeft(s, cutset string) string
  trimprefix  func TrimPrefix(s, prefix string) string
  trimright   func TrimRight(s, cutset string) string
  trimspace   func TrimSpace(s string) string
  trimsuffix  func TrimSuffix(s, suffix string) string

Flags:
  -h, --help   help for gostrings

Use "gostrings [command] --help" for more information about a command.

gofilepath

$ gofilepath --help
Usage:
  gofilepath [command]

Available Commands:
  abs          func Abs(path string) (string, error)
  base         func Base(path string) string
  clean        func Clean(path string) string
  completion   Generate completion script
  dir          func Dir(path string) string
  evalsymlinks func EvalSymlinks(path string) (string, error)
  ext          func Ext(path string) string
  glob         func Glob(pattern string) (matches []string, err error)
  help         Help about any command
  isabs        func IsAbs(path string) bool
  rel          func Rel(basepath, targpath string) (string, error)
  split        func Split(path string) (dir, file string)
  splitlist    func SplitList(path string) []string

Flags:
  -h, --help   help for gofilepath

Use "gofilepath [command] --help" for more information about a command.

gonet

$ gonet --help
Usage:
  gonet [command]

Available Commands:
  completion   Generate completion script
  help         Help about any command
  joinhostport func JoinHostPort(host, port string) string
  lookupaddr   func LookupAddr(addr string) (names []string, err error)
  lookupcname  func LookupCNAME(host string) (cname string, err error)
  lookuphost   func LookupHost(host string) (addrs []string, err error)
  lookuptxt    func LookupTXT(name string) ([]string, error)
  parsecidr    func ParseCIDR(s string) (IP, *IPNet, error)

Flags:
  -h, --help   help for gonet

Use "gonet [command] --help" for more information about a command.

gourl

$ gourl --help
Usage:
  gourl [command]

Available Commands:
  completion    Generate completion script
  help          Help about any command
  parse         func Parse(rawurl string) (*URL, error)
  pathescape    func PathEscape(s string) string
  pathunescape  func PathUnescape(s string) (string, error)
  pathunescape  func QueryEscape(s string) string
  queryunescape func QueryUnescape(s string) (string, error)

Flags:
  -h, --help   help for gourl

Use "gourl [command] --help" for more information about a command.