How to Change the Command Line Prompt in SQLite

If you’ve ever used the SQLite command line shell, you’re probably familiar with the default command line prompt. Actually, there are two prompts:

  • The default main prompt looks like this: sqlite>
  • The default continuation prompt looks like this: ...>

If you don’t like these prompts, you can always change them with the .prompt dot command.

This article provides a quick demonstration on how to change these prompts.

Example

Here’s an example that demonstrates changing both prompts.

.prompt "Fire Away: " "More? "

The first argument is for the main prompt. The second argument is for the continuation prompt.

Now, when I enter new commands, I’ll see the new prompts:

sqlite> .prompt "Fire Away: " "More? "
Fire Away: SELECT * 
More? FROM Dogs
More? WHERE DogId = 3
More? ;

Note that the prompts will be reset whenever you open a new connection to SQLite. However, you can change this by saving your settings in a .sqliterc file.

Save your Settings

To save your settings so that you always get your preferred prompts in future SQLite CLI sessions, simply enter your .prompt command into a file, then save that file as .sqliterc in your home directory.

So, here it is with the previous command:

.prompt "Fire Away: " "More? "

I can save that as .sqliterc in my home directory.

Now, whenever I connect using the SQLite CLI, I see the new prompts.

Only Change the Main Prompt

You can also use one argument to change the main prompt:

.prompt "Go: "

Entering this will change the main prompt, but the continuation prompt will remain the same.

Remove All Prompts

If you don’t want any prompts to be displayed, you can specify the empty string:

.prompt "" ""