diff --git a/AUTHORS b/AUTHORS index 2bf68e873..539b5c349 100644 --- a/AUTHORS +++ b/AUTHORS @@ -122,6 +122,7 @@ Contributors: * Daniele Varrazzo * Daniel Kukula (dkuku) * Kian-Meng Ang (kianmeng) + * Mathieu Gascon-Lefebvre (mlefebvre) Creator: -------- diff --git a/changelog.rst b/changelog.rst index 952583ebd..74e0d1857 100644 --- a/changelog.rst +++ b/changelog.rst @@ -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: ---------- diff --git a/pgcli/main.py b/pgcli/main.py index 3d42dca8a..fbc02d8a8 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -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" @@ -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() diff --git a/pgcli/pgclirc b/pgcli/pgclirc index 6654ce92e..5799f972f 100644 --- a/pgcli/pgclirc +++ b/pgcli/pgclirc @@ -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'