mooz / percol Goto Github PK
View Code? Open in Web Editor NEWadds flavor of interactive filtering to the traditional pipe concept of UNIX shell
adds flavor of interactive filtering to the traditional pipe concept of UNIX shell
Is it possible for percol to continuously read from the stream with percol
somthing like
tail -f /var/log/messages | percol
Hi, thanks for the nice Python app.
It will be nice if there is a documentation to use percol as a Python module. I am requesting this because I am using percol as a Python module for my advanced shell history app called RASH. I want to use percol as Python module as I want to issue request to SQLite DB as you type query in percol.
I have several suggestions:
bin/percol
to percol.cli
or something like that. Ideally, bin/percol
just contains from percol.cli import main; main()
(not one-linear, of course ^^). Otherwise, people need to reimplement functions such as load_rc
.percol.Percol
need to be set even if it is optional. For example, I needed to pass candidates=[]
.real-to-display
/ display-to-real
in helm/anything. How about allowing any object that have __str__
for collection
(so, you need to convert it to strings somewhere)? Module user can get that object by passing some custom actions.Here is the related part in RASH:
https://github.com/tkf/rash/blob/master/rash/interactive_search.py
Hello.
I've package percol for Fedora and discower you have outdated file headers:
percol.x86_64: E: incorrect-fsf-address /usr/bin/percol
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/command.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/debug.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/view.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/tty.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/ansi.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/markup.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/display.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/action.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/lazyarray.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/__init__.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/info.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/model.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/actions.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/cli.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/key.py
percol.x86_64: E: incorrect-fsf-address /usr/lib/python3.4/site-packages/percol/finder.py
By our guidelines https://fedoraproject.org/wiki/Common_Rpmlint_issues#incorrect-fsf-address I shoul inform you.
Hi,
I get this since a few days. I'm using percol with zsh for history
Error: 'ascii' codec can't encode character u'\xe9' in position 0: ordinal not in range(128)
Maybe I mistyped a command, but I don't kno how to get rid of it.
Thanks
IOError: [Errno 13] Permission denied: '/tmp/percol-log'
because another user owns that file.
I would like Percol to be able to work in a "reverse" or "negate" mode, in which lines matching my query strings would be removed from the output. It would be the equivalent of grep -v
, but with Percol's awesomeness. :)
Is there any way we could either enable some kind of wrapping mode, and/or allow horizontal scrolling?
I'm using peco to analyse logfiles with some rather long loglines - and the pertinent content is at the end of the line (i.e. off to the right of the screen).
There is some ipython integration? (tab-tab activation)
Setup completes without error, but when run from an account other than root I get this error:
$ ls | percol
Traceback (most recent call last):
File "/usr/local/bin/percol", line 29, in <module>
from percol.cli import main
ImportError: No module named percol.cli
I presume this has to do with my python version or configuration, but don't know how to fix it.
$ uname -a ; python --version
Linux wh-lap-090 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:12:00 UTC 2013 i686 i686 i686 GNU/Linux
Python 2.7.5+
$ git log --abbrev-commit -n 1
commit 03aaf84
Merge: 40f9887 db4d8d7
Author: mooz <[email protected]>
Date: Sun Jun 15 00:11:03 2014 +0900
Merge branch 'master' of github.com:mooz/percol
I like that Percol colorizes text and the selected line background, but the white-on-magenta of the selected line is not very readable on my screen, because the contrast between the text and the magenta background is not very strong. After some digging I found where I can change the colors in view.py
, but maintaining my own fork for this seems like overkill.
It'd be really nice if Percol supported customizable colors, perhaps by command-line options, or by a config file.
Thanks a lot for Percol!
main()
in cli.py is huge and not so customizable. It would be nice to separate it into smaller functions.
If a have an array
arr = [a, b, c]
and i want to pass this array to percol, how could i do it?
Thanks for your answer! Great software piece!
These dont seem to work
"Escape" : lambda percol: percol.cancel(),
"Esc" : lambda percol: percol.cancel(),
I'd like to have prompt at the bottom because you need to change your focus to the top of the terminal when start using percol. It would be nice if percol can show candidates and prompt "upside down", like this:
|
|
| candidate 3
| candidate 2
| candidate 1
| QUERY>
Can percol have an option to do this?
as title
I use frequently following scenario:
<pipe> | percol | pecol | <pipe>
In the first call of the percol
I choose multiple output (percol.command.toggle_mark_all()
), in the second call of the
percol
I am searching through the output of the first one.
This works. But I have to decide to call multiple percol
at beginning. What I want is to call just:
<pipe> | pecol | <pipe>
but with possibilities to cascade search. I would like to press M- to say:
"OK, what I matched now I want to search with another pattern".
Is possible to do it?
The gif animation is confusing to me because the shell appears to be extensively customized, so I can't tell what is percol and what is crazy zshell customization.
I'd have to agree with this - the auto-fu
plugin makes it a little unclear (as it's doing a lot of things as well) which parts of the GIF are actually from percol
. Would love to see an updated version that just uses a plain prompt.
I was trying to use percol in almost everything.
I had aliased my ls to '\ls -pF --color=always' and when I do ls | percol, the color formatting translates to their color codes in percol. Is there a way to mask that in percol? Or actually show those colors in percol?
For now I remove the --color=always flag from ls when piping the output to percol.
Another instance where I faced this was when I wanted to quickly grep for something in man. So I did "man tmux | percol" but percol is not useful there as it doesn't work with the formatting chars used in man.
Are you planning to add support for that?
Thanks.
Please allow ~/percol.d/
to be configurable through an environment variable, and even better - add support for XDG specification, i.e. ~/.config/percol.d/
Awesome tool. thanks!
Currently newline in the collection string is converted to "?". It would be nice if percol supports multiline collections.
Hello,
I found an interesting bug when using the --auto-match flag. I can reproduce it with 0.1.0 installed from pypi on linux and osx. I am using python 2.7.
First, the correct behavior, without --auto-match
:
$ echo -e "1\n2\n3\n4\n5" | percol
QUERY> (1/5) [1/1]
1
2
3
4
5
Next, the buggy behavior with --auto-match
, the 2nd list item is dropped:
$ echo -e "1\n2\n3\n4\n5" | percol --auto-match
QUERY> (1/4) [1/1]
1
3
4
5
Interesting, huh? 😸
If I check out the original commit where this feature was added, 00b5417, then I get the correct behavior. If I check out the commit where this feature was refactored, bd59b87, then I get the buggy behavior. So perhaps that refactoring is now doing something unsafe (consuming the 2nd element somehow).
Hi,
I would like to request the part which is left to awk in the examples as a percol feature. The way I imagine it is a "part of line" selector, which can be cycled (or selected with M-1, M-2 etc, or something like that) over configurable values like 'entire line', 'first word', 'second word', or custom regular expressions.
one use case would be ps faux | percol --partial '$2'
, which is not perfectly unix-y but feels natural to me. what's more important though is that I would like to be able to do ps faux | percol
without prior knowledge about how exactly the output looks, find out interactively that it's the second word, hit my 'next partial matcher' binding two times, select the line and proceed.
thanks for your work on percol so far!
Hi!
I'm looking at packaging this for Debian, and for that purpose it would be useful to have release numbers. Otherwise I'd just package it as 0~20140716 (for example).
Thanks
Since 0e98966 , the RET key doesn't do anything anymore.
Hello, mooz.
I'm using percol very conveniently and I thank you for providing
such a good program.
When I select a item including japanese characters, the item becomes
empty in some case.
For exmaple, If I execute following commands in a directory which has
two files, "hoge" and "ほげ", they output as below.
$ ls | percol # I select hoge by percol
hoge
$ ls | percol # I select ほげ by percol
ほげ
$ ls | percol | cat # I select hoge by percol
hoge
$ ls | percol | cat # I select ほげ by percol
(no output)
I predict that the fourth command output "ほげ" but do not.
Is it a wrong behavior?
kbkbkbkb1
Will it be supported by percol, or is it a job for some external wrapper?
Hi Mooz,
Thank you for providing this amazing tool! It is awesome! However, when I use it in the Cygwin it will show 'gbk' codec error sometimes (perhaps there is some Chinese Character). Is there anyway to solve it?
Thank you very much!
I am having a problem with Percol not sorting its results consistently. Under a certain condition, it reverses the input. I will try to illustrate:
function onlydirs {
while read dir
do
[[ -d $dir ]] && echo "$dir"
done
}
function p {
percol --prompt-bottom --result-bottom-up
}
locate -eiA /usr/src/linux-headers-3.1 ext3 | onlydirs | xargs -d '\n' ls -dt | p
When I run that, Percol displays:
/usr/src/linux-headers-3.13.0-45/fs/ext3
/usr/src/linux-headers-3.16.0-30/fs/ext3
See how 3.13
is listed first.
But if I run:
locate -eiA /usr/src/linux-headers-3.1 | onlydirs | xargs -d '\n' ls -dt | p
Then after typing ext3
into Percol, it displays:
/usr/src/linux-headers-3.16.0-30/fs/ext3
/usr/src/linux-headers-3.13.0-45/fs/ext3
See how the lines have been reversed.
I cannot figure out why this is happening. If I take the second example and pipe it through grep ext3
instead of Percol (which should have the same effect as typing ext3
into Percol after it comes up), the order is correct, with 3.13
being before 3.16
.
For some reason, Percol is reordering these lines depending on other, non-matching lines of input.
Thanks.
I'm using percol for command line history search.
I use the configuration discribed here.
https://github.com/mooz/percol#zsh-history-search
I enter Ctrl-C
to exit percol when there are no desired history command,
but in that case the typed command will be gone.
Any ideas?
While trying to use percol with a logfile containing utf characters I'm getting the following error:
jsegura@air:~/tmp % percol i.log [ 7:45AM]
Traceback (most recent call last):
File "/usr/local/bin/percol", line 31, in <module>
main()
File "/Library/Python/2.7/site-packages/percol/cli.py", line 238, in main
exit_code = percol.loop()
File "/Library/Python/2.7/site-packages/percol/__init__.py", line 180, in loop
self.view.refresh_display()
File "/Library/Python/2.7/site-packages/percol/view.py", line 67, in refresh_display
self.display_results()
File "/Library/Python/2.7/site-packages/percol/view.py", line 113, in display_results
is_marked = self.model.get_is_marked(cand_nth))
File "/Library/Python/2.7/site-packages/percol/view.py", line 88, in display_result
self.display_line(y, 0, line, style = line_style)
File "/Library/Python/2.7/site-packages/percol/view.py", line 74, in display_line
self.display.add_aligned_string(s, y_offset = y, x_offset = x, style = style, fill = True)
File "/Library/Python/2.7/site-packages/percol/display.py", line 256, in add_aligned_string
self.add_string(s, pos_y, pos_x, style)
File "/Library/Python/2.7/site-packages/percol/display.py", line 282, in add_string
self.addnstr(pos_y, pos_x, s, n if n >= 0 else self.WIDTH - pos_x, style)
File "/Library/Python/2.7/site-packages/percol/display.py", line 305, in addnstr
bytes_count_to_display = screen_length_to_bytes_count(s, n, self.encoding)
File "/Library/Python/2.7/site-packages/percol/display.py", line 104, in screen_length_to_bytes_count
char_bytes_count = len(unicode_char.encode(encoding))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 0: ordinal not in range(128)
File (character ·):
jsegura@air:~/tmp % cat i.log [ 8:30AM]
[2014/06/10 13:40:17 CEST] [INFO] (cluster.func·004:1028) Recovering local server
[2014/06/10 13:40:17 CEST] [INFO] (cluster.(*ClusterConfiguration).recover:1054) No shards to recover for 1
Thanks for providing this great tool.
I would like to customize the colors. I'm on Ubuntu 14.04 and I've installed percol using pip. I don't know what you mean by:
For now, styles of following 4 items can be customized in rc.py.
I've looked in the /usr/local/lib/python2.7/dist-packages/percol
directory and do not see a rc.py
file.
If you could add more details on how to customize the colors in the README.md
it would be great.
Thanks
I cannot upvote this enough. Thank you for the amazing tool!!
Has anyone started a repository of helpful bash aliases using percol? I've just made a few that are really useful for me.
Here is one for Docker that lets you choose which running docker image you would like to stop:
docker stop $(docker ps | percol | awk '{print $1;}')
Is it somehow possible to have search queries contain spaces, because whenever I have a space in a query, it seems to interpret it as two separate queries.
For example (in regex mode): [0-9]{2} USER
(i.e. a space, two numbers, a space and then the string USER
) should match
CHAPTER 26 USER: 180
CHAPTER 26 USER: 2
But also matches:
BOOK 6 USER: 787
BOOK 6 USER: 89
LOCATION 111 USER: 709
LOCATION 120 USER: 2
Is there anyway to tell Percol to interpret the spaces as part of the search query?
OS X 10.10.3 / zsh 5.0.8 (x86_64-apple-darwin14.3.0)
if i executed some commands like:
for i in $(cat list); do
echo $i;
done
and search through the history by Ctrl-r, the result would expand to:
for i in $(cat list); do\necho $i;\ndone
the '\n' breaks the command, any chance to fix this?
thanks.
Is there a standard way to select nothing in percol? I've been using ctrl+c
so far but it prints an error and doesn't clean up the screen.
fzf
has !pattern
matching, which excludes anything matching that pattern. It would be really great to have this in Percol. (It'd be great to have all of its pattern types, really. =)
Long query is truncated in percol. If (1) the query is shifted to left to make the caret visible or (2) break the line, it would be great. I think "break the line" is better because you can see all query you are typing.
Trying to use percol
from fish
as output to other commands doesn't work.
ls | percol
works as expected.
cd (ls | percol)
(not a typo, fish
uses (...)
instead of bash
/zsh
's $(...)
) closes without doing anything.
Here is what looks like using percol:
ls -1 | percol
X / _ / X (1/5) [1/1]
?[0m?[01;34manalysis.git?[0m
?[01;34mLinkageAnalysis.git?[0m
?[01;34mmutagenetix.git?[0m
?[01;34mmutagenetix.scripts.git?[0m
?[m
Can percol strip out these escaped color codes or render them correctly?
My editor add encoding lines at the top off my .py
files and it make percol don't read it's. The problem can be solved by replacing some lines in load_rc function, please change this:
with open(path, 'r') as rc:
exec(rc.read().decode(encoding), locals())
for it:
execfile(path, locals())
and my problem will be fixed.
When the bash history is piped to percol with the command:
bind -x '"\C-R": READLINE_LINE=$(history | tac | cut -c 8- | percol --query "${READLINE_LINE}") READLINE_POINT='
percol searches only in the first "SOME_NUMBER" of lines (1000?). Is this number configurable somewhere?
Thanks.
➜ ps aux | percol
Traceback (most recent call last):
File "/usr/local/bin/percol", line 31, in <module>
main()
File "/usr/local/lib/python2.7/site-packages/percol/cli.py", line 284, in main
exit_code = percol.loop()
File "/usr/local/lib/python2.7/site-packages/percol/__init__.py", line 180, in loop
self.handle_key(self.screen.getch())
File "/usr/local/lib/python2.7/site-packages/percol/__init__.py", line 248, in handle_key
self.last_key = self.handle_normal_key(ch)
File "/usr/local/lib/python2.7/site-packages/percol/__init__.py", line 264, in handle_normal_key
self.keymap[k](self)
File "~/.percol.d/rc.py", line 7, in <lambda>
"C-y" : lambda percol: percol.command.yank(),
File "/usr/local/lib/python2.7/site-packages/percol/command.py", line 219, in yank
if self.model.killed:
AttributeError: 'SelectorModel' object has no attribute 'killed'
When I rebind C-j, the binding for RET is also changed. When I bind RET, neither binding is changed.
REPRODUCE CASE 1:
Put this in ~/.percol.d/rc.py
:
percol.import_keymap({
"C-j" : lambda percol: percol.command.select_next(),
})
While using percol, press RET
Expected result: selected entry is printed to stdout (default RET binding)
Actual result: the next entry becomes selected
REPRODUCE CASE 2:
Put this in ~/.percol.d/rc.py
:
percol.import_keymap({
"RET" : lambda percol: percol.command.select_next(),
})
While using percol, press RET
Expected result: the next entry becomes selected
Actual result: selected entry is printed to stdout (default C-j binding)
Hi, Is it possible to display multiple lines if the matching line is too long?
I had a long command which will be multiple lines in the terminal:
A LONG LONG LONG...Line A
A LONG LONG LONG...Line B
When I search by Long (say, ctrl^R for the command), currently it is only displaying partial of the command (not in multiple lines), so I can not tell the difference of both lines.
Thanks!
Let me elaborate.
I wrote an alias in tcsh to cd to any of the subdirectories directly.
alias pcd 'set search_pattern="*\!***"; \\
find . -type d -name "$search_pattern" | percol | \\
xclip -i; cd xclip -o'
Let say I have directories:
abcd/pqr1/ and
abcd/pqr2/
If I do "pcd pqr (return)", it shows the above 2 directories, I select one, hit Enter and I end up in that directory. I love that! :)
But if I do "pcd pqr2 (return)", it shows the only "abcd/pqr2" directory. That correct; the filtered result has just one option. Then I hit Enter and end up in that directory.
My request: Does or can percol have a feature in the future where it automatically selects the option if and only if 1 option is available? With that feature, I can do "pcd pqr2 (return)" and boom!, I will be in abcd/pqr2; I skip the step where I am in percol and have to hit another Enter.
This feature will be useful for many other aliases of mine.
Thanks!
Hi, I really enjoy using your terminal tool.
Trying to install percol
on python 3 fails:
$ python --version
Python 3.3.2
$ pip install percol
Downloading/unpacking percol
You are installing an externally hosted file. Future versions of pip will default to disallowing externally hosted files.
You are installing a potentially insecure and unverifiable file. Future versions of pip will default to disallowing insecure files.
Downloading master
Running setup.py egg_info for package percol
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/private/var/folders/yp/n_vh185d1z39k_xmp5wwwm1m0000gn/T/pip_build_azu/percol/setup.py", line 5, in <module>
import percol
File "./percol/__init__.py", line 40, in <module>
import debug, action
ImportError: No module named 'debug'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/private/var/folders/yp/n_vh185d1z39k_xmp5wwwm1m0000gn/T/pip_build_azu/percol/setup.py", line 5, in <module>
import percol
File "./percol/__init__.py", line 40, in <module>
import debug, action
ImportError: No module named 'debug'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /private/var/folders/yp/n_vh185d1z39k_xmp5wwwm1m0000gn/T/pip_build_azu/percol
Storing complete log in /Users/azu/.pip/pip.log
Hi,
I tried the following:
python setup.py install --prefix=~/usr_local
$ export PATH=~/usr_local/bin:$PATH
After doing that I am able to execute percol
from anywhere but it fails with this error:
"ImportError: No module named percol.cli"
How do I fix it?
Using percol on a file with multi-line records, I'd like to search to find candidate records, up/down to choose, (?) to pick a line near that.
One suggestion would be un-narrowing (clearing the search query text) and scrolling down to the same line. It can probably be that simple at first, but later the right thing is probably to have bs restore the query, or something like that.
It marked support python3, but apperently is not:
$ percol
Traceback (most recent call last):
File "/bin/percol", line 31, in <module>
main()
File "/usr/lib/python3.4/site-packages/percol/cli.py", line 225, in main
tty_f.write(INSTRUCTION_TEXT)
TypeError: 'str' does not support the buffer interface
Is it somewere I wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.