Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ Contributors:
* Daniele Varrazzo
* Daniel Kukula (dkuku)
* Kian-Meng Ang (kianmeng)
* Mathieu Gascon-Lefebvre (mlefebvre)

Creator:
--------
Expand Down
4 changes: 4 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Upcoming:
=========

Features:
---------
* Add a configuration option to execute commands on startup ([related issue](https://github.com/dbcli/pgcli/issues/247)).

Bug fixes:
----------

Expand Down
5 changes: 5 additions & 0 deletions pgcli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def __init__(
self.float_format = c["data_formats"]["float"]
auth.keyring_initialize(c["main"].as_bool("keyring"), logger=self.logger)
self.show_bottom_toolbar = c["main"].as_bool("show_bottom_toolbar")
self.startup_command = c["main"]["startup_command"]

self.pgspecial.pset_pager(
self.config["main"].as_bool("enable_pager") and "on" or "off"
Expand Down Expand Up @@ -778,6 +779,10 @@ def run_cli(self):
print("Home: http://pgcli.com")

try:
if self.startup_command:
print(f"Executing startup command: {self.startup_command}")
self.handle_watch_command(self.startup_command)

while True:
try:
text = self.prompt_app.prompt()
Expand Down
3 changes: 3 additions & 0 deletions pgcli/pgclirc
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ enable_pager = True
# Use keyring to automatically save and load password in a secure manner
keyring = True

# Command to run at startup. Multiple commands can be specified if separated by a semicolon.
startup_command = ''

# Custom colors for the completion menu, toolbar, etc.
[colors]
completion-menu.completion.current = 'bg:#ffffff #000000'
Expand Down