Run commands on startup
I would like to run some commands on start up, like \x.
Is this possible?
Right now there is no way to have a startup command.
Is \x the only thing you have in mind or do you have other ideas for this request?
The reason I ask is because I can made the expanded output to be a config option in ~/.pgclirc and you'll be able to achieve this feature. If you have more things in mind, I'll have to think of a different solution.
I would also like to be able to change the value for nulls:
`\pset null '(null)'``.
In my current psqlrc I also echo out a cheatsheet of \ commands, but I can live without those...
https://github.com/leebrooks0/dotfiles/blob/master/psqlrc
The null thing is not going to work. \pset is not supported by pgcli. Right now all null values are displayed as <null> by default.
The idea is that pgcli should ship with sane defaults that requires no configuration. But there does exist a config file which tweaks certain settings such as colorscheme and keybindings.
I can sympathize with the cheat sheet commands. I'll see what I can do.
Also I didn't know about \x auto that seems like an awesome feature of psql that I might steal. :)
One other thing worth mentioning, can you also add to the config file the ability to use multiline by default?
Aha! This is already part of the config file. Open up ~/.pgclirc and you'll see an option to enable or disable multi-line mode.
Is it possible to use the .pgclirc config file to set my default search path, like I can in .psqlrc? What would be the syntax?
I would join to the question how to set up defaul search_path. Is it possible now?
I too would like the ability to execute arbitrary commands on startup. My use case is a little different; I want to be able to CREATE TEMP VIEW on startup for some tables that I frequently join together. I don't think "named queries" are what I'm looking for because AFAICT you can't use named queries as part of another query, e.g. I wouldn't be able to join a named query against some other table. (Correct me if I'm wrong.)
psql just interprets everything in .psqlrc literally; I'm not super familiar with the details of the config file format, but would it be possible to add a section like "literal startup commands" that just sends every line straight to _evaluate_command?
My use case for it would be automatically making the session as readonly when connecting to a production database. E.g. SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;