[ADD] conf for archlinux, <init>
[arrow.git] / archlinux_conf / home / .vim / autoload / tlib / cmd.vim
blobd67f06ba00b93fe7154136adbff87db289b89b76
1 " cmd.vim
2 " @Author:      Thomas Link (micathom AT gmail com?subject=[vim])
3 " @Website:     http://www.vim.org/account/profile.php?user_id=4037
4 " @License:     GPL (see http://www.gnu.org/licenses/gpl.txt)
5 " @Created:     2007-08-23.
6 " @Last Change: 2008-03-06.
7 " @Revision:    0.0.20
9 if &cp || exists("loaded_tlib_cmd_autoload")
10     finish
11 endif
12 let loaded_tlib_cmd_autoload = 1
15 function! tlib#cmd#OutputAsList(command) "{{{3
16     " let lines = ''
17     redir => lines
18     silent! exec a:command
19     redir END
20     return split(lines, '\n')
21 endf
24 " See |:TBrowseOutput|.
25 function! tlib#cmd#BrowseOutput(command) "{{{3
26     let list = tlib#cmd#OutputAsList(a:command)
27     let cmd = tlib#input#List('s', 'Output of: '. a:command, list)
28     if !empty(cmd)
29         call feedkeys(':'. cmd)
30     endif
31 endf
34 " :def: function! tlib#cmd#UseVertical(?rx='')
35 " Look at the history whether the command was called with vertical. If 
36 " an rx is provided check first if the last entry in the history matches 
37 " this rx.
38 function! tlib#cmd#UseVertical(...) "{{{3
39     TVarArg ['rx']
40     let h0 = histget(':')
41     let rx0 = '\C\<vert\%[ical]\>\s\+'
42     if !empty(rx)
43         let rx0 .= '.\{-}'.rx
44     endif
45     " TLogVAR h0, rx0
46     return h0 =~ rx0
47 endf
50 " Print the time in seconds a command takes.
51 function! tlib#cmd#Time(cmd) "{{{3
52     let start = localtime()
53     exec a:cmd
54     echom 'Time: '. (localtime() - start) .'s: '. a:cmd
55 endf