More screen magic, now with povray
The goal: hit F5 to rerender scene.
The line in .vimrc:
nmap <F5> :update<CR>:call system("screen -X stuff 'clear; povray ".@%."; open $(basename ".@%." .pov).png; open ".@%."; \n'")<CR>
And how it works:
-
nmap <F5>to set shortcut key -
:update<CR>to save the current file -
:call system("screen -X stuff '...'")<CR>This combination makes a call to the system (a terminal). That call runs thescreen -X stuff '...'command, which inserts'...'into the current screen session. - Looking at the
"..."piece by piece: -
clearclears the terminal -
povray ".@%."feeds the current file into the povray command-line utility.%is the current file.@%accesses the current file. The"‘s escape from the string, and the.is concatenation. -
open $(basename ".@%." .pov).pngOpens (refreshes the view of) the new.png.basenameis a function that strips a filename’s extension.$()evaluations an expression in bash. -
open ".@%."Opens the file back up in vim — serves to return focus to the file I’m editing. -
\nenter, makes the command go
The result of all this trickery is ease. I hit F5, and all my windows auto-update — terminal, image viewer, and vim. The only thing left to do is locate some artistic talent.
No comments yet