Reference

The command-line options and environment variables, the default key bindings by keymap context, the menus, and the files pgtc reads and writes.

Command line

pgtc [OPTION]... [DBNAME [USERNAME]]

The connection options are psql's.

OptionMeaning
-h, --host HOSTNAMEhost: host name or IP address, or the directory of the server's Unix-domain socket.
-p, --port PORTport.
-U, --username USERNAMEuser: the role to connect as.
-d, --dbname DBNAMEdbname — or a connection URI.
-w, --no-passwordNever prompt for a password. If the server requests one and none is available, the connection attempt fails.
-W, --passwordAlways prompt for a password.
--setupRun every installation step (today: install the developer templates), print one line per step, and exit. The exit code is not zero if a step failed.
--install-templatesCopy the developer templates that come with pgtc into your templates folder, and exit. If the folder exists, pgtc asks [y/N] before overwriting its own templates.
-?, --helpShow the options and exit. (-h is host, as in psql.)
-V, --versionShow the version and exit.

Positional arguments as in psql.

Examples

pgtc                                         start with the saved connections
pgtc adventureworks                          dbname adventureworks on localhost, role = your OS user name
pgtc -h db.example.com -U app adventureworks
pgtc -h db.example.com -p 5433 -U app -W adventureworks
pgtc postgresql://app@db.example.com/adventureworks
pgtc "postgresql://app@db.example.com:5433/adventureworks?sslmode=verify-full"
pgtc --setup

Connection URIs

postgresql://[user[:password]@][host][:port][/dbname][?sslmode=...&sslrootcert=...]

Also postgres://.

Environment variables

VariableMeaning
PGHOST, PGPORT, PGUSER, PGDATABASEDefaults for host, port, user and dbname.
PGSSLMODE, PGSSLROOTCERTDefaults for sslmode and sslrootcert. There is no command-line option for them; give them here or in a URI.
PGPASSWORDThe password (used for this run only; not saved).
PGPASSFILEAnother location of the password file.
PGTC_LOGLevel filter of pgtc's own log.

Other libpq variables (PGSERVICE, PGOPTIONS, PGAPPNAME, …) are not read. An invalid PGPORT or PGSSLMODE is an error at start.

Precedence: a URI, then the options, then the environment variables, then the built-in defaults — host localhost, port 5432, user = your operating-system user name, dbname = the user name, sslmode prefer.

Effect: with any connection argument, pgtc saves the connection (unless one with the same host, port, database, user and sslmode is saved) and connects it at start.

Keyboard reference

Default bindings by keymap context; the last column is the command name for keymap.toml. F1 in pgtc shows the effective keymap.

Help → Keyboard shortcuts
Help → Keyboard shortcuts; the last lines give the path of keymap.toml.

Everywhere [global]

KeyWhat it doesCommand
F1The keys that work nowhelp
F9Open the menu barmenu
F10Quit pgtcquit
Ctrl+NNew query tabnew_query
F6, Ctrl+TabSwitch between the object tree and the right frameswitch_panel
Alt+1, Ctrl+1Focus the object treefocus_tree
Alt+2, Ctrl+2Focus the right frame (the part last used)focus_right
Alt+Down, Ctrl+Shift+DownLower part of the right frame (results, messages, statement pane)focus_lower
Alt+Up, Ctrl+Shift+UpUpper part of the right frame (editor, list)focus_upper
Alt+RightNext tabnext_tab
Alt+LeftPrevious tabprev_tab
Ctrl+WClose the tabclose_tab

Object tree [tree]

KeyWhat it doesCommand
Up, DownUp / downup, down
Left, RightCollapse / expandleft, right
PgUp, PgDnPage up / downpage_up, page_down
Home, EndFirst / last rowhome, end
EnterExpand or collapse the rowaccept
F2Context menucontext_menu
F3Show the object in a new tabshow_in_new_tab
F8Delete the saved connection (nothing is dropped on the server)drop_object
Ctrl+RRefresh the object treerefresh_tree
Ctrl+EEdit the shown definition in a new query tabedit_in_query_tab
Ctrl+BSELECT * FROM … LIMIT 100 for the table or view, in a new query tabselect_top_rows
Alt+S, Ctrl+SQuick searchquick_search
Ctrl+FFind an object below the selected tree rowfind_object
Alt+D, Ctrl+DServer dashboard of the selected server or databasedashboard
Alt+P, Ctrl+PSQL profilersql_profiler
Alt+IStatistics of the selected databasedb_stats
—Show / hide system objectstoggle_system_objects

