4

I'm trying to add a new terminal Postgres shell (psql) to the Windows Terminal. I want to add it to the profiles list in the settings.

This is the windows terminal.

windows terminal

In the settings file, we can add a list of profiles. In that list, I have Windows PowerShell, Command prompt, and Azure Cloud Shell.

How do I add psql shell on that list?

    {
          "guid": "{some guid}",
          "hidden": false,
          "name": "SQL Shell (psql)",
          "source": ?
    }

I looked up various articles on this, but none of them has a working solution.

Can anyone help me with this?

nicks101
  • 1,065
  • 11
  • 20
  • Sorry, what exactly do you mean with "add to Windows Terminal"? Can't you just run `psql` from within a command line window (`cmd.exe`)? –  Aug 05 '20 at 07:05
  • I'll elaborate on my question. – nicks101 Aug 05 '20 at 10:56
  • What about `"source": "psql.exe"` (I have never used this, so I'm just guessing) –  Aug 05 '20 at 11:12
  • I tried, not working. I think we need to specify the whole path maybe. – nicks101 Aug 05 '20 at 15:43
  • You can generate a guid pretty easily, just search for it in google. Then you will need to give it a name and specify the path, more than likely it will be the WHOLE path. You may also just want to change the installation location of the psql shell or make a copy, throw that in the same place as cmd and powershell. – Zach Pedigo Aug 11 '20 at 14:55

2 Answers2

9

I somehow figured it out! The profile settings are:

{
    "commandline" : "\"%PROGRAMFILES%\\PostgreSQL\\12\\scripts\\runpsql.bat\" -i -l",
    "hidden": false,
    "name": "PostgreSQL",
    "icon" : "PostgreSQL.png*",
    "background" : "#1b364d",
    "cursorShape" : "vintage"
}

I also searched for the guid for some time, and then I remembered that I had added Git Bash to Windows Terminal. So I copied that executable, replaced the value with psql batch file address, and voilà!

*PostgreSQL.png

  • 1
    Why not use `psql.exe` directly? –  Aug 27 '20 at 09:35
  • what was the reason for using `-i -l` in `"commandline" :` path ? I run it without them just: "commandline" : "C:/Program Files/PostgreSQL/14/scripts/runpsql.bat", – Paweł Pedryc Jul 05 '22 at 01:57
2

you can get the guid down below if you want, i got it from here: https://www.postgresql.org/docs/8.3/datatype-uuid.html

"guid": "{a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11}",
"name" : "SQL psql",
"commandline": "%PROGRAMFILES%/PostgreSQL/13/scripts/runpsql.bat -i -l",
"hidden": false,
"icon": "%SystemDrive%/PROGRA~1/PostgreSQL/13/scripts/images/pg-psql.ico",
General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • Would anyone know why I'm getting prompted to set up a username and db when I launch the SQL shell this way? I'm afraid to enter anything because I already have a dB and admin users. – andres Oct 27 '20 at 22:39