diff options
author | rrueger <rrueger@ethz.ch> | 2020-07-31 16:43:42 +0200 |
---|---|---|
committer | rrueger <rrueger@ethz.ch> | 2020-07-31 16:43:42 +0200 |
commit | 9f548489f878dfd114d8d2ae6a45886dbffbbebe (patch) | |
tree | 06fa76353c8de7be780e7baa1e1bbba5516975be /plugin | |
parent | b20c29c906e03bbe483c86013eb3ee5fec4881a4 (diff) | |
download | statusryne-9f548489f878dfd114d8d2ae6a45886dbffbbebe.tar.gz statusryne-9f548489f878dfd114d8d2ae6a45886dbffbbebe.tar.bz2 statusryne-9f548489f878dfd114d8d2ae6a45886dbffbbebe.zip |
Do not use regex to parse command output for buffer statistics
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/statusryne.vim | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/plugin/statusryne.vim b/plugin/statusryne.vim index 6e84966..4c915fc 100644 --- a/plugin/statusryne.vim +++ b/plugin/statusryne.vim @@ -145,20 +145,15 @@ function! FileStats() " endfor " Using system utils - let size_cmd = 'du -sh ' . expand('%:p') - let size = system(size_cmd) - " Parse. - let size_pattern = '^\(\S*\).*$' - let size = substitute(size, size_pattern, '\1', '') + let size_cmd = 'du -shL ' . expand('%:p') . ' | cut -f1' + let word_count_cmd = 'wc -w < ' . expand('%:p') + let char_count_cmd = 'wc -m < ' . expand('%:p') - " Word and character count. - let counts_cmd = 'wc -mw ' . expand('%:p') - let counts = system(counts_cmd) - " Parse. - let counts_pattern = '^\s*\([0-9]*\)\s*\([0-9]*\).*$' - let counts = substitute(counts, counts_pattern, '\1(w) \2(c)', '') + let size = system(size_cmd) + let word_count = system(word_count_cmd) . '(w) ' + let char_count = system(char_count_cmd) . '(c) ' - let stats = counts . ' ' . size + let stats = word_count . char_cound . size endif |