suptrio.blogg.se

Pmenu ctermfg
Pmenu ctermfg










pmenu ctermfg

I remember attending a C and UNIX programming class at an AT&T facility in the early eighties when neither vi nor Emacs was readily available, nor were any of the clever editors that many of you cited. I’m a goofy old geek that is now retired, so I can occasionally do useful things, but I can also experiment. In conclusion, psql is awesome, but psql with Vim integration is awesome-er.Set statusline+=%3*\ %l\ of\ %L\ %2*\ line\Īutocmd colorscheme * hi clear cursorline vimrcpg, and add the following lines:įinally, set the PAGER environment variable before running psql:Īnd, voila! Check out the super cool color highlighting from the obviously very useful “test” table I just created! Next, create a custom Vim configuration for the results that uses the syntax highlighting. The color definitions I’m using here expect a 256 color capable terminal, those with less will have to fiddle with the ctermfg values. Syn region Heading start=/^ \l/ end=/\+$/ Put the following super hacky syntax highlight definitions in that file: If those folders don’t exist in your home directory, create them. Create a file called “dbout.vim” and put it in ~/.vim/syntax. Set the correct PAGER value before starting psql.įirst up, the syntax highlighting. create a custom Vim config to be used when displaying results and 3. Setup a custom Vim syntax file to make the results all pretty 2. There are 3 steps to gluing this all together: 1. This defines what program will be used to display results that don’t fit in the available terminal screen real-estate. Like the EDITOR environment variable, psql respects the PAGER variable. This is yet another place we can dollop Vim awesome-sauce into psql. In the course of developing said complex SQL statements, I’m running oodles of queries and analyzing the results. Now I can seamlessly use Vim from psql to develop complex SQL statements. vimrc file should do the trick (presuming psql is using /tmp like it does on Debian):Īu BufRead /tmp/psql.edit.* set syntax=sql The only other trick here is to make sure Vim knows that you are editing a query so we get fancy-pants syntax highlighting. bashrc file so ANY program respecting the EDITOR variable will use Vim by default, because of course I do. Just set that to “vim” before starting psql. You can control the editor with the EDITOR environment variable. When exiting the editor, the updated query will be re-run. Psql provides a command, “\e”, that will start an editor with the last query pre-loaded.

#PMENU CTERMFG FULL#

So cool! Editing Queries With Vimīeing able to jump around the CLI is nice, but when you are building a complicated query, it’s better to have a full featured editing environment. Now you can navigate the Psql command line with some Vim-like shortcuts via a limited command mode accessed with ESC. Just create the file if it does not exist, and add the following: set editing-mode vi Support for vi key-binding is provided by the readline or libedit library, so enabling this in psql can be done using the. This is like “set -o vi” in bash, but for psql.

pmenu ctermfg pmenu ctermfg

That other client might have similar features, but thankfully I don’t work with that anymore and have all but forgotten it existed at all. Psql has some interesting options we can use to bring the Vim goodness. In this way it’s similar to the mysql command line interface for that other RDMS you may have heard of. Type an SQL statement, get an ASCII formatted result. It’s a powerful, if somewhat boring, interface to the DB. Psql is the command line client for Postgres. Instead, I’m writing about how you can spice up your psql environment with Vim, since I just did that last week, and kind of sort of remember how I did it. I was going to write a post about all the Vim tips and tricks I have consumed over the years, but that information lives almost exclusively in muscle memory, which requires too much effort to extract. If I’m typing something and it requires more than 4 words, I do it in Vim. I use it to develop software, write blog posts, analyze and manipulate raw data, even compose E-mail.












Pmenu ctermfg