This plugin enhances your Oh My Zsh setup by providing an easy way to manage and connect to PostgreSQL databases using pgcli
and fzf
for a seamless command-line experience.
Ensure you have the following tools installed before using this plugin:
- fzf: A command-line fuzzy finder.
- pgcli: A Postgres client with auto-completion and syntax highlighting.
To install the PostgreSQL Connection Plugin, follow these steps:
-
Clone the repository into your custom Oh My Zsh plugins directory:
git clone [email protected]:ruslan-korneev/pgconnect-zsh.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/pgconnect
-
Add
pgconnect
to the list of plugins in your.zshrc
file:plugins=(... pgconnect)
-
Reload your Zsh configuration:
source ~/.zshrc
To manage your PostgreSQL connections, configure your ~/.pg_service.conf
file. This file allows you to define multiple database connections. Here is an example configuration:
[db1]
host=0.0.0.0
port=5862
user=username
dbname=postgres
[db2]
host=0.0.0.0
port=5432
user=postgres
dbname=mysuperdatabase
After setting up your ~/.pg_service.conf
, you will be able to see and select these databases from a list using the plugin.
To keep your passwords secure, you can use the .pgpass
file, which stores your credentials safely. If you prefer, you can also include the password directly in the ~/.pg_service.conf
file using the password
attribute, though this is not recommended for security reasons.
For more detailed information on configuring these files, refer to the PostgreSQL documentation on connection service files and password file.
Feel free to contribute to this project by submitting issues or pull requests. Enjoy seamless PostgreSQL connections with Oh My Zsh!