Wikia

Vim Tips Wiki

Changes: Find VIMRUNTIME in a bash script

Edit

Back to page

(Move categories to tip template)
(Remove html character entities)
 
Line 15: Line 15:
   
 
<pre>
 
<pre>
vim --cmd 'echo $VIMRUNTIME' --cmd 'quit' 2&gt; /tmp/VIMRUNTIME.txt
+
vim --cmd 'echo $VIMRUNTIME' --cmd 'quit' 2> /tmp/VIMRUNTIME.txt
 
VIMRUNTIME=`perl -pe 's/\r\n//g' /tmp/VIMRUNTIME.txt`
 
VIMRUNTIME=`perl -pe 's/\r\n//g' /tmp/VIMRUNTIME.txt`
 
rm -f /tmp/VIMRUNTIME.txt
 
rm -f /tmp/VIMRUNTIME.txt
Line 21: Line 21:
   
 
<pre>
 
<pre>
VIMRUNTIME=`vim -e -T dumb --cmd 'exe "set t_cm=\&lt;C-M&gt;"|echo $VIMRUNTIME|quit' | tr -d '\015' `
+
VIMRUNTIME=`vim -e -T dumb --cmd 'exe "set t_cm=\<C-M>"|echo $VIMRUNTIME|quit' | tr -d '\015' `
 
</pre>
 
</pre>
   
Line 27: Line 27:
   
 
==Comments==
 
==Comments==
 
----
 

Latest revision as of 09:19, September 29, 2008

Tip 745 Printable Monobook Previous Next

created June 15, 2004 · complexity advanced · author Steve Hall · version 6.0


I recently needed the value of $VIMRUNTIME in a bash shell script and was forwarded these two terrific solutions that may be of use to others.

vim --cmd 'echo $VIMRUNTIME' --cmd 'quit' 2> /tmp/VIMRUNTIME.txt
VIMRUNTIME=`perl -pe 's/\r\n//g' /tmp/VIMRUNTIME.txt`
rm -f /tmp/VIMRUNTIME.txt
VIMRUNTIME=`vim -e -T dumb --cmd 'exe "set t_cm=\<C-M>"|echo $VIMRUNTIME|quit' | tr -d '\015' `

Both properly capture Vim's output and handle the trailing line feed, although in remarkably different ways.

CommentsEdit

Around Wikia's network

Random Wiki