Editor and object view [editor]

Also the read-only object view and the statement pane.

KeyWhat it doesCommand
F5Execute the selection or the whole scriptexecute
Alt+Shift+CSend a cancel request for the running statementcancel_query
F7Generate SQL from developer templatenew_from_template
F4psql-style command linepsql_command
F8Ask AI for SQL — into the editor, never run (AI assistant)ask_ai
Ctrl+Space, Alt+/Autocomplete: object names, columns and keywordscomplete
Ctrl+PPL/pgSQL mode on / offtoggle_plpgsql
Ctrl+EEdit the shown definition (or statement) in a new query tabedit_in_query_tab
Ctrl+SSave SQL filesave_file
ArrowsMoveup, down, left, right
PgUp, PgDnPage up / downpage_up, page_down
Home, EndStart / end of the linehome, end
Ctrl+Home, Ctrl+EndStart / end of the textdoc_start, doc_end
Ctrl+Left, Ctrl+RightWord left / rightword_left, word_right
Shift+arrowsSelectselect_left, select_right, select_up, select_down
Ctrl+Shift+Left, Ctrl+Shift+RightSelect word left / rightselect_word_left, select_word_right
Shift+Home, Shift+EndSelect to the start / end of the lineselect_home, select_end
Shift+PgUp, Shift+PgDnSelect a page up / downselect_page_up, select_page_down
Ctrl+Shift+Home, Alt+Shift+HomeSelect to the start of the textselect_doc_start
Ctrl+Shift+End, Alt+Shift+EndSelect to the end of the textselect_doc_end
Ctrl+ASelect allselect_all
Ctrl+C, Ctrl+InsertCopycopy
Ctrl+X, Shift+DeleteCutcut
Ctrl+V, Shift+InsertPastepaste
Ctrl+ZUndoundo
Ctrl+Shift+Z, Alt+Shift+ZRedoredo
Tab, Shift+TabIndent / unindentindent, unindent
EnterNew linenewline
Backspace, DeleteDelete left / rightbackspace, delete
Ctrl+Backspace, Ctrl+DeleteDelete the word left / rightdelete_word_left, delete_word_right
Ctrl+YDelete the line (the selected lines)delete_line
Ctrl+FFind / replacefind
F3Find nextfind_next
Shift+F3, Alt+F3Find previousfind_prev
Ctrl+RShow / hide the resultstoggle_results
Alt+MSwitch between results and messagesshow_messages
Ctrl+PgDn, Alt+PgDnNext result setnext_result
Ctrl+PgUp, Alt+PgUpPrevious result setprev_result
Alt+EndFetch all rowsfetch_all
Alt+Shift+Up, Alt+Shift+DownResults smaller / largerresults_smaller, results_larger

Results and messages [results]

KeyWhat it doesCommand
Arrows, PgUp, PgDn, Home, EndMove the cell cursorup … end
Ctrl+Home, Ctrl+EndFirst / last rowdoc_start, doc_end
EnterMessages: jump to the editor line of the erroraccept
Ctrl+C, Ctrl+InsertCopy the cell / the messagecopy
Ctrl+ASelect allselect_all
F2Context menucontext_menu
Alt+RightNext result set, then Messagesnext_result_tab
Alt+LeftPrevious result set or Messagesprev_result_tab
Ctrl+PgDn, Alt+PgDnNext result setnext_result
Ctrl+PgUp, Alt+PgUpPrevious result setprev_result
Alt+MSwitch between results and messagesshow_messages
Alt+EndFetch all rowsfetch_all
Alt+Shift+Up, Alt+Shift+DownResults smaller / largerresults_smaller, results_larger
Ctrl+RShow / hide the resultstoggle_results
F5Executeexecute
Alt+Shift+CSend a cancel request for the running statementcancel_query
F4psql-style command linepsql_command
F8Ask AI for SQL — into the editor, never run (AI assistant)ask_ai
Ctrl+PPL/pgSQL mode on / offtoggle_plpgsql
Ctrl+SSave SQL filesave_file
—Export the resultexport_result
—Copy all messagescopy_all_messages

