question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

colored prompt and commands executed

See original GitHub issue

it would be nice, to have colors for the pgcli prompt available like the psql command has.

for example, this is my prompt in psqlrc which looks more appealing.

\set PROMPT1 '%[%33[%0;33m%] 🐘 %`date +"%H:%M:%S"` %[%33[%0;34m%]» %[%33[%0;31m%]%n%[%33[%0;33m%]@%[%33[%0;36m%]%M:%> %[%33[%0;35m%]%x%# %[%33[%0;0m%]'
\set PROMPT2 '%[%33[%0;33m%] 🐘 %R » %[%33[%0;0m%]'

the % allows you to pass vt color codes thrugh with the %[ %] syntax and even better, with

%`date`

you can execute commands, which results in a nice colored prompt with the current time.

can we have this in pgcli too?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
amjithcommented, Mar 29, 2020

You can install directly from the master branch using:

pip install -U https://github.com/dbcli/pgcli/archive/master.zip

Here’s an example of colored prompt in the config:

prompt = '\x1b[35m\u@\x1b[32m\h:\x1b[36m\d>'

\x1b[ followed by the color code. 35m for purple, 32m for green and 36m for cyan.

This is what the prompt looks like:

image

0reactions
rightawaycommented, Mar 29, 2020

It’s not working for me in that version, the characters from the code above just appear as they are. Could you give an example of a couple of different colors in your prompt and I can try that in mine to see if it works?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Color cmd command - GeeksforGeeks
Type the command – color /? in the Command Prompt. It sets the default console foreground and background colors.
Read more >
BASH Shell Change The Color of Shell Prompt on Linux or UNIX
This page explains how to set up or change the color of bash shell prompt by editing $PS1 variable on a Linux, *BSD,...
Read more >
Bash/Prompt customization - ArchWiki
Prompts. Bash has four prompt strings that can be customized: PS0 is displayed after each command, before any output.
Read more >
Coloured commands in terminal prompt - macos - Super User
Coloured commands in terminal prompt ... This way I get the /working/directory $ in bold red, but I also want to get the...
Read more >
Dynamic Bash Command Prompt Highlighting - Bianchini Love
This post goes over how to add dynamic command prompt coloring to your bash shell and discusses a few ways to customize your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found