1
0
Fork 0

Set a sane default for the pager.

This commit is contained in:
Amjith Ramanujam 2014-12-19 23:12:43 -08:00
parent c47c647e7d
commit d136180ff4
2 changed files with 15 additions and 2 deletions

1
TODO
View File

@ -1,6 +1,7 @@
# vi: ft=vimwiki
* [ ] Fix: SELECT id, <tab> FROM django_migrations; - Auto-completion for the second column name is broken. Find the last keyword and use it for completion.
* [ ] Bottom status bar is cut-off in half pane. Figure out how to fix that.
* [ ] Fix: Autocompletion won't go away after semi-colons. This an artifact of stripping special chars in the partially typed words. Need to selectively remove parens.
* [ ] Default host should not be set to localhost. Since it causes problems in IPv6 machines. Need to research this one further.
* [ ] Column completion for nested sql.
* [ ] Add JOIN to the list of keywords and provide proper autocompletion for it.

View File

@ -2,7 +2,7 @@
from __future__ import unicode_literals
from __future__ import print_function
import os.path
import os
import click
@ -26,7 +26,7 @@ from .config import write_default_config, load_config
from .key_bindings import pgcli_bindings
@click.command()
@click.option('-h', '--host', default='localhost', help='Host address of the '
@click.option('-h', '--host', default='', help='Host address of the '
'postgres database.')
@click.option('-p', '--port', default=5432, help='Port number at which the '
'postgres instance is listening.')
@ -48,6 +48,15 @@ def cli(database, user, password, host, port):
config = load_config('~/.pgclirc')
smart_completion = config.getboolean('main', 'smart_completion')
less_opts = os.environ.get('LESS', '')
if not less_opts:
os.environ['LESS'] = '-RXF'
if 'X' not in less_opts:
os.environ['LESS'] += 'X'
if 'F' not in less_opts:
os.environ['LESS'] += 'F'
# Connect to the database.
try:
pgexecute = PGExecute(database, user, password, host, port)
@ -107,6 +116,9 @@ def cli(database, user, password, host, port):
pgexecute.columns(table))
except Exit:
print ('GoodBye!')
finally: # Reset the less opts back to normal.
if less_opts:
os.environ['LESS'] = less_opts
def need_completion_refresh(sql):
try: