Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save SQLite settings such as mode, headers and width so they persist

Tags:

sqlite

Everytime I start SQLite, I have to re-turn on headers, re-switch to column mode, re-change the separator and/or width. How can I make the settings persist??

Repeated Code

.mode column
.headers on
.separator ','

In other words, how can I save the settings so that next time I run SQLite, my preferences are automatically applied.

like image 572
Govind Rai Avatar asked Feb 27 '17 06:02

Govind Rai


2 Answers

Create a .sqliterc file in your home directory

Ah, finally stumbled upon the answer. You can create a .sqliterc (SQLite Run Commands file) in your home directory. Every time you run sqlite, it will load the settings from the rc file.

Here's a quick command line script you can paste in the terminal for some basic settings (edit it to add additional preferences):

cat << EOF > ~/.sqliterc
.headers on
.mode column
EOF
like image 148
Govind Rai Avatar answered Sep 30 '22 07:09

Govind Rai


There are alternative command line options. Something like this:

alias mysqlite='sqlite3 -column -header -separator ,'

like image 24
cshu Avatar answered Sep 30 '22 05:09

cshu