Skip to content

zph/go-sack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sack

Search and edit those results instantly. (Named comes from search-ack, now ag).

Demonstration

sack demo

Details

Search for specific terms in files using AG (the-silver-searcher) and then jump to instantly edit those lines in VIM.

Sack outputs those shortcuts into ~/.sack_shortcuts for easy editing/re-use across any terminal on the system.

It's a reimplementation of sack, which was a ruby re-implementation of the original bash script sack.

Installation (on Mac)

wget -o ~/bin/sack https://github.com/zph/go-sack/releases/download/v0.3.0/sack && chmod +x ~/bin/sack

Or for the reckless:

curl -sSL https://github.com/zph/go-sack/raw/master/src/install | bash -s

Installation on other platforms

Install script will try to match for the right version of binary (only amd64 arch):

curl -sSL https://github.com/zph/go-sack/raw/master/src/install | bash -s

Check for your platform's bin on repo's Release Page.

Install that into somewhere in your $PATH and chmod +x that puppy.

OR:

Install from source using usual go build. Clone it && make build or make install.

For shell integration (sets up two aliases) add the following to your .zshrc or .bashrc

eval "$(sack init)"

Usage

To search in a directory:

sack -s SEARCH_TERM [DIRECTORY: defaults to current]

OR (with shell integration)

S SEARCH_TERM [DIRECTORY: defaults to current]

To edit one of those results by index number (zero indexed):

sack -e 1

OR (with shell integration)

F 1

To display current shortcuts:

sack -p

Options

NAME:
   Sack - sack [searchterm] [optional directory]

USAGE:
   sack [global options] command [command options] [arguments...]
   
VERSION:
   0.4.0
   
COMMANDS:
    init	shell init script
    eval	shell eval command to insert into .{zsh,bash}rc

GLOBAL OPTIONS:
   --edit, -e			edit a given shortcut
   --search, -s			search-ack/ag it
   --print, -p			display existing shortcuts
   --debug, -d			show all the texts
   --flags value, -f value	flags to pass to ag
   --help, -h			show help
   --version, -v		print the version
   

Credit

Original idea & implementation belong to @sampson-chen: https://github.com/sampson-chen/sack.

Rewritten for cleanliness in go-lang for speed b/c Ruby standalone scripts with dependencies aren't convenient, & b/c Shell scripts past a certain length are unwieldy.

Dependencies

License

MIT License (MIT) Copyright (c) 2014 Zander Hill

Contributing

Input and pull requests are welcomed!

  1. Fork it ( http://github.com/zph/go-sack/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

It's like sack.sh but in golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published