Skip to content

Commit

Permalink
some new CLI tools to replace more basic ones
Browse files Browse the repository at this point in the history
  • Loading branch information
marten committed Oct 1, 2018
1 parent 46ca1ee commit a2782b1
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ config/fish/fish_history
config/fish/fishd.*
config/xbuild
config/configstore/update-notifier-npm.json
config/configstore/update-notifier-npm.json*
config/configstore/update-notifier-npm.json*
config/pgcli/history
config/pgcli/log
config/StardewValley
3 changes: 3 additions & 0 deletions config/fish/functions/fish_user_key_bindings.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function fish_user_key_bindings
fzf_key_bindings
end
1 change: 1 addition & 0 deletions config/fish/functions/fzf_key_bindings.fish
3 changes: 3 additions & 0 deletions config/nvim/init.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath=&runtimepath
source ~/.vimrc
187 changes: 187 additions & 0 deletions config/pgcli/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# vi: ft=dosini
[main]

# Enables context sensitive auto-completion. If this is disabled the all
# possible completions will be listed.
smart_completion = True

# Display the completions in several columns. (More completions will be
# visible.)
wider_completion_menu = False

# Multi-line mode allows breaking up the sql statements into multiple lines. If
# this is set to True, then the end of the statements must have a semi-colon.
# If this is set to False then sql statements can't be split into multiple
# lines. End of line (return) is considered as the end of the statement.
multi_line = False

# If multi_line_mode is set to "psql", in multi-line mode, [Enter] will execute
# the current input if the input ends in a semicolon.
# If multi_line_mode is set to "safe", in multi-line mode, [Enter] will always
# insert a newline, and [Esc] [Enter] or [Alt]-[Enter] must be used to execute
# a command.
multi_line_mode = psql

# Destructive warning mode will alert you before executing a sql statement
# that may cause harm to the database such as "drop table", "drop database"
# or "shutdown".
destructive_warning = True

# Enables expand mode, which is similar to `\x` in psql.
expand = False

# Enables auto expand mode, which is similar to `\x auto` in psql.
auto_expand = False

# If set to True, table suggestions will include a table alias
generate_aliases = False

# log_file location.
# In Unix/Linux: ~/.config/pgcli/log
# In Windows: %USERPROFILE%\AppData\Local\dbcli\pgcli\log
# %USERPROFILE% is typically C:\Users\{username}
log_file = default

# keyword casing preference. Possible values "lower", "upper", "auto"
keyword_casing = auto

# casing_file location.
# In Unix/Linux: ~/.config/pgcli/casing
# In Windows: %USERPROFILE%\AppData\Local\dbcli\pgcli\casing
# %USERPROFILE% is typically C:\Users\{username}
casing_file = default

# If generate_casing_file is set to True and there is no file in the above
# location, one will be generated based on usage in SQL/PLPGSQL functions.
generate_casing_file = False

# Casing of column headers based on the casing_file described above
case_column_headers = True

# history_file location.
# In Unix/Linux: ~/.config/pgcli/history
# In Windows: %USERPROFILE%\AppData\Local\dbcli\pgcli\history
# %USERPROFILE% is typically C:\Users\{username}
history_file = default

# Default log level. Possible values: "CRITICAL", "ERROR", "WARNING", "INFO"
# and "DEBUG". "NONE" disables logging.
log_level = INFO

# Order of columns when expanding * to column list
# Possible values: "table_order" and "alphabetic"
asterisk_column_order = table_order

# Whether to qualify with table alias/name when suggesting columns
# Possible values: "always", never" and "if_more_than_one_table"
qualify_columns = if_more_than_one_table

# When no schema is entered, only suggest objects in search_path
search_path_filter = False

# Default pager.
# By default 'PAGER' environment variable is used
# pager = less -SRXF

# Timing of sql statments and table rendering.
timing = True

# Table format. Possible values: psql, plain, simple, grid, fancy_grid, pipe,
# ascii, double, github, orgtbl, rst, mediawiki, html, latex, latex_booktabs,
# textile, moinmoin, jira, vertical, tsv, csv.
# Recommended: psql, fancy_grid and grid.
table_format = psql

# Syntax Style. Possible values: manni, igor, xcode, vim, autumn, vs, rrt,
# native, perldoc, borland, tango, emacs, friendly, monokai, paraiso-dark,
# colorful, murphy, bw, pastie, paraiso-light, trac, default, fruity
syntax_style = default

# Keybindings:
# When Vi mode is enabled you can use modal editing features offered by Vi in the REPL.
# When Vi mode is disabled emacs keybindings such as Ctrl-A for home and Ctrl-E
# for end are available in the REPL.
vi = False

# Error handling
# When one of multiple SQL statements causes an error, choose to either
# continue executing the remaining statements, or stopping
# Possible values "STOP" or "RESUME"
on_error = STOP

# Set threshold for row limit prompt. Use 0 to disable prompt.
row_limit = 1000

# Skip intro on startup and goodbye on exit
less_chatty = False

