Skip to content

Commit

Permalink
Fixing os-name constant & a bunch of other nifty fixes and tweaks (#123)
Browse files Browse the repository at this point in the history
* Fixing os-name constant

* Many small fixes and adjustments.

* Zeds dead baby, zeds dead

* Fix the name of the test

* Fixing the flakey test

* kick build

* Hopefully fixing the test

* Updating docs for version 3.1.3

* Hoping to explain test failures oni CI

* Bypasssing the test if $CI is defined
  • Loading branch information
kigster authored Dec 16, 2022
1 parent 4be0e2a commit d487f12
Show file tree
Hide file tree
Showing 32 changed files with 704 additions and 378 deletions.
10 changes: 9 additions & 1 deletion .bash_safe_source
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
set +e

function is-debug() {
[[ $((DEBUG + BASHMATIC_DEBUG + BASHMATIC_PATH_DEBUG)) -gt 0 ]]
export DEBUG=${DEBUG:-0}
export BASHMATIC_DEBUG=${BASHMATIC_DEBUG:-0}
export BASHMATIC_PATH_DEBUG=${BASHMATIC_PATH_DEBUG:-0}
local sum=$(( DEBUG + BASHMATIC_DEBUG + BASHMATIC_PATH_DEBUG ))
if [[ ${sum} -gt 0 ]]; then
return 0
else
return 1
fi
}

function debug-info() {
Expand Down
17 changes: 9 additions & 8 deletions .db.active.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
-- vim: ft=sql
select pid,
rpad(coalesce(datname, 'DB'), 20) as dbname,
rpad(coalesce(application_name, 'app'), 7) as app,
rpad(coalesce(backend_type, 'bcknd'), 15) as backand_type,
to_char((now() + interval '0.0001 sec' - query_start)::interval, 'HH24:MM:SS.ms') as duration,
rpad(regexp_replace(query, E'[\\n\\r +]+', ' ', 'g'), QUERY_WIDTH) as Query
-- /* db.top.active.queries */
select
pid,
rpad(coalesce(application_name, 'app'), 7) as app,
rpad(coalesce(state, 'state'), 7) as state,
to_char((now() + interval '0.0001 sec' - query_start)::interval, 'HH24:MM:SS.ms') as duration,
rpad(regexp_replace(query, E'[\\n\\r +]+', ' ', 'g'), QUERY_WIDTH) as Query
from pg_stat_activity
where state != 'idle'
order by duration desc
where state not like '%QUERY_FILTER_OUT%' and query not like '%db.top.active.queries%'
order by duration desc;
9 changes: 9 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@ jobs:
uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
with:
ruby-version: '3.1'
- name: Source
env:
TERM: xterm-256color
MIN_WIDTH: 80
run: |
source init.sh;
printf "date.now.with-time.and.zone: [%s]\n" "$(date.now.with-time.and.zone)";
printf " date zone: [%s]\n" "$(date '+%z')";
- name: Test
env:
TERM: xterm-256color
MIN_WIDTH: 80
CI: true
run: bin/specs
20 changes: 6 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
.bats-*
.bundle
.bundle/
.dccache
.developer-warned
.envrc.local
.fonts/
.history
.idea/
.last-loaded
.last-rebase
.rubocop
.ruby-version
.vscode/*.log
/test/tmp/
/test/version_tmp/
/tmp/
Expand All @@ -18,17 +24,3 @@ libexec/
share/
shellcheck.log
test/all.bats
**/.DS_Store
.envrc.local
.fonts/
*.pdf.reduced
.bundle/
doc/USAGE.adoc
.developer-warned
.history
.vscode/*.log
.ruby-version
.last-loaded
.developer-warned
.dccache
.rubocop
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.1
3.1.3
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[separator=—]
= Bashmatic® — BASH-based DSL helpers for humans, sysadmins, and fun.
// vim: ft=asciidoc
:author: Version v3.1.0
:author: Version v3.1.3
:doctype: book
:source-highlighter: rouge
:rouge-style: base16.monokai
Expand Down
Binary file modified README.pdf
Binary file not shown.
29 changes: 16 additions & 13 deletions bin/.db
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
│  │DESCRIPTION: Performs one of many supported actions against PostgreSQL
├──────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│  │FLAGS: 
│  │ -q / --quiet  Suppress the colorful header messages
│  │ -v / --verbose  Show additional output
│  │ -n / --dry-run  Only print commands, but do not run them
│  │ -q / --quiet  Suppress the colorful header messages
│  │ -v / --verbose  Show additional output
│  │ -n / --dry-run  Only print commands, but do not run them
├──────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│  │GLOBAL FLAGS:  
│  │ -C / --commands  List all sub-commands to the db script
│  │ -c / --connectons List all available database connections
│  │ -e / --examples  Show script usage examples
│  │ -h / --help  Show this help screen
│  │   
│  │GLOBAL FLAGS:  
│  │ -w / --width WIDTH  Use specified screen width instead of automatic.
│  │ -f / --filter REGEX Defaults to 'idle', but can be set
│  │   to remove some active queries from the view.
│  │ -C / --commands  List all sub-commands to the db script
│  │ -c / --connections  List all available database connections
│  │ -e / --examples  Show script usage examples
│  │ -h / --help  Show this help screen
│  │   
├──────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│  │SUMMARY:  
│  │   This tool uses a list of database connections defined in the
│  │   YAML file that must be installed at: ~/.db/database.yml
│  │   
│  │SUMMARY:  
│  │   This tool uses a list of database connections defined in the
│  │   YAML file that must be installed at: ~/.db/database.yml
│  │   
└──────────────────────────────────────────────────────────────────────────────────────────────────────────┘
1 change: 0 additions & 1 deletion bin/bashmatic-install
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ function .install.darwin-requirements() {
# Ensure OS-specific reqquirements are satisfied
#——————————————————————————————————————————————————————————————————————————————————————
function .install.os-requirements() {
export BASHMATIC_OS="$(uname -s | tr '[:upper:]' '[:lower:]')"

case ${BASHMATIC_OS} in
darwin)
Expand Down
2 changes: 1 addition & 1 deletion bin/install-direnv
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function direnv.install() {
printf " — NO."
not-ok:

export BASHMATIC_OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
export BASHMATIC_OS="${BASHMATIC_OS_NAME}"

if [[ ${BASHMATIC_OS} == darwin ]]; then
command -v brew>/dev/null || brew.install
Expand Down
13 changes: 7 additions & 6 deletions conf/.psqlrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
-- vim: set filetsype=sql
-- don't output commands as we run them
-- set how to output numbers (this turns on thousdand separators)
\set PSQLRC_VERSION '(v0.1.1)'
\set PSQLRC_VERSION '1.0.1'
\set PSQLRC_RELEASED 'Thu Dec 15 18:36:30 PST 2022'
\set QUIET 1
\encoding unicode
\timing 0
Expand All @@ -22,16 +23,18 @@
-- Verbose error reports.
\set VERBOSITY verbose
\echo '┌───────────────────────────────────────────────────────────────────────────┐'
\echo '│ PostgreSQL PSQL Prompt & Shortcuts ' :PSQLRC_VERSION ' │'
\echo '│ © 2016-2022 All Rights Reserved @kigster, MIT License 🌎 https://kig.re/ │'
\echo '│ PostgreSQL PSQL Macros, Version v' :PSQLRC_VERSION ' (' :PSQLRC_RELEASED ') │'
\echo '│ © 2015-2023 All Rights Reserved @kigster, MIT License 🌎 https://kig.re/ │'
\echo '│ │'
\echo '│ To switch between wide and narrow result views, type \\x<ENTER> │'
\echo '└───────────────────────────────────────────────────────────────────────────┘'
\echo
\pset border 0
\pset tuples_only 1
SELECT ' PostgreSQL Server Version: ' || regexp_replace(version(), 'PostgreSQL ([\d.]+) .*', '\1', 'g') as pg_version;
\echo ' To load and view macros, type :macros<ENTER> (or :m for short)'
\echo '┌───────────────────────────────────────────────────────────────────────────┐'
\echo '│ 💡 To load and view macros, type :macros<ENTER> (or :m for short) │'
\echo '└───────────────────────────────────────────────────────────────────────────┘'
\echo

\pset border 3
Expand All @@ -49,5 +52,3 @@ SET search_path TO public,extensions;
-- New Prompt, more compact, and works with back editing using readlines
\set PROMPT1 '%[%033[0;30;33m%]%[%033[0;43;30m%] %`date "+%H:%M:%S%p"` %033[0;30;33m%]%033[0;43;37m%]%[%033[0;0;0m%]━%[%033[0;30;32m%]%033[0;42;30m%] %n@%M:%> %033[0;32m%%[%033[3;30;96m%]━%[%033[3;30;106m%]% %[%033[3;30;106m%]%/%x %033[0;96m% %[%033[0m%]\n ❯ '
\set PROMPT2 '%[%033[0;30;33m%] ⤷ %l%[%033[0m% ❯ '
\set PROMPT1 '%[%033[6;30;33m%]%[%033[0;43;30m%] %`date "+%H:%M:%S%p"` %[%033[%6;30;33m%]%[%033[%0;0;0m%]━%[%033[%3;5;35m%]%[%033[5;32;34m%] %n@%M:%> %[%033[3;30;44m%]━━━%[%033[3;34;81m%]% %[%033[3;30;106m%] %/%x %[%033[%0m%]\n ❯ '

Loading

0 comments on commit d487f12

Please sign in to comment.