Created
March 15, 2011 00:08
-
-
Save qdw/870109 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Include the role (MASTER versus SLAVE) in your bash prompt. For example: | |
# | |
# quinn@tao (MASTER) ~$ | |
# | |
# I use this to remind myself which node is which during failover testing. Helpfully, this also | |
# tells you if both nodes think they're the master (or the slave). Either can happen if | |
# replication gets into a bad state. | |
# | |
# Assumptions: | |
# - psql is in your path. | |
# - You have your ~/.pgpass set up so that you can log in automatically. | |
export PS1="\u@\h ($(psql -Atc "SELECT CASE WHEN pg_is_in_recovery() THEN 'SLAVE' ELSE 'MASTER' END")) \w\\$ " | |
# Explanation: | |
# \u expands to your username. | |
# \h expands to the hostname (the host part only, not the FQDN). | |
# \w expands to the working directory. | |
# \\$ expands to # if you're root and $ otherwise. | |
# $(psql...) expands to the result of that command, i.e. MASTER or SLAVE. | |
# All else is literal. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment