forked from dotphiles/dotphiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
146 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.2.3 | ||
0.2.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
psql | ||
=== | ||
|
||
Adds config for psql | ||
|
||
To use, add the following to **dotsyncrc** | ||
|
||
[files] | ||
.. | ||
postgresql/psqlrc | ||
.. | ||
[endfiles] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
-- | ||
-- dotphiles : https://github.com/dotphiles/dotphiles | ||
-- | ||
-- Setup psql | ||
-- | ||
-- Authors: | ||
-- Ben O'Hara <[email protected]> | ||
-- | ||
|
||
\set QUIET ON | ||
|
||
\set PROMPT1 '(%n@%M:%>) [%/] > ' | ||
\set PROMPT2 '' | ||
\set PAGER OFF | ||
\set HISTFILE ~/.history/psql- :HOST - : DBNAME -- Remove space between : and DBNAME | ||
\set HISTSIZE 2000 | ||
\set ECHO_HIDDEN ON | ||
\set COMP_KEYWORD_CASE upper | ||
|
||
\timing | ||
\encoding unicode | ||
|
||
\pset null 'NULL' | ||
\pset border 2 | ||
|
||
\set QUIET OFF | ||
|
||
\echo '\nCurrent Host Server Date Time : '`date` '\n' | ||
|
||
\echo 'Administrative queries:\n' | ||
\echo '\t\t\t:settings\t-- Server Settings' | ||
\echo '\t\t\t:conninfo\t-- Server connections' | ||
\echo '\t\t\t:activity\t-- Server activity' | ||
\echo '\t\t\t:locks\t\t-- Lock info' | ||
\echo '\t\t\t:waits\t\t-- Waiting queires' | ||
\echo '\t\t\t:dbsize\t\t-- Database Size' | ||
\echo '\t\t\t:tablesize\t-- Tables Size' | ||
\echo '\t\t\t:uselesscol\t-- Useless columns' | ||
\echo '\t\t\t:uptime\t\t-- Server uptime' | ||
\echo '\t\t\t:menu\t\t-- Help Menu' | ||
\echo '\t\t\t\\h\t\t-- Help with SQL commands' | ||
\echo '\t\t\t\\?\t\t-- Help with psql commands\n' | ||
|
||
\echo 'Development queries:\n' | ||
\echo '\t\t\t:sp\t\t-- Current Search Path' | ||
\echo '\t\t\t:clear\t\t-- Clear screen' | ||
\echo '\t\t\t:ll\t\t-- List\n' | ||
|
||
-- Administration queries | ||
|
||
\set menu '\\i ~/.psqlrc' | ||
|
||
\set settings 'select name, setting,unit,context from pg_settings;' | ||
|
||
\set locks 'SELECT bl.pid AS blocked_pid, a.usename AS blocked_user, kl.pid AS blocking_pid, ka.usename AS blocking_user, a.query AS blocked_statement FROM pg_catalog.pg_locks bl JOIN pg_catalog.pg_stat_activity a ON bl.pid = a.pid JOIN pg_catalog.pg_locks kl JOIN pg_catalog.pg_stat_activity ka ON kl.pid = ka.pid ON bl.transactionid = kl.transactionid AND bl.pid != kl.pid WHERE NOT bl.granted;' | ||
|
||
\set conninfo 'select usename, count(*) from pg_stat_activity group by usename;' | ||
|
||
\set activity 'select datname, pid, usename, application_name,client_addr, client_hostname, client_port, query, state from pg_stat_activity;' | ||
|
||
\set waits 'SELECT pg_stat_activity.pid, pg_stat_activity.query, pg_stat_activity.waiting, now() - pg_stat_activity.query_start AS \"totaltime\", pg_stat_activity.backend_start FROM pg_stat_activity WHERE pg_stat_activity.query !~ \'%IDLE%\'::text AND pg_stat_activity.waiting = true;' | ||
|
||
\set dbsize 'SELECT datname, pg_size_pretty(pg_database_size(datname)) db_size FROM pg_database ORDER BY db_size;' | ||
|
||
\set tablesize 'SELECT nspname || \'.\' || relname AS \"relation\", pg_size_pretty(pg_relation_size(C.oid)) AS "size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN (\'pg_catalog\', \'information_schema\') ORDER BY pg_relation_size(C.oid) DESC LIMIT 40;' | ||
|
||
\set uselesscol 'SELECT nspname, relname, attname, typname, (stanullfrac*100)::int AS null_percent, case when stadistinct >= 0 then stadistinct else abs(stadistinct)*reltuples end AS \"distinct\", case 1 when stakind1 then stavalues1 when stakind2 then stavalues2 end AS \"values\" FROM pg_class c JOIN pg_namespace ns ON (ns.oid=relnamespace) JOIN pg_attribute ON (c.oid=attrelid) JOIN pg_type t ON (t.oid=atttypid) JOIN pg_statistic ON (c.oid=starelid AND staattnum=attnum) WHERE nspname NOT LIKE E\'pg\\\\_%\' AND nspname != \'information_schema\' AND relkind=\'r\' AND NOT attisdropped AND attstattarget != 0 AND reltuples >= 100 AND stadistinct BETWEEN 0 AND 1 ORDER BY nspname, relname, attname;' | ||
|
||
\set uptime 'select now() - pg_postmaster_start_time() AS uptime;' | ||
|
||
-- Development queries: | ||
|
||
\set sp 'SHOW search_path;' | ||
\set clear '\\! clear;' | ||
\set ll '\\! ls -lrt;' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,43 @@ | |
# Ben O'Hara <[email protected]> | ||
# | ||
|
||
# Imports we need | ||
import sys | ||
import os | ||
import readline, rlcompleter | ||
import atexit | ||
import pprint | ||
from tempfile import mkstemp | ||
from code import InteractiveConsole | ||
|
||
# Imports we want | ||
import datetime | ||
import pdb | ||
try: | ||
import readline | ||
import rlcompleter | ||
import atexit | ||
except ImportError: | ||
print("You need readline, rlcompleter, and atexit") | ||
|
||
|
||
# Make this work properly in Darwin and Linux | ||
if 'libedit' in readline.__doc__: | ||
readline.parse_and_bind("bind ^I rl_complete") | ||
else: | ||
readline.parse_and_bind("tab: complete") | ||
|
||
class Completer(object): | ||
def __init__(self): | ||
# Enable a History | ||
self.HISTFILE=os.path.expanduser("%s/.history/python" % os.environ["HOME"]) | ||
|
||
AUTHOR = 'Seth House <[email protected]>' | ||
# Read the existing history if there is one | ||
if os.path.exists(self.HISTFILE): | ||
readline.read_history_file(self.HISTFILE) | ||
|
||
# Set maximum number of items that will be written to the history file | ||
readline.set_history_length(300) | ||
atexit.register(self.savehist) | ||
|
||
def savehist(self): | ||
import readline | ||
readline.write_history_file(self.HISTFILE) | ||
|
||
|
||
c = Completer() | ||
|
||
WELCOME='' | ||
# Color Support | ||
class TermColors(dict): | ||
"""Gives easy access to ANSI color codes. Attempts to fall back to no color | ||
|
@@ -37,8 +59,7 @@ class TermColors(dict): | |
("Purple" , "0;35"), | ||
("Cyan" , "0;36"), | ||
("LightGray" , "0;37"), | ||
("DarkGray" , "1;30"), | ||
("LightRed" , "1;31"), | ||
("DarkGray" , "1;30"), ("LightRed" , "1;31"), | ||
("LightGreen" , "1;32"), | ||
("Yellow" , "1;33"), | ||
("LightBlue" , "1;34"), | ||
|
@@ -59,27 +80,12 @@ class TermColors(dict): | |
self.update(dict([(k, self.NoColor) for k,v in self.COLOR_TEMPLATES])) | ||
_c = TermColors() | ||
|
||
# Enable a History | ||
HISTFILE="%s/.history/python" % os.environ["HOME"] | ||
HISTDIR = os.path.dirname(HISTFILE) | ||
if not os.path.exists(HISTDIR): | ||
os.makedirs(HISTDIR) | ||
|
||
# Read the existing history if there is one | ||
if os.path.exists(HISTFILE): | ||
readline.read_history_file(HISTFILE) | ||
|
||
# Set maximum number of items that will be written to the history file | ||
readline.set_history_length(300) | ||
|
||
def savehist(): | ||
readline.write_history_file(HISTFILE) | ||
|
||
atexit.register(savehist) | ||
|
||
import sys | ||
# Enable Color Prompts | ||
sys.ps1 = "%s>>> %s" % (_c['Green'], _c['Normal']) | ||
sys.ps2 = "%s... %s" % (_c['Red'], _c['Normal']) | ||
sys.ps1 = '%s>>> %s' % (_c['Green'], _c['Normal']) | ||
sys.ps2 = '%s... %s' % (_c['Red'], _c['Normal']) | ||
|
||
# Enable Pretty Printing for stdout | ||
def my_displayhook(value): | ||
|
@@ -90,22 +96,11 @@ def my_displayhook(value): | |
except ImportError: | ||
__builtins__._ = value | ||
|
||
import pprint | ||
pprint.pprint(value) | ||
sys.displayhook = my_displayhook | ||
del pprint | ||
|
||
# Welcome message | ||
WELCOME = """\ | ||
%(Cyan)s | ||
You've got color, history, and pretty printing. | ||
(If your ~/.inputrc doesn't suck, you've also | ||
got completion and vi-mode keybindings.) | ||
%(Brown)s | ||
Type \e to get an external editor. | ||
%(Normal)s""" % _c | ||
|
||
atexit.register(lambda: sys.stdout.write("""%(DarkGray)s | ||
Sheesh, I thought he'd never leave. Who invited that guy? | ||
%(Normal)s""" % _c)) | ||
sys.displayhook = my_displayhook | ||
|
||
# Django Helpers | ||
def SECRET_KEY(): | ||
|
@@ -133,7 +128,7 @@ if 'DJANGO_SETTINGS_MODULE' in os.environ: | |
C = Client() | ||
|
||
WELCOME += """%(Green)s | ||
Django environment detected. | ||
Django environment detected. | ||
* Your INSTALLED_APPS models are available as `A`. | ||
* Your project settings are available as `S`. | ||
* The Django test client is available as `C`. | ||
|
@@ -150,16 +145,21 @@ Warning: DEBUG_PROPAGATE_EXCEPTIONS has been set to True. | |
%(Normal)s""" % _c | ||
|
||
# Start an external editor with \e | ||
EDITOR = os.environ.get('EDITOR', 'vi') | ||
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438813/ | ||
|
||
EDITOR = os.environ.get('EDITOR', 'vim') | ||
EDIT_CMD = '\e' | ||
|
||
from tempfile import mkstemp | ||
from code import InteractiveConsole | ||
|
||
class EditableBufferInteractiveConsole(InteractiveConsole): | ||
def __init__(self, *args, **kwargs): | ||
self.last_buffer = [] # This holds the last executed statement | ||
InteractiveConsole.__init__(self, *args, **kwargs) | ||
|
||
def runsource(self, source, *args): | ||
self.last_buffer = [ source.encode('utf-8') ] | ||
self.last_buffer = [ source.encode('latin-1') ] | ||
return InteractiveConsole.runsource(self, source, *args) | ||
|
||
def raw_input(self, *args): | ||
|
@@ -177,9 +177,12 @@ class EditableBufferInteractiveConsole(InteractiveConsole): | |
line = lines[-1] | ||
return line | ||
|
||
# clean up namespace | ||
del sys | ||
|
||
c = EditableBufferInteractiveConsole(locals=locals()) | ||
c.interact(banner=WELCOME) | ||
|
||
# Exit the Python shell on exiting the InteractiveConsole | ||
import sys | ||
sys.exit() | ||
|
Submodule dotzsh
updated
10 files
+1 −1 | .dotzsh | |
+10 −5 | helper.zsh | |
+7 −1 | modules/gnupg/init.zsh | |
+15 −3 | modules/notify/README.md | |
+45 −17 | modules/notify/init.zsh | |
+3 −3 | modules/python/init.zsh | |
+4 −0 | modules/taskwarrior/init.zsh | |
+3 −0 | modules/tmux/init.zsh | |
+2 −2 | themes/dotphiles/init.zsh | |
+106 −99 | themes/dotphiles/prompt/prompt_dotphiles_setup |