Skip to content

Commit

Permalink
totally cow
Browse files Browse the repository at this point in the history
  • Loading branch information
mklabs committed May 8, 2012
0 parents commit e836a9e
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 0 deletions.
37 changes: 37 additions & 0 deletions doc/cowsay.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
*cowsay.txt*

hmmmmmmm, just vim saying cowsay


|cowsay-intro| Introduction
|cowsay-Installation| Installation
|cowsay-commands| Commands


Introduction *cowsay-intro*

Blah, Blah, Blah.

Installation *cowsay-installation*

If you don't have a preferred installation method, I recommend
installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
then simply copy and paste:

>
cd ~/.vim/bundle
git clone git://github.com/mklabs/vim-cowsay.git
<

Once help tags have been generated, you can view the manual with `:help cowsay`.


Commands *cowsay-commands*

Blah, Blah, Blah.




vim:tw=78:ts=8:ft=help:norl:

4 changes: 4 additions & 0 deletions doc/tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cowsay-commands cowsay.txt /*cowsay-commands*
cowsay-installation cowsay.txt /*cowsay-installation*
cowsay-intro cowsay.txt /*cowsay-intro*
cowsay.txt cowsay.txt /*cowsay.txt*
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"author": "mklabs",
"name": "cowsay",
"description": "hmmmmmmm, just vim saying cowsay",
"version": "0.1.0",
"repository": {
"url": "git://github.com/mklabs/vim-cowsay.git"
},
"dependencies": {},
"devDependencies": {}
}

101 changes: 101 additions & 0 deletions plugin/cowsay.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
" cowsay.vim - just vim saying cowsay
" Maintainer: mklabs

" _____________
" < Cowsay.vim >
" -------------
" \ ^__^
" \ (oo)\_______
" (__)\ )\/\
" ||----w |
" || ||
"

if exists("g:loaded_cowsay") || v:version < 700 || &cp
finish
endif
let g:loaded_cowsay = 1

" _________
" < Utility >
" ---------
" \ ^__^
" \ (oo)\_______
" (__)\ )\/\
" ||----w |
" || ||

function! s:error(str)
echohl ErrorMsg
echo '... '. a:str . ' ...'
echohl None
endfunction

" _________________________________________
" / ## Commands \
" | |
" | Commands below accepts arguments or |
" | visual range. |
" | |
" | ### :Cowsay |
" | |
" | Output the cow, a simple echo. |
" | |
" | ### :Cow |
" | |
" | Same as ':Cowsay', expect that it |
" | replaces the selected lines (if used in |
" | visual mode) or append what the cow |
" | said below the cursor. |
" | |
" | ### :CowComment |
" | |
" | Same as ':CowComment', expect that it |
" | also triggers :TComment if is |
" \ installed. /
" -----------------------------------------
" \ ^__^
" \ (oo)\_______
" (__)\ )\/\
" ||----w |
" || ||

function! s:Cow(args, ...)
if !executable('cowsay')
return s:error('cowsay is not installed')
endif

if a:args != ""
let lines = a:args
else
let lines = join(getline(a:1, a:2), "\n")
endif

let cow = system('cowsay', lines)
return cow
endfunction

function! s:CowSay(args, ...)
let cow = s:Cow(a:args, a:1, a:2)
echo cow
endfunction

function! s:CowInsert(args, ...)
let cow = s:Cow(a:args, a:1, a:2)
let lines = split(cow, "\n")
let oldlines = getline(a:2, a:2 + len(lines))
call setline(a:1, lines + oldlines)
return lines
endfunction

function! s:CowComment(args, ...)
let lines = s:CowInsert(a:args, a:1, a:2)
if exists("g:loaded_tcomment")
let end = a:1 + len(lines)
call tcomment#Comment(a:1, end)
endif
endfunction

command! -nargs=* -range Cowsay call s:CowSay(<q-args>, <line1>, <line2>)
command! -nargs=* -range Cow call s:CowInsert(<q-args>, <line1>, <line2>)
command! -nargs=* -range CowComment call s:CowComment(<q-args>, <line1>, <line2>)
115 changes: 115 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@

cowsay.vim
==============

**just vim saying cowsay**

```
____________________
< Vimmmmmmeuuuuuuuuh >
--------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

cowsay.vim is a simple wrapper to [cowsay](http://www.nog.net/~tony/warez/cowsay.shtml)

Right now, cowsay.vim is pretty dumb. But it does it very well.

Commands
--------


## Commands

Commands below accepts arguments or visual range.

### :Cowsay

Output the cow, a simple echo.

```
:Cowsay Wait what!?
_____________
< Wait what!? >
-------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

### :Cow

Same as ':Cowsay', expect that it replaces the selected lines (if used in
visual mode) or append what the cow said below the cursor.

Assume you're writing this fancy readme, and that you have the two
paragraph here starting at line 48 and ending at line 52. Running
`:48,52Cow` should replace the specified lines by...:

```
:48,52Cow
_________________________________________
/ Same as ':Cowsay', expect that it \
| replaces the selected lines (if used in |
| visual mode) or append what the cow |
| said below the cursor. |
| |
| Assume you're writing this fancy |
| readme, and that you have the two |
| paragraph here starting at line 48 and |
\ ending at line 52. /
-----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```

Visual range works too!


### :CowComment

Same as ':Cow', expect that it also triggers :TComment if is
installed.


Install
-------

Just drop this vim script in one of your runtime path, `~/.vim/plugin/`
maybe. Or if you use pathogen you might want to bundle it as a pathogen
module,

```sh
cd ~/.vim/bundle
git clone <gistcloneturl> cowsay.vim
cd cowsay.vim
mkdir plugin && mv cowsay.vim plugin/
```
Make sure to have cowsay installed and available in your path.

If not, simply copy and paste:

```sh
curl -o cowsay-3.03.tar.gz http://www.nog.net/~tony/warez/cowsay-3.03.tar.gz
tar xvzf cowsay-3.03.tar.gz
rm cowsay-3.03.tar.gz
cd cowsay-3.03/
./install.sh
rm -rf cowsay-3.03/
```

License & Acknowledgement
-------------------------

License: Same as Vim. See `:help license`.


0 comments on commit e836a9e

Please sign in to comment.