Created
September 18, 2008 20:39
-
-
Save jonuts/11479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Author : Jonas Kramer | |
" Copyright : Copyright (C) 2008 by Jonas Kramer. Published under the terms | |
" of the GNU General Public License (GPL). | |
" Name Of File : shell-fm.vim | |
" Description : Provide | |
" Maintainer : Jonas Kramer (jkramer at nex dot scrapping dot cc) | |
" Last Changed : 2008-07-12 | |
" Version : 0.01 | |
" Usage : Save this file in your plugin directory. Requires 'socat' to | |
" be installed. | |
let g:socat = "/usr/bin/socat" | |
fu! ShellFMCommand(command) | |
if(!exists("g:shellsocket")) | |
ec "You have to set g:shellsocket to the path of your shell-fm UNIX domain socket." | |
retu | |
en | |
if(!filewritable(g:shellsocket)) | |
ec "Can't read UNIX socket. Is shell-fm running after all?" | |
retu | |
en | |
let shellcommand = shellescape(a:command) | |
let command = "silent !".g:socat." UNIX-CONNECT:".g:shellsocket." - <<<".shellcommand | |
redi @Z | |
sil! exe command | |
return @Z | |
endf | |
fu! ShellFMSkip() | |
cal ShellFMCommand("skip") | |
endf | |
fu! ShellFMLove() | |
cal ShellFMCommand("love") | |
endf | |
fu! ShellFMHate() | |
cal ShellFMCommand("ban") | |
endf | |
fu! ShellFMPlay() | |
let s:station = input('URL: ') | |
cal ShellFMCommand("play lastfm://".s:station) | |
endf | |
fu! ShellFMPause() | |
cal ShellFMCommand("pause") | |
endf | |
fu! ShellFMFormat(format) | |
let s:formatted = ShellFMCommand("info ".a:format) | |
echo s:formatted | |
endf | |
fu! ShellFMNowPlaying() | |
exe "!cat ".g:shellnp | |
endf | |
nnoremap <Leader>sn :call ShellFMSkip()<CR> | |
nnoremap <Leader>sl :call ShellFMLove()<CR> | |
nnoremap <Leader>sb :call ShellFMHate()<CR> | |
nnoremap <Leader>sp :call ShellFMPlay()<CR> | |
nnoremap <Leader>sP :call ShellFMPause()<CR> | |
nnoremap <Leader>sN :call ShellFMNowPlaying()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment