Git Product home page Git Product logo

sack's People

Contributors

aarongamble avatar dooktibs avatar ernstki avatar hakamadare avatar jordanlewis avatar kunaltyagi avatar liuyang1 avatar premek avatar sampson-chen avatar simonhoibm avatar spodkowinski avatar urguardian4ngel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sack's Issues

sag/sack F is broken trying to use ansi-colors in filename

$ sag cmd
sack__option is: -ag

============> running ag! <============

===> Current Profile: no_profile
===> Using flags:
===> Searching under: /Users/daniel/tmp/sack
===> Searching parameters: cmd


/Users/daniel/tmp/sack/sack
[1] 150:create_shortcut_cmd() {
[2] 153:    sack__shortcut_cmd_path=~/bin/$sack__shortcut_cmd
[3] 154:    echo "#!/bin/bash" > $sack__shortcut_cmd_path
[4] 155:    echo "sack__vim_shortcut=\$(sed -n \"\$1p\" < $sack__shortcut_file)" >> $sack__shortcut_cmd_path
[5] 156:    echo "$sack__default_editor +\$sack__vim_shortcut" >> $sack__shortcut_cmd_path
[6] 157:    chmod +x $sack__shortcut_cmd_path
[7] 162:    # Get the specified profile name from cmdline
[8] 551:    echo "===== Use: \"$sack__shortcut_cmd #\" to go directly to the search result!"
[9] 552:    echo "===== Example: ( user@linux:~$ $sack__shortcut_cmd 25 )"
[10] 556:create_shortcut_cmd

Then I run F 1

"^[[1;32m/Users/daniel/tmp/sack/sack^[[0m^[[K" [New DIRECTORY]
Error detected while processing command line:
E492: Not an editor command: ^[[1;33m150^[[0m^[[K
Press ENTER or type command to continue

sag -g filename support

It would be nice to support this scenario.
Expected: to open a given file with F
Actual:

$ sag -g filename
sack__option is: -ag

============> running ag! <============

===> Current Profile: no_profile
===> Using flags: 
===> Searching under: /home/etc/etc
===> Searching parameters: -g filename


/home/etc/etc/filename
[1] 

$ F 1
sed: -e expression #1, char 10: unknown option to `s'

And it opens the editor in working directory

Stacked searches

I'm tracing function calls right now and it'd be great to be able to EG:

sag get_by_fixed_ip
F 1
sag -push FixedIP.get
F 1
F 2
sag -pop
F 2

I've made a lot of updates and fixes.

I was wondering if you are interested in adding me as a Contributor/Maintainer for this repo. I have noticed there are some PRs, issues and what not. Would you be interested in making me a Maintainer or should we make my fork "official"?

This is my first time trying to help maintain a project, apologies if my etiquette is incorrect.

broken in vim

$ sag foo
# ...results...
$ F 1
# vim opens to an empty buffer, for file ""/my/actual/desired/file""

I believe the cause is the escaped quotes around $sack__file, added in the last commit. @db5526e

Without them, F 1 behaves as expected.

Shell history should have the actual command that was run instead of "F somenumber"

sack stores F somenumber in shell history instead of the actual editor command that was run. Across multiple searches these aren't the same locations. Sack functionality should be decoupled from shell history so exact locations can be revisited via shell history.

$ sack something
...
$ F 1
...
$ <press up> # this should give the actual editor command that was run and not F 1

These lines added to the sack script (at line 163 in ~/bin/sack) work in zsh.

HISTFILE=~/.zhistory # or wherever your history is
sed -i '$ d' \$HISTFILE # delete the F somenumber that was added
/bin/zsh -ic "print -s \$sack__editor +\$sack__line \"\$sack__file\"" # add actual command to the shell history
\$sack__editor +\$sack__line "\$sack__file"

If you run a sack search now, the shell history stores the actual locations visited. You might want to do fc -R in zsh.

Let me know what you think of this feature and if it could be implemented in a portable way that works across shells. Would be happy to submit a PR.

multiple directories to search, and announce them in the profile

sack -sd ~/some/other/ ~/bar/foo/ and other variants is not possible, although there is a mention or two of directory(s) in the script.
This -i-s- possible admittedly a ~/some/other/ is set and then doing "prompt$ sack foo ~/bar/foo/" will search and spit both the results in the preset in profile AND the command added directory.
The above way one has sack now searching the profile announced directory AND the command line hinted directory.

Question: how to set reliably multiple directories in a profile, since I am using ag and not ack, is ag the culprit?

The additional reason is that the results cannot be called up from another terminal for the directory added to the command, sack script switches to the profile declared directory only to act upon "F #"
Logically there is no way of knowing for the script what the command line given directory is.

Regards, the added possibility to jump from a different terminal to a search result and open the editor, is an appreciated time and focus gain. This way, is also cleaner then within vim doing the search, one is not always within the editor, and the quickview of vim has not the real estate of the terminal window.

Support for ripgrep?

Love the sack tool. I just discovered http://blog.burntsushi.net/ripgrep/ today, and was wondering if sack could support it now, and if not how hard it would be to include that support.

Apologize in advance if this is the wrong place to ask this. Feel free to close issue immediately.

sag does not honor piped data

Using ag:

 ag shortcut | ag create
sack:150:create_shortcut_cmd() {
sack:556:create_shortcut_cmd

using sack

$ sag shortcut | sag create
sack__option is: -ag

============> running ag! <============

===> Current Profile: no_profile
===> Using flags:
===> Searching under: /Users/daniel/tmp/sack
===> Searching parameters: create


/Users/daniel/tmp/sack/install_sack.sh
[1] # If the install directory doesn't exist, create it

/Users/daniel/tmp/sack/sack
[2] create_shortcut_cmd() {
[3]         echo "To create a new profile, do:"
[4] create_shortcut_cmd

Note that result [3] does not contain the word shortcut

Using an old .sackrc (prior to 2c6ed83) prevents 'F' helper script from being created

I'm filing this issue because I'm part of the problem: I wrote the part of the install script that prompts you whether you want to overwrite an existing .sackrc.

The problem is, as of 2c6ed83, there's a new variable which has been added to the "factory" .sackrc (sack__shortcut_path) that's absolutely required for the F command to work, and you get the error

/path/to/your/home/bin/sack: line 154: /F: Permission denied

if you run sack with a .sackrc that predates this commit.

The problem occurs at this point and several others in thesack script. You can see the problem is that, because sack__shortcut_path is undefined, sack tries to write the F script to the root directory, which hopefully you don't have permissions to as a normal user.

Since no one else seems to have experienced this problem (at least not reported it), I'm not going to propose adding any kind of band-aids to the install_sack.sh installation script. I might think about it for a couple of days, and probably just close this issue, so it remains searchable for anyone else who might have this problem in the future.

For what it's worth, my solution was to compare the new .sackrc in the repo to mine (I used vimdiff) and copy over the changed lines (in this case, just lines 9-11). This way I didn't lose existing profiles, but I got the definition of sack__shortcut_path that's necessary for the F command to work.

Open all search result in one vim instance as tabs

Vim has a feature called clientserver, if start vim with same servername, files will open in the same instance instead multiple:
vim --servername ios_code +34 main.m
vim --servername ios_code +125 test.m

I found it's really convenience to switch between search results inside the same vim instance.

I also think it's a good idea to use current pofile name as severname, so different profile will has its own vim instance.
I can implement this feature using script like this:
\$sack__editor -p --servername $sack__profile_name --remote-tab-silent +\$sack__line "\$sack__file"

It looks like clientserver feature will need gui mode vim, we can check if vim has this feature with script like this:
vim --version | grep -c '+clientserver'

Per-shell sessions

It would be great if sack could maintain a list of saved tags per shell session - I quite often have multiple terminals open still showing the output of previously-run sacks, and would find it helpful to be able to jump straight to any of the results without having to worry about which was run most recently.

Colorized results cause file open problems

By default both ag and ack colorize their results on my terminal.

sack tries to open the colorized file name which includes escape characters and fails.

Running with the --no-color option works as expected.

Update: I see sack__os is initialized in ~/.sackrc but apparently sack isn't sourcing that file? In any case putting a manual sack__os=uname within the function to strip out escape code characters with sed also doesn't seem to work.

sag --help scrambled

sag --help numbers every line of ag --help.

Instead, how about leaving it as is, or, like sack --help, showing the help of sack?

So at

sack/sack

Line 480 in f0cfda6

if [[ "$sack__option" == "-ag" ]]; then

the check at

sack/sack

Line 490 in f0cfda6

elif [[ -z "$sack__option" || "$sack__option" == "-h" || "$sack__option" == "--help" || "$sack__option" == "--info" ]]; then

could be copy-pasted.

Context lines shouldn't be tagged

If I run sack with -C3, I get output like:

/home/lealexis/w/nova/nova/objects/fixed_ip.py
[1] 122-        if expected_attrs is None:
[2] 123-            expected_attrs = []
[3] 124-        get_network = 'network' in expected_attrs
[4] 125:        db_fixedip = db.fixed_ip_get(context, id, get_network=get_network)
[5] 126-        return cls._from_db_object(context, cls(context), db_fixedip,
[6] 127-                                   expected_attrs)
[7] 128-

Only [4] is follow-able though.

It'd be better if only the middle line was tagged and followable. This would help prevent the tag numbers growing so quickly.

If you fix this, please ensure context lines are properly indented so the code aligns correctly.

Also remember that two context sections can run together. In this case, both hits should be numbered.

No F validations

F makes no attempt to validate input; 'F abc' and 'F 0' (for example) are not handled gracefully.

no_profile profile_name -- cumbersome to me

sack__profile_name=.
sack__profile_preset_flags=""
sack__profile_preset_directory=""

after sack'ing all weekend and realizing how much i'd missed profiles i'd like to leave you these ideas:

change the 'no_profile' name to '.'
-- i think its more usable out of the box that way, its shorter and representative of what you want.

check for the presence of ack/ag binaries and store something/anything as the customizable command.
-- i dont have ack installed at all and making a shortcut 'just for sack'. ok, but not really.

check for the presence of .sackrc and re-create it as needed.
-- you can't actually use sack after sudo installing until you create ~/.sackrc

i could go completely nuts with profiles...

sack . x .. find x here
sack .crm x .. find x using the .crm profile
sack .crm ... switch to .crm profile for the next search

these would run a search using a named profile. if the first param was a profile name. i'd be responsible for picking profile names that i'd not search for, so no worries about chars and prefixes.

.sackrc .. in ~/ could be supplanted by .sackrc in the cwd (and up) so that profiles would work well with teams and repos. .. sack.config and! sack.json would make better names/formats for that purpose too.

sack's now indispensible over here ๐Ÿ‘ thanks for that!

Install instructions

I just tried the following command (as suggested) to install sack:

git clone [email protected]:sampson-chen/sack.git && cd sack && chmod +x install_sack.sh && ./install_sack.sh

and I got the following error:

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

I believe when cloning using the [email protected] URL, git tries to authenticate the user with Github's servers. I don't think that's necessary since this is a public repo.

Instead, the following command worked fine for me:

git clone https://github.com/sampson-chen/sack.git && cd sack && chmod +x install_sack.sh && ./install_sack.sh

If this problem is reproducible on other machines, it might be worth updating README.md to reflect the alternate URL.

Add a git tag for versioning

I would like to help you pack this tool into a homebrew formula for easier installation on OS X.

However, I need a git tagged version for packing. Would you please add a tag, and push it to GitHub? Thanks!

`sag` now fails when `.sackrc` does not exist

This error does not exist in 6a89205.

/home/vagrant/bin/sack: line 564: $sack__dev_null: ambiguous redirect
/home/vagrant/bin/sack: line 564: $sack__shortcut_file: ambiguous redirect
ERR: Error stat()ing:
ERR: Error opening directory : No such file or directory

/home/vagrant/bin/sack: line 577: [: ==: unary operator expected
/home/vagrant/bin/sack: line 579: [: ==: unary operator expected
Error: unsupported default editor specified in sack__default_editor

not working with emacs

emacs shortcut create function missing

sack__option is: /home/redfeast/.sackrc

============> running ack! <============

===> Current Profile: no_profile
===> Using flags:
===> Searching under: /home/redfeast
===> Searching parameters: /home/redfeast/.sackrc

/home/redfeast/bin/ack: line 1: syntax error near unexpected token newline' /home/redfeast/bin/ack: line 1: '

Error: unsupported default editor specified in sack__default_editor

Support for SublimeText

Pretty please.

(I've seen the note in the README, I'm just opening this so I can be notified when it's implemented)

sag/sawk problem when search for pattern with spaces

$ /bin/bash -x sag -Q 'write body'
+ sack -ag -Q write body
sack__option is: -ag

============> running ag! <============

===> Current Profile: ipnc
===> Using flags: 
===> Searching under:  
===> Searching parameters: -Q write body

 ERR: Error stat()ing: body
 ERR: Error opening directory body: No such file or directory

sag script removes quotes and sawk interprets second word as directory to search.

Calling sack -ag directly has same problem.
sack -ag -Q 'write body'

F: illegal option -- t on OS X

sag / sack works fine, but when I try to open a line from .sack_shortcuts with F, then it throws the error

find: illegal option -- t

install directory is hardcoded

I use ~/local for all my installs because it gets too cluttered otherwise. --prefix=$HOME/local otherwise I get ~/include ~/lib as well as ~/bin

However, in create_shortcut_cmd() I see the command path is hardcoded as sack__shortcut_cmd_path=~/bin/$sack__shortcut_cmd which obviously doesn't work for me.

Seems .sackrc would be a reasonable place to make this configurable?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.