# Postgres prompt
# \t - Current date and time
# \u - Username
# \h - Short hostname of the server (up to first '.')
# \H - Hostname of the server
# \d - Database name
# \p - Database port
# \i - Postgres PID
# \# - "@" sign if logged in as superuser, '>' in other case
# \n - Newline
# \dsn_alias - name of dsn alias if -D option is used (empty otherwise)
prompt = '\u@\h:\d> '

# Number of lines to reserve for the suggestion menu
min_num_menu_lines = 4

# Character used to left pad multi-line queries to match the prompt size.
multiline_continuation_char = ''

# The string used in place of a null value.
null_string = '<null>'

# manage pager on startup
enable_pager = True

# Use keyring to automatically save and load password in a secure manner
keyring = True

# Custom colors for the completion menu, toolbar, etc.
[colors]
Token.Menu.Completions.Completion.Current = 'bg:#ffffff #000000'
Token.Menu.Completions.Completion = 'bg:#008888 #ffffff'
Token.Menu.Completions.Meta.Current = 'bg:#44aaaa #000000'
Token.Menu.Completions.Meta = 'bg:#448888 #ffffff'
Token.Menu.Completions.MultiColumnMeta = 'bg:#aaffff #000000'
Token.Menu.Completions.ProgressButton = 'bg:#003333'
Token.Menu.Completions.ProgressBar = 'bg:#00aaaa'
Token.SelectedText = '#ffffff bg:#6666aa'
Token.SearchMatch = '#ffffff bg:#4444aa'
Token.SearchMatch.Current = '#ffffff bg:#44aa44'
Token.Toolbar = 'bg:#222222 #aaaaaa'
Token.Toolbar.Off = 'bg:#222222 #888888'
Token.Toolbar.On = 'bg:#222222 #ffffff'
Token.Toolbar.Search = 'noinherit bold'
Token.Toolbar.Search.Text = 'nobold'
Token.Toolbar.System = 'noinherit bold'
Token.Toolbar.Arg = 'noinherit bold'
Token.Toolbar.Arg.Text = 'nobold'
Token.Toolbar.Transaction.Valid = 'bg:#222222 #00ff5f bold'
Token.Toolbar.Transaction.Failed = 'bg:#222222 #ff005f bold'

# color of table
# you can use token or custom colors
Token.Output.Header = "#00ff5f bold"
Token.Output.OddRow = ""
Token.Output.EvenRow = ""

# Named queries are queries you can execute by name.
[named queries]

# DSN to call by -D option
[alias_dsn]
# example_dsn = postgresql://[user[:password]@][netloc][:port][/dbname]

# Format for number representation
# for decimal "d" - 12345678, ",d" - 12,345,678
# for float "g" - 123456.78, ",g" - 123,456.78
[data_formats]
decimal = ""
float = ""
2 changes: 1 addition & 1 deletion zsh/config.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ colors
setopt promptsubst
autoload -U promptinit
promptinit
prompt marten
prompt gbt

# Automatically pushd
setopt autopushd
Expand Down
25 changes: 25 additions & 0 deletions zsh/functions/prompt_gbt_setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
prompt_gbt_help () {
cat <<'EOF'
This is my prompt
EOF
}

export GBT_CARS='Dir, Git, Sign'
export GBT_RCARS='Status'
export GBT_CAR_DIR_DEPTH='9999'
export GBT_CAR_STATUS_FORMAT=' {{ Code }} '
export GBT_CAR_GIT_BG='none'
export GBT_CAR_GIT_FG='white'

prompt_gbt_setup () {
precmd () { prompt_gbt_precmd }
preexec () { }
}

prompt_gbt_precmd () {
# *Very* important to use single quotes, not double quotes... WHY?
PROMPT='$(gbt $?)'
RPROMPT='$(gbt -right $?)'
}

prompt_gbt_setup "$@"
3 changes: 3 additions & 0 deletions zsh/lib/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ alias g='git'
alias gp='git pull --rebase'
alias gti=git

alias ping='prettyping'

# List direcory contents
alias lsa='ls -lah'
alias l='ls -la'
Expand All @@ -35,6 +37,7 @@ alias beheer='sshuttle -r beheer11 10.128.0.0/9'
alias afind='ack-grep -il'
alias awssh="docker run -it --rm --volume $HOME/.ssh:/root/.ssh -e AWS_DEFAULT_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_SECURITY_TOKEN astopy/awssh"

alias psql='pgcli'
alias psql-panoptes-staging='psql -h panoptes-staging-new.cezuuccr9cw6.us-east-1.rds.amazonaws.com --user panoptes panoptes'
alias psql-panoptes-production='psql -h panoptes-production.cezuuccr9cw6.us-east-1.rds.amazonaws.com --user readonly panoptes'
alias psql-panoptes-slave='psql -h panoptes-production-read1.cezuuccr9cw6.us-east-1.rds.amazonaws.com --user readonly panoptes'
Expand Down
2 changes: 2 additions & 0 deletions zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ export PATH=/anaconda2/bin:$PATH

. $HOME/.asdf/asdf.sh
. $HOME/.asdf/completions/asdf.bash

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

0 comments on commit a2782b1

Please sign in to comment.