Free tools Windows power users keep installed
One-click scans. No signup required.
You can customize every prompt that the psql terminal client displays by editing a startup file and assigning values to PROMPT1, PROMPT2, and PROMPT3. A practical starting point is set PROMPT1 '%n@%/%R%# ', which shows the connected user, database, input state, and a privilege-sensitive prompt character. Add host, port, transaction, version, or carefully wrapped ANSI color codes only when that context helps you avoid mistakes.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
This guide explains the file locations, prompt substitutions, multiline behavior, color-safe syntax, version-specific configuration, and recovery procedure for a broken startup file.
As an Amazon Associate I earn from qualifying purchases.
What the psqlrc file does
psql reads startup configuration before it begins accepting your normal commands. The system-wide psqlrc is read first, followed by your personal startup file. The personal file is read after the connection is established and before normal commands run. Prompt definitions placed there therefore become your defaults every time that client starts.
Using a startup file is preferable to retyping set commands in every session. It also makes your prompt reproducible: the same user/database indicator, transaction marker, and multiline behavior appear whenever that configuration is loaded.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
Bypass the file for one session
Pass -X when starting psql to bypass startup files. This is the quickest way to determine whether an error or an unreadable prompt is caused by your configuration rather than by the server or terminal.
psql -X
A session started with -X uses the client without the system-wide or personal startup customizations. Once you have corrected the file, start psql normally again.
Where to put psqlrc
The filename and default location depend on the operating system. You can also point psql at another file with the PSQLRC environment variable.
| Environment | Default personal file | When to use it |
|---|---|---|
| Unix-like systems | ~/.psqlrc |
The normal per-user configuration for Linux, macOS, and other Unix-like systems. |
| Windows | %APPDATA%postgresqlpsqlrc.conf |
The per-user configuration read by the Windows client. |
| Any supported platform | Path supplied through PSQLRC |
Useful when you keep separate dotfiles, use a managed profile, or need a temporary configuration. |
| Version-specific client configuration | ~/.psqlrc-16 or ~/.psqlrc-16.15 |
Isolates settings for a major version or an exact client release. |
Version-specific names are useful when you maintain more than one psql client. A setting that is appropriate for one client version will not silently become the default for every other version when each version has its own file.
Create or edit the Unix-like file
- Open
~/.psqlrcin your preferred text editor. Create it if it does not exist. - Add one or more
setlines, keeping the prompt value inside single quotes. - Save the file and start a new
psqlsession. Startup files are read when the client starts, so an already-running session will not automatically reload edits.
Create or edit the Windows file
- Open
%APPDATA%postgresqlpsqlrc.confin a text editor. Create thepostgresqldirectory first if it is absent. - Add the same
set PROMPT1,set PROMPT2, andset PROMPT3lines used on Unix-like systems. - Restart
psqlto test the change. If you choose a different file, setPSQLRCto its full path before launching the client.
Set the three prompt variables
psql has three prompt variables, each for a different input state:
Rank #2
- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
| Variable | Displayed when | Example role |
|---|---|---|
PROMPT1 |
You are entering a normal command. | Show the user, database, input state, and privilege marker. |
PROMPT2 |
The current statement is incomplete. | Make it obvious that psql is waiting for more input. |
PROMPT3 |
You are entering data for COPY FROM STDIN. |
Use a short, unmistakable data-entry marker. |
Put all three definitions in the startup file so a long statement or a copy operation does not unexpectedly fall back to an unhelpful default.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteset PROMPT1 '%n@%/%R%# '
set PROMPT2 '%w%R%# '
set PROMPT3 '>> '
In this baseline:
%ndisplays the connected database user.%/displays the current database name.%Rdisplays an input-state indicator.%#displays a privilege-sensitive prompt character.%winserts whitespace matching the visible width of the latestPROMPT1.
The aligned PROMPT2 keeps continuation input under the command text instead of starting at an unrelated column. The final space in each ordinary prompt is intentional: it separates the marker from the SQL you type.
Understand the prompt substitutions
Prompt substitutions are interpreted by psql when it renders the prompt. Choose only the information that helps you identify where a command will run.
| Substitution | What it shows | Practical use |
|---|---|---|
%n |
Connected database user | Distinguishes roles when you use more than one login. |
%/ |
Database name | Prevents running a command in the wrong database. |
%R |
Input-state indicator | Shows normal input or why a statement is waiting for completion. |
%# |
Privilege-sensitive prompt character | Provides a visual distinction based on the connected role’s privileges. |
%M |
Full host name | Identifies the complete server host when several environments are open. |
%m |
Truncated host name | Adds server context without making the line as wide as the full name. |
%p |
Server port | Separates installations that use different ports. |
%x |
Transaction status | Highlights whether a transaction is active or otherwise has a notable state. |
%l |
Statement line number | Helps orient you while entering a multiline statement. |
%:name: |
Value of a psql variable named name |
Includes a value you have defined in the client session. |
%% |
A literal percent sign | Prints % instead of starting a substitution. |
| Backtick command substitution | Output from a command substitution | Adds dynamic context, but can make a prompt slower or harder to scan if overused. |
Start with user and database. Add host, port, or transaction state only when those distinctions prevent an actual error. A prompt that fills the entire terminal width can be less useful than a short prompt whose important fields are immediately visible.
A compact context-rich prompt
set PROMPT1 '%n@%M:%p/%R%# '
set PROMPT2 '%w%R%# '
set PROMPT3 '>> '
This places the user before the host and port, then the database and state marker. The full host is explicit, while the continuation prompt retains the width of the first prompt.
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
A shorter remote-session prompt
set PROMPT1 '%n@%m/%R%# '
set PROMPT2 '%w%R%# '
set PROMPT3 '>> '
Use %m when the full host name is too wide but a truncated host still differentiates your environments.
Make incomplete statements easy to diagnose
PROMPT2 is not merely a second copy of PROMPT1. The %R substitution changes to indicate why psql is waiting. Depending on what you have typed, it can identify an unterminated command, block comment, quoted string or identifier, dollar-quoted string, or unmatched parenthesis.
For example, after entering a statement that has not yet received its terminating semicolon, the continuation prompt tells you that the client is still collecting input. If you accidentally leave a quote or parenthesis open, the state indicator gives you a clue instead of making the new line look like an ordinary prompt.
set PROMPT1 '%n@%/%R%# '
set PROMPT2 '%w%R%# '
set PROMPT3 '>> '
Do not replace PROMPT2 with a fixed symbol if you rely on these diagnostics. A plain ... is shorter, but it hides the distinction between different incomplete-input states.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Keep COPY input unmistakable with PROMPT3
When you run COPY ... FROM STDIN, psql switches to its data-entry prompt. Set PROMPT3 to a marker that cannot be confused with a normal SQL prompt:
Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
set PROMPT3 '>> '
In the PROMPT3 state, %R produces no text, so adding it does not provide the same incomplete-command information it does in PROMPT1 or PROMPT2. A concise marker makes it clear that lines are being treated as copy data until the copy terminator is entered.
Add ANSI color without breaking Readline
Color can make a production connection stand out, but terminal control bytes are not visible characters. GNU Readline and similar line editors must be told which parts occupy no screen columns; otherwise the cursor can jump to the wrong position, and editing a long command becomes unreliable.
Wrap non-printing ANSI sequences in %[ and %]. PostgreSQL’s documented bold yellow-on-black example is:
Recommended Free Tools
set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '
The first sequence enables bold yellow text on a black background. The second resets terminal attributes before the privilege marker and the SQL input. The %[ and %] delimiters tell Readline not to count those bytes as visible prompt width.
What the colored example displays
- The user, database, and input-state portion is colored.
- The reset sequence returns the terminal to its normal attributes.
- The visible prompt character remains outside the colored span.
- Readline receives accurate width information for cursor movement and editing.
Color depends on a terminal that supports the ANSI sequences. If the result is unreadable, remove the color codes first and verify the plain prompt. A plain prompt is preferable to a colored prompt that causes cursor misalignment.
Best Value
Choose a prompt design by trade-off
| Design | Information density | Readability | Multiline behavior | Portability |
|---|---|---|---|---|
| User and database only | Low; shows the two most important identity fields. | Highest in narrow terminals. | Good when paired with a state-aware PROMPT2. |
Works across Unix-like systems and Windows. |
| User, database, host, and port | High; separates remote and local servers. | Can become wide with long host names. | Good if %w%R%# is retained in PROMPT2. |
Uses documented substitutions available to the client. |
| Plain text with transaction state | Medium; adds session context without terminal control codes. | Consistent in logs and basic terminals. | Preserves diagnostic %R markers. |
Most portable because it needs no ANSI support. |
| ANSI-colored prompt | Whatever fields you include, with visual emphasis. | Fast to scan when colors are supported and correctly wrapped. | Requires matching non-printing delimiters in each colored prompt. | Depends on terminal color support and correct Readline handling. |
There is no benefit in displaying every available substitution at once. Pick a prompt that answers your immediate question—who am I connected as, where am I connected, and am I in a transaction—without making SQL editing cumbersome.
Use version-specific files safely
A shared ~/.psqlrc is convenient when all your clients should behave identically. Separate files such as ~/.psqlrc-16 or ~/.psqlrc-16.15 are safer when you need to isolate client settings by major version or exact release.
When isolation helps
- You are testing a new client while retaining an older client for established workflows.
- You want to change escape sequences or defaults for one release without changing another.
- You maintain a dotfile repository that is deployed to several machines with different PostgreSQL client versions.
Keep the version suffix tied to the client version you intend to run, and test each file with that client. This prevents assumptions about prompt behavior from leaking into sessions that use another version.
Test changes incrementally
- Start with
PROMPT1,PROMPT2, andPROMPT3from the baseline example. - Open a new
psqlsession and confirm the user, database, and prompt character are correct. - Enter an intentionally incomplete statement, such as an opening parenthesis or quote, and check that
PROMPT2appears with a useful state indicator. - Run a small
COPY FROM STDINoperation when appropriate for your workflow and confirm thatPROMPT3is visibly different. - Add one optional substitution—host, port, transaction status, or line number—then restart and verify its output.
- Add color last. If editing becomes erratic, remove the color layer and return to the last working plain-text version.
Changing one element at a time makes a malformed quote, unsupported escape, or incorrect color delimiter easy to locate.
Troubleshoot a broken or confusing prompt
| Symptom | Likely cause | Recovery |
|---|---|---|
psql reports an error while starting. |
A syntax error in the startup file, often an unmatched quote or malformed set line. |
Start with psql -X, edit the file, and restore the smallest known-good prompt definitions before adding options again. |
| The old prompt remains after editing. | The current client was started before the file was changed, or a different file is being read. | Exit and restart psql; then verify the platform path, PSQLRC, and any version-specific filename. |
| The continuation prompt is far to the left or right. | PROMPT2 does not use the width-matching %w substitution, or visible and non-visible characters are miscounted. |
Use set PROMPT2 '%w%R%# '. If color is present, wrap every non-printing sequence in %[ and %]. |
| Cursor movement breaks after adding color. | Readline is counting ANSI control bytes as visible characters. | Restore the plain prompt, then add the documented delimiters around the color sequences. |
| You cannot tell whether input is SQL or COPY data. | PROMPT3 is identical to a normal prompt or too subtle to notice. |
Set it to a short marker such as >> and keep it visually distinct. |
| The prompt is too wide to scan. | Too many substitutions, a full host name, or command substitution make each line noisy. | Remove optional fields, use %m instead of %M, and reserve dynamic substitutions for information you actually use. |
Complete configurations to copy
Minimal, portable configuration
set PROMPT1 '%n@%/%R%# '
set PROMPT2 '%w%R%# '
set PROMPT3 '>> '
This is the best starting point when you work across operating systems or terminal types. It provides identity, database, input state, privilege marker, aligned continuation lines, and a distinct COPY prompt without terminal-specific color.
Remote-environment configuration
set PROMPT1 '%n@%M:%p/%R%# '
set PROMPT2 '%w%R%# '
set PROMPT3 '>> '
Use this when the host and port are essential to distinguish servers. Replace %M with %m if full host names make the prompt too long.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallColor-highlighted configuration
set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '
set PROMPT2 '%w%R%# '
set PROMPT3 '>> '
This follows the documented ANSI pattern. Keep the continuation and COPY prompts plain unless you have a specific reason to color them; fewer control sequences mean fewer opportunities for width and readability problems.
Quick Recap
A practical checklist
- Use
~/.psqlrcon Unix-like systems or%APPDATA%postgresqlpsqlrc.confon Windows. - Set all three variables:
PROMPT1,PROMPT2, andPROMPT3. - Include
%Rwhere you want input-state diagnostics. - Include
%winPROMPT2to align continuation input withPROMPT1. - Add host, port, transaction, line, or version context only when it improves a real decision.
- Wrap ANSI control bytes in
%[and%]so Readline counts visible width correctly. - Use
psql -Xto recover from a startup error and test fixes incrementally. - Consider version-specific files when multiple client versions share the same machine.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




