diff --git a/tsv/sqlite3ncsv b/tsv/sqlite3ncsv index 92ce223..4e6f821 100755 --- a/tsv/sqlite3ncsv +++ b/tsv/sqlite3ncsv @@ -8,6 +8,8 @@ echo 'Sqlite3NCSV: view sqlite3 DB with ncsv. TABLE: If not given, first in schema used. QUERY: If the second argument contains spaces, it is assumed to be a query. -l: List table names + + note: will try for tabview if ncsv not installed ' } [[ "$1" == "-h" ]] && { @@ -33,6 +35,11 @@ sqlfile="$1" } || { query="$table" } +VIEWER=ncsv +which ncsv > /dev/null || { + VIEWER="tabview -" + which tabview > /dev/null || VIEWER="cat -" +} -sqlite3 -header -separator ' ' -nullvalue NA "$sqlfile" "$query" | ncsv +sqlite3 -header -separator ' ' -nullvalue NA "$sqlfile" "$query" | $VIEWER