Skip to content

Instantly share code, notes, and snippets.

@neninja
Created March 14, 2020 16:10
Show Gist options
  • Save neninja/49cb2b86ef9e790e2778721e4af7cd77 to your computer and use it in GitHub Desktop.
Save neninja/49cb2b86ef9e790e2778721e4af7cd77 to your computer and use it in GitHub Desktop.
instalador de pacotes/dotfiles feito em vim [cancelado]
set nocompatible " evita erro de E10: \ should be followed by /, ? or &
let g:dotfilesDir = $HOME . "/dev/dotfiles/"
let g:dotfiles = [
\ {
\ "input": "zathura/zathurarc",
\ "output": $HOME . "/.config/zathura"
\ },
\ {
\ "input": "bash/.bash_profile",
\ "output": $HOME . "/.config/bashrc"
\ }
\ ]
let g:reposClone = [
\ {
\ "path": $HOME . "/.vim",
\ "remote": "https://github.com/nenitf/pack.git"
\ }
\ ]
function s:MKDir(...)
if isdirectory(a:1)
return
endif
return mkdir(a:1, 'p')
endfunction
function s:CopyDotfile(arquivoInicial, arquivoFinal)
" acessa arquivo (existindo ou não) para escrever seu conteúdo
exec "e " . a:arquivoFinal
" cria diretório caso não exista
call s:MKDir(expand("%:h"))
" apaga conteúdo do arquivo
normal dG
" lê informações do fonte
exec "0r " . a:arquivoInicial
" salva
w
endfunction
function InstallDotfiles()
if !exists("*mkdir")
echoe "Incompatibilidade do vim com o script"
call input('Press any key to continue')
return
endif
for config in g:dotfiles
echo config.output
call s:CopyDotfile(g:dotfilesDir . config.input, config.output)
endfor
echom "Script de copy dos dotfiles finalizado"
call input('Press any key to continue')
endfunction
function GitClones()
for repo in g:reposClone
exec "term ++close ++curwin git -C ". repo.path . " clone --recurse-submodules " . repo.remote
endfor
qa
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment