Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sqlite-history.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sql_escape () {

_histdb_query () {
sqlite3 -cmd ".timeout 1000" "${HISTDB_FILE}" "$@"
[[ "$?" -ne 0 ]] && echo "error in $@"
[[ "$?" -ne 0 ]] && print -u2 "error in $@"
}

_histdb_stop_sqlite_pipe () {
Expand Down Expand Up @@ -189,12 +189,16 @@ histdb-top () {
join='commands.id = history.command_id'
table=commands
;;;
*)
print -u2 'error: argument must be one of "cmd" or "dir"'
return 1
;;;
esac
_histdb_query -separator "$sep" \
-header \
"select count(*) as count, places.host, replace($field, '
', '
$sep$sep') as ${1:-cmd} from history left join commands on history.command_id=commands.id left join places on history.place_id=places.id group by places.host, $field order by count(*)" | \
$sep$sep') as ${1} from history left join commands on history.command_id=commands.id left join places on history.place_id=places.id group by places.host, $field order by count(*)" | \
"${HISTDB_TABULATE_CMD[@]}"
}

Expand Down