Created
November 26, 2024 13:38
Revisions
-
wbob created this gist
Nov 26, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ #!/usr/bin/env bash # # simple sqlite-wrapper to have PAGER support # # install and chmod+x to ~/bin/wsqlite and load in ~/.profile PATH set -eE command -v sqlite3 >/dev/null || echo "sqlite3 not found, please install" || exit 1 command -v tmux >/dev/null || echo "tmux not found, please install" || exit 1 usage() { echo "usage: wsqlite <sqlite.db>" } test -z $1 && usage && exit 0 target="$1" fullpath=$(readlink -f .) fifo="$fullpath/sqlitepager.tmp" rc="$fullpath/sqlitepager.rc" test -p "$fifo" && rm -v "$fifo" mkfifo "$fifo" test -f "$rc" && rm -v "$rc" echo ".output \"$fifo\"" > "$rc" echo ".mode column" >> "$rc" cat "$rc" tmux kill-session -t "sqlite" >/dev/null || continue tmux new-session -s "sqlite" -d tmux split-window -d -v -t "sqlite" tmux send -t "sqlite.0" "sqlite3 -init \"$rc\" \"$target\"" ENTER tmux send -t "sqlite.1" "less -f -S \"$fifo\"" ENTER tmux attach-session -d -t "sqlite.0" -c "ls" rm "$fifo" rm "$rc"