227 points · by amjith · 11y ago · 52 comments
There is an FAQ page: http://pgcli.com/faq
I'll be happy to answer questions here as well.
My setup is a bit of a one-off. I'm running it inside ConEmu, with the environment initialized from a batch script. That way, my whole setup is portable. Postgres is fired up with a tab in ConEmu (cleaned up once ConEmu closes by the waiting script that spawned it). None of it has admin, but seems to allow me to bootstrap any tool I'd like to use. I also have MinGW and the GNU tools that were compiled for Windows. So from now on, I'll have pgcli fire up instead of just psql when that ConEmu tab opens.
I have to say it's a pleasure to see it Just Work. I haven't done anything clever yet, just some basic fiddlin'. But it's really quite nice to have a pretty CLI tool for PG in Windows!
EDIT: whoops, wrong tool name.
The source code is available on GH: https://github.com/amjith/pgcli
OP: why no "Fork Me" banner? ;)
The link to the GH repo is on the home page. I figured that makes it obvious, but perhaps not?
Again, this is truly awesome work. Can you comment on what inspired you to create pgcli?
From [1]:
> Homebrew generally won't accept libraries that can be installed correctly with `pip install foo`.
[1]: https://github.com/Homebrew/homebrew/blob/master/share/doc/h...
[0]: https://github.com/Homebrew/homebrew/blob/master/Library/For...
> Homebrew is happy to accept applications that are built in Python, whether the apps are available from PyPI or not.
[0]: https://github.com/Homebrew/homebrew/blob/master/Library/For...
[0]: https://github.com/Homebrew/homebrew/blob/master/Library/For...
[0]: https://github.com/Homebrew/homebrew/blob/master/Library/For...
[0]: https://github.com/Homebrew/homebrew/blob/master/Library/For...
[0]: https://github.com/Homebrew/homebrew/blob/master/Library/For...
[0]: https://github.com/Homebrew/homebrew/blob/master/Library/For...
[0]: https://github.com/Homebrew/homebrew/blob/master/Library/For...
[0]: https://github.com/Homebrew/homebrew/blob/master/Library/For...
As a reminder/heads up, you can often get simple command line editing and completion in tools like psql in a bash-like environment, just by having a .inputrc file in your home directory. Basically anything that uses readline, like bash, psql, ipython, etc.
Extra benefit, you don't need to set -o vi (or the other flavor) in your .bashrc or on the command line; anything that uses readline (including bash and many other cli interfaces) will read the .inputrc file and do what it says. I'm often pleasantly surprised that a new cli tool uses my .inputrc.
http://linux.die.net/man/3/readline
https://www.gnu.org/software/bash/manual/bashref.html#Comman...
You can easily add the capability to command line tools that you write. For example:
I'm genuinely confused by this. Why do you need to .inputrc file? Doesn't readline default to EMACS style command shortcuts? And isn't TAB the EMACS (and near universal) key for auto-complete?
If you want vi command line edit keybindings, then you do.
Or if you like emacs but you want to customize, then you need a .inputrc.
Also, is it possible to tweak the autocompletion so that hitting Enter selects the first offered completion? Right now, you have to hit tab or use the arrow keys to select.
A Homebrew formula would be great.
Hitting enter to select the first completion is much harder. I can't promise I'll be able to do this one.
A homebrew formula would be fantastic. I tried making it last night but I ran into issues with psycopg2 dependency. So if you have any experience with building brew formulae, I'd appreciate some help.
For now it serve me well.
I don't have a working setup of emacs to try it right away. If you can try it out and find that it's not working, please file an issue.
If someone tries to install this on ubuntu with just the quick start instructions and fails, note that you need to
sudo apt-get install libpq-dev
Obviously, this is told in the more detailed install instructions.
I'll go ahead and ask, since I'm probably not the only one thinking it: will there be a MySQL version? ;)
EDIT: oh, and I guess the name wouldn't be very fitting for a MySQL cli...
Probably. Now that I've worked out the hard parts (sqlcompletion and special commands), I'd like to write a CLI for Sqlite and MySql. But I'm not sure if I'll have the time to do it in the immediate future. But if you're interested in doing it, I'd be happy to help you. Please get in touch.
Would you mind adding a bit of description to the issue, perhaps an example sql statement?
Considering I'm new to Postgres (been on MySQL for too many years), this is definitely making my life easier because of the autocomplete :)
But a question for you: how does this help someone who's a power user of Postgres?
That is the most popular feature request so far. https://github.com/amjith/pgcli/issues/19
It's not quite the same as pgcli but I took some inspiration from that for auto-completion.