pindexis / qfc Goto Github PK
View Code? Open in Web Editor NEWQuick Command-line File Completion
License: MIT License
Quick Command-line File Completion
License: MIT License
qfc shows up to 10, default in UI.py, entries, if there are more entries, no feedback is provided to the user.
See this video:
My current environment
I followed the installation instructions without any changes.
I've followed the instructions but somehow read
in get_cursor_position
does fail on my mac. If I hit <ctrl>-f
on a fresh console my termial is stuck with the following message:
-bash: read: read error: 0: Input/output error
But if I call get_current_position
directly everything seems to work:
$ get_cursor_position
1 0
I've added some set -x
marks to the code in bin/qfc.sh
and here is some output that might help you:
$ get_cursor_position
+ exec
++ stty -g
+ oldstty=gfmt1:cflag=4b00:iflag=6b02:lflag=200005cf:oflag=3:discard=f:dsusp=19:eof=4:eol=ff:eol2=ff:erase=7f:intr=3:kill=15:lnext=16:min=1:quit=1c:reprint=12:start=11:status=14:stop=13:susp=1a:time=0:werase=ff:ispeed=38400:ospeed=38400
+ stty raw -echo min 0
+ echo -en '\033[6n'
+ IFS=';'
+ read -r -d R row col
+ stty gfmt1:cflag=4b00:iflag=6b02:lflag=200005cf:oflag=3:discard=f:dsusp=19:eof=4:eol=ff:eol2=ff:erase=7f:intr=3:kill=15:lnext=16:min=1:quit=1c:reprint=12:start=11:status=14:stop=13:susp=1a:time=0:werase=ff:ispeed=38400:ospeed=38400
+ row=7
+ col=20
+ echo '7 20'
7 20
get_current_position
survived, but qfc_complete
will get stuck:
$ qfc_complete
++ offset=0
++ READLINE_POINT=0
+++ cut -f 2 -d ' '
++++ get_cursor_position
++++ exec
+++++ stty -g
++++ oldstty=gfmt1:cflag=4b00:iflag=6a02:lflag=4c7:oflag=3:discard=f:dsusp=ff:eof=4:eol=ff:eol2=ff:erase=7f:intr=3:kill=15:lnext=ff:min=1:quit=1c:reprint=12:start=11:status=14:stop=13:susp=1a:time=0:werase=ff:ispeed=38400:ospeed=38400
++++ stty raw -echo min 0
++++ echo -en '\033[6n'
++++ IFS=';'
++++ read -r -d R row col
-bash: read: read error: 0: Input/output error
++++ stty gfmt1:cflag=4b00:iflag=6a02:lflag=4c7:oflag=3:discard=f:dsusp=ff:eof=4:eol=ff:eol2=ff:erase=7f:intr=3:kill=15:lnext=ff:min=1:quit=1c:reprint=12:start=11:status=14:stop=13:susp=1a:time=0:werase=ff:ispeed=38400:ospeed=38400
And here some facts about my system:
$ bash --version
GNU bash, version 4.4.0(1)-release (x86_64-apple-darwin16.0.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ python --version
Python 2.7.12
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.1
BuildVersion: 16B2555
The default keybindings are unfriendly to emacs users. How to change it?
It seems that attempting to complete a path that includes spaces will not work. Would it be possible to have qfc, prior to finishing the auto-complete, wrap the path in double-quotes whenever the path includes a space?
the list displayed is the list of directory under the root, if I go into proc/ and then out, I find myself not in the root but in cwd
this is not specific to /proc, if one backs long enough, one finds oneself in cwd
Searching using ctrl-F works perfectly, but pressing Enter/Return returns to the command line without appending the path to the command line. My environment is OS X 10.10 + iTerm2 + bash(3.2.57).
mksh, ksh93 and pdksh are classic POSIX shells and widely used, probably more widely than the zsh. Please add support for ksh flavors.
Hi @pindexis and thank you for the work you have put into this great, little tool. :) ✋
It’d be great to be able to install qfc
via something like Homebrew, etc.
I’ve noticed that work on this has been kind of slow the last 1,5 years but thought it can’t hurt to open this for myself and others. Maybe somebody will pick it up (myself included).
Thanks and cheers. 🍺
Is there any chance that this script could also support searching for dotfiles?
the maximum length of the list is 10 by default and it can only be be modified in UI.py
make it user configurable in the shell scrip or, in the worst case with an environment variable
Many folders in my home directory are symlinked. At the moment, qfc doesn't show symlinked folders in its list.
I may have a look at adding this if I find some time (along with #29 since I'm also interested in that).
the path selection list is done on the current line, hiding the command, but when the command line is the last line of the terminal, the output shifts up the terminal content and writes the path selection list under the command
Unless you search from the root directory of the git repo, it only searches 3 levels down instead of searching against all tracked files.
Please add an environment variable for configuring the path where qfc is installed, defaults at ~/.qfc
.
Awesome utility! thanks.
I have installed qfc using the method described here , when i tried to run qfc it's throwing a error
Traceback (most recent call last):
File "/home/user/.qfc/bin/qfc", line 34, in
parse_arguments()
File "/home/user/.qfc/bin/qfc", line 17, in parse_arguments
return args.func(args)
File "/home/user/.qfc/bin/qfc", line 20, in cmd_get
output = core.get_selected_command_or_input(args.search)
File "/home/user/.qfc/bin/../qfc/core.py", line 11, in get_selected_command_or_input
state = State(search)
File "/home/user/.qfc/bin/../qfc/core.py", line 62, in init
self.set_input(default_input)
File "/home/user/.qfc/bin/../qfc/core.py", line 72, in set_input
self._update()
File "/home/user/.qfc/bin/../qfc/core.py", line 105, in _update
self.matches = get_matches(os.getcwd(),self.input)
File "/home/user/.qfc/bin/../qfc/core.py", line 128, in get_matches
source_files = dirhandler.get_source_files(start_dir)
File "/home/user/.qfc/bin/../qfc/dirhandler.py", line 104, in get_source_files
return default.get_source_files(directory)
File "/home/user/.qfc/bin/../qfc/dirhandler.py", line 82, in get_source_files
self._cache[start_dir] = self._walk_down(start_dir)
File "/home/user/.qfc/bin/../qfc/dirhandler.py", line 77, in _walk_down
files = out.split('\n')
TypeError: 'str' does not support the buffer interface
python version : 3.4.3
bash version : 4.3.39
Traceback (most recent call last):
File "/home/emiliano/.qfc/bin/qfc", line 33, in
parse_arguments()
File "/home/emiliano/.qfc/bin/qfc", line 16, in parse_arguments
return args.func(args)
File "/home/emiliano/.qfc/bin/qfc", line 19, in cmd_get
output = core.get_selected_command_or_input(args.search)
File "/home/emiliano/.qfc/bin/../qfc/core.py", line 12, in get_selected_command_or_input
ui.refresh(state)
File "/home/emiliano/.qfc/bin/../qfc/ui.py", line 20, in refresh
lines, num_rows = _construct_output(state)
File "/home/emiliano/.qfc/bin/../qfc/ui.py", line 45, in _construct_output
fm = ' '+str(m)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 2: ordinal not in range(128)
Traceback (most recent call last):
File "/home/emiliano/.qfc/bin/qfc", line 33, in
parse_arguments()
File "/home/emiliano/.qfc/bin/qfc", line 16, in parse_arguments
return args.func(args)
File "/home/emiliano/.qfc/bin/qfc", line 19, in cmd_get
output = core.get_selected_command_or_input(args.search)
File "/home/emiliano/.qfc/bin/../qfc/core.py", line 12, in get_selected_command_or_input
ui.refresh(state)
File "/home/emiliano/.qfc/bin/../qfc/ui.py", line 20, in refresh
lines, num_rows = _construct_output(state)
File "/home/emiliano/.qfc/bin/../qfc/ui.py", line 45, in _construct_output
fm = ' '+str(m)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 2: ordinal not in range(128)
Version Python 2.7.6 (default, Jun 22 2015, 17:58:13)
Test in Guake and bash 2.1 at elementary freya
While the Python binaries are in most cases available as "python2" or "python3", OSX and BSD systems (and probably some Linuxes too) don't link "python2" or "python3" to "python" automatically. You might consider to consider that.
Another advantage of that would be that you could stop supporting the deprecated Python2 line. :-)
When I ran qfc
at a directory where the file structure is as following, I had no result.
[hiroshi ~/test-qfc]% tree
.
└── A
└── B
└── C
└── empty.file
3 directories, 1 file
[hiroshi ~/test-qfc]% qfc
Path:
Nothing found
Is this behavior as expected? It seems if a directory does not have a regular file in its child or grand child directories, the directory itself is not listed up.
Some environment require a rather deep directory structure and I am wondering it could be a pain. For example, in Go, source code is typically located under ~/go/src/<vc repository>/<organization>/<repository name>/
and I have to move to, say, ~/go/src/github.com
to list source files with qfc
command.
Thanks in advance for your support.
BASH_VERSION
is 4.3.33(1)-release. Pressing ^F just inserts ^F
. Running set -o emacs
causes qfc to work as expected.
On my system (Arch Linux), python
is python3
. Running qfc throws an exception:
Traceback (most recent call last):
File "/home/jmhite/.qfc/bin/qfc", line 34, in <module>
parse_arguments()
File "/home/jmhite/.qfc/bin/qfc", line 17, in parse_arguments
return args.func(args)
File "/home/jmhite/.qfc/bin/qfc", line 20, in cmd_get
output = core.get_selected_command_or_input(args.search)
File "/home/jmhite/.qfc/bin/../qfc/core.py", line 13, in get_selected_command_or_input
ui.refresh(state)
File "/home/jmhite/.qfc/bin/../qfc/ui.py", line 19, in refresh
erase()
File "/home/jmhite/.qfc/bin/../qfc/ui.py", line 14, in erase
ansi.move_cursor_line_beggining()
Attribute Error: 'module' object has no attribute 'move_cursor_line_beggining'
This actually looks to be an issue with the Py3k version of the ansi having changed the API. In any event, changing the shebang line in qfc
to #!/usr/bin/env python2
fixes it.
Hello,
I just installed qfc and added it to my zsh 5.0.5 .zshrc
like that:
[[ -s "$HOME/.qfc/bin/qfc.sh" ]] && source "$HOME/.qfc/bin/qfc.sh"
qfc_quick_command 'cd' '\C-b' 'cd $0'
qfc_quick_command 'vim' '\C-p' 'vim $0'
and restarted my terminal / sourced the config file.
If I press ctrl + f the result looks like this:
~|⇒
qfc_complete:15: command not found: qfc
Is there anything I missed?
Thanks
Using iTerm2 on OS X I get this error when pressing "Enter" on a highlighted result: expr: syntax error
.
this would help the user see the type of certain files
...At least, that's my best guess of the problem.
I have a directory structure like so:
"github" is the folder where I store my repositories. qfc can search within repo1 just fine. However, it cannot search within subfolder1 (so not within repo2 either) or subfolder2, saying "Nothing found". I've tried searching within other folders on my computer with a similar structure, but the problem seems to be something related to regular folders within or containing git repositories.
Path: Projects/iwinkit/
.docker/
_commons/
_externals/
_hooks/
_templates/
_test/
app/
apps/
assets/
src/
in this screen if I click Ctrl-b nothing happens
if I quit with another Ctrl-f click and then click Ctrl-b I get this
[dmitry@DMITRY ~]$ Projects/iwinkit/"
bash: bash_execute_unix_command: cannot find keymap for command
[dmitry@DMITRY ~]$ Projects/iwinkit/"
my .bashrc
# .bashrc
[[ -s "$HOME/.qfc/bin/qfc.sh" ]] && source "$HOME/.qfc/bin/qfc.sh"
qfc_quick_command 'cd' '\C-b' 'cd $0'
qfc_quick_command 'joe' '\C-p' 'joe $0'
any ideas?
[dmitry@DMITRY ~]$ bash --version
GNU bash, version 4.3.0(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[dmitry@DMITRY ~]$ python --version
Python 2.7.5
[dmitry@DMITRY ~]$ uname -a
Linux DMITRY.LINUX 3.10.0-229.14.1.el7.x86_64 #1 SMP Tue Sep 15 15:05:51 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[dmitry@DMITRY ~]$
if a file name has spaces in it it does not insert \ or quotes around that filename
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.