https://github.com/funbringer/smart_psqlrc
Smart .psqlrc with a neat customizable prompt
https://github.com/funbringer/smart_psqlrc
postgres postgresql psql psqlrc
Last synced: 4 months ago
JSON representation
Smart .psqlrc with a neat customizable prompt
- Host: GitHub
- URL: https://github.com/funbringer/smart_psqlrc
- Owner: funbringer
- License: mit
- Created: 2017-10-05T10:39:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-14T11:21:33.000Z (about 8 years ago)
- Last Synced: 2025-10-30T01:34:02.079Z (8 months ago)
- Topics: postgres, postgresql, psql, psqlrc
- Language: Shell
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Make `psql` even more powerful
### Overview
This repository contains two important files:
* `.psqlrc`
* `pg_debug`
The first one is a config file which provides a simple way to extend command prompt in **`psql`**,
a terminal-based front-end to PostgreSQL. The latter is a tiny script which allows you to quickly
attach to the current PostgreSQL backend using a `:gdb` command defined in `.psqlrc`
(keep in mind that it only works with the `yakuake` terminal emulator, though).
### What can I do with this stuff?
This is how default psql prompt looks like:
```
psql (10.0)
Type "help" for help.
postgres=#
```
Using this config, you can easily add a few more useful things to prompt:
```
~/pg_10/bin/psql postgres -p 10679
psql (10.0)
Type "help" for help.
postgres[R, 10679]=#
```
Where `R` means we're connected to some replica node, and `10679` is the port this node listens to.
### How do I add my favorite setting?
Simply add a line describing your setting to `.psqlrc` under the `Put your lines here.` comment, for example:
```plpgsql
/* ORDER NAME FMT_STRING DEFAULT_VALUE */
(1, 'master_or_replica', '', 'M'),
(2, 'port', 'port', '5432'),
(3, 'shardman.my_id', '@', NULL),
(4, 'multimaster.node_id', '@', NULL)
```
By default values are taken from table called `pg_settings` (it's part of the system catalog), but you can add a few more relations using the `UNION` statement.
This is how the result might look like:
```
psql (10.0)
Type "help" for help.
postgres[port=5433, @2]=#
```