Server dashboard [dashboard]

KeyWhat it doesCommand
F5Refresh now (reconnects when needed)dashboard_refresh
Ctrl+PPause / resume the refreshdashboard_pause
Ctrl+TRefresh interval (0.5, 1, 2, 5, 10, 30 s)dashboard_interval
Alt+IHide / show idle sessionshide_idle_sessions
Alt+TSession duration: query, transaction or backend timeduration_mode
InsertTag / untag the sessiontag_session
EscUntag all sessionsclear_tags
Alt+Right, Ctrl+PgDn, Alt+PgDnNext dashboard listnext_list
Alt+Left, Ctrl+PgUp, Alt+PgUpPrevious dashboard listprev_list
Alt+Shift+Cpg_cancel_backend() on the selected sessioncancel_backend
F8pg_terminate_backend() on the selected sessionterminate_backend
EnterShow the whole row (full query text)show_row
Ctrl+EThe statement in a new query tabedit_in_query_tab
Ctrl+RShow / hide the statement panetoggle_results
Alt+Shift+Up, Alt+Shift+DownStatement pane smaller / largerresults_smaller, results_larger
F2Context menucontext_menu
Ctrl+C, Ctrl+Insert; Ctrl+ACopy; select allcopy, select_all
Arrows, PgUp, PgDn, Home, End, Ctrl+Home, Ctrl+EndMove in the listup … doc_end

SQL profiler [profiler]

KeyWhat it doesCommand
F5Start / stop the profilerprofiler_start_stop
Ctrl+PPause / resumeprofiler_pause
Ctrl+FFilter the entriesprofiler_filter
Ctrl+LClear the entriesprofiler_clear
Ctrl+QExecution plan (EXPLAIN) of the entry's statementprofiler_plan
EnterShow the whole entryshow_row
Ctrl+EThe statement in a new query tabedit_in_query_tab
Ctrl+RShow / hide the statement panetoggle_results
Alt+Shift+Up, Alt+Shift+DownStatement pane smaller / largerresults_smaller, results_larger
F2Context menucontext_menu
Ctrl+C, Ctrl+Insert; Ctrl+ACopy; select allcopy, select_all
Arrows, PgUp, PgDn, Home, End, Ctrl+Home, Ctrl+EndMove in the listup … doc_end

Database statistics [db_stats]

KeyWhat it doesCommand
F5Read the statistics again (reconnects when needed)db_stats_refresh
F2Context menucontext_menu
Ctrl+C, Ctrl+Insert; Ctrl+ACopy; select allcopy, select_all
Arrows, PgUp, PgDn, Home, End, Ctrl+Home, Ctrl+EndMove in the listup … doc_end

Template tab [template]

The template editor tab. F5, F7 and Ctrl+T work in every part; the other keys in the header list (elsewhere the [editor] keys apply).

KeyWhat it doesCommand
F5Test the template in its form (nothing is inserted)template_test
F7Helper menu of the template bodytemplate_helpers
Ctrl+TParameter list / raw header (TOML)template_raw_header
Ctrl+SSave the templatesave_file
Ctrl+RShow / hide the previewtoggle_results
Alt+Shift+Up / Alt+Shift+DownPreview smaller / largerresults_smaller, results_larger
EnterEdit the name, the description or the parametertemplate_edit_param
InsertAdd a parametertemplate_add_param
DeleteDelete the parametertemplate_delete_param
Ctrl+Up, Shift+UpMove the parameter uptemplate_param_up
Ctrl+Down, Shift+DownMove the parameter downtemplate_param_down
F2Context menucontext_menu
Tab, Shift+TabNext / previous part of the tab (header list and preview; Alt+Down / Alt+Up everywhere)next_field, prev_field
Up, Down, PgUp, PgDn, Home, EndMove in the listup … end

Dialogs, menus and lists [dialog]

KeyWhat it doesCommand
Tab, Shift+TabNext / previous fieldnext_field, prev_field
EnterOpen / choose / OKaccept
Ctrl+EnterOK from any field (where the terminal reports Ctrl+Enter)dialog_ok
Esc, F10Cancel / closecancel
SpaceToggle the checkboxtoggle
Arrows, PgUp, PgDn, Home, EndMoveup … end
Backspace, DeleteDelete left / rightbackspace, delete

Other keys

KeyWhat it does
Esc, digitF1 … F10 (Esc 1 … Esc 0), for terminals without F-keys
F9, letterThe menu with that underlined letter
Alt+letterThe dialog field with that underlined letter

Commands without a default key

Menu only; bind them in keymap.toml:

commit, rollback, toggle_auto_commit, toggle_auto_rollback, export_result, copy_all_messages, save_file_as, open_file, toggle_system_objects, new_connection, edit_connection, delete_connection, connect, disconnect, export_definition, load_definition, settings, run_setup, install_templates, show_templates_folder, keyboard_shortcuts, third_party_licences, about, template_manager, template_insert_param, template_insert_construct, template_insert_filter, template_make_param, template_add_variant.

F9 opens the menu bar. Keys are the default bindings, with their context in brackets.

MenuItemKeyNotes
FileNew connection…Save a new set of connection parameters
Edit connection…The server of the selected tree row; changed connection parameters disconnect and reconnect the server (its tabs are closed) (details)
Delete connection…The server of the selected tree row, after confirmation
ConnectThe server selected in the tree
Disconnect
New queryCtrl+NNeeds a database (or an object below it) selected in the tree
Open SQL file…
Save SQL fileCtrl+SIn a query tab
Save SQL file as…
Export database definition…Needs a database selected in the tree
Load database definition…
QuitF10
ViewRefresh object treeCtrl+R (tree)
Edit in new query tabCtrl+EThe shown definition or statement
Select top 100 rowsCtrl+B (tree)Tables and views: SELECT * … LIMIT 100
Find object…Ctrl+F (tree)
Next tabAlt+Right
Previous tabAlt+Left
Close tabCtrl+WNot the default tab
QueryExecuteF5Enabled in a query tab
CancelAlt+Shift+C
Fetch allAlt+End
Export result…
Commit
Rollback
Auto commit [x]
Auto rollback on error [x]
PL/pgSQL mode [x]Ctrl+P
Show/hide resultsCtrl+R
Results / MessagesAlt+M
Next result setCtrl+PgDn
Previous result setCtrl+PgUp
ToolsGenerate SQL from developer template…F7In a connected query tab
Developer templates…Always: the template editor
psql command…F4In a connected query tab
Ask AI…F8 (query tab)A connected query tab, AI set up (AI assistant)
Server dashboardAlt+D (tree)Needs a connected server
SQL profilerAlt+P (tree)
SettingsSettings…
AI…Provider, model and API key of the AI assistant
Run setupAs pgtc --setup
Install templatesAs pgtc --install-templates
Show templates folder
HelpKeyboard shortcutsEvery key of your keymap, and the path of keymap.toml
Third-party licences
About pgtcVersion, copyright, licence

Files and folders

PlatformConfig folderData folder
Linux~/.config/pgtc (or $XDG_CONFIG_HOME/pgtc)~/.local/share/pgtc (or $XDG_DATA_HOME/pgtc)
macOS~/Library/Application Support/pgtc
Windows%APPDATA%\pgtc
File or folderInWhat
settings.tomlconfigSettings and saved connections (no passwords)
keymap.tomlconfigYour key-binding overrides (you create it)
ai_keyconfigThe AI provider's API key, when it is kept in a file (AI assistant); readable only by you
developer_templates/dataDeveloper templates
themes/dataYour own colour schemes
logs/dataLog files pgtc.YYYY-MM-DD.log, one per day; the last 7 are kept
profiler_restore.tomldataLogging parameters the profiler changed and has not restored yet (no passwords)
window.tomldataWindows only: position of pgtc's own console window
.pgpass / pgpass.conflibpq's locationThe password file, shared with psql and other libpq clients — ~/.pgpass, %APPDATA%\postgresql\pgpass.conf, or PGPASSFILE

Log

pgtc logs to a file, never to stdout or stderr. Default level info; PGTC_LOG takes a level or a per-module filter (PGTC_LOG=debug, PGTC_LOG=pgc_db=trace).

Window position (Windows)

Started from Explorer, a shortcut or Win+R, pgtc has its own console window and restores its position and maximized state. A terminal you opened yourself is never moved.

About and licences

PostgreSQL Licence. The catalog queries are adapted from pgAdmin 4 (same licence).