Skip to content

Instantly share code, notes, and snippets.

@421p
Last active October 28, 2015 22:50
Show Gist options
  • Save 421p/8722555d3dfa8c15f6cb to your computer and use it in GitHub Desktop.
Save 421p/8722555d3dfa8c15f6cb to your computer and use it in GitHub Desktop.
bash vim_init.sh
#!/bin/bash
function createMakefile(){
echo "all: run
compile:
g++ -std=c++0x 1.cc -o runme
run: compile
./runme" > Makefile;
}
function createSource(){
echo "#include <iostream>
using namespace std;
int main(){
cout << \"Hello Vimer!\n\";
return 0;
}" > 1.cc;
}
function setVimrc(){
echo "
function! ToggleVExplorer()
if exists(\"t:expl_buf_num\")
let expl_win_num = bufwinnr(t:expl_buf_num)
if expl_win_num != -1
let cur_win_nr = winnr()
exec expl_win_num . 'wincmd w'
close
exec cur_win_nr . 'wincmd w'
unlet t:expl_buf_num
else
unlet t:expl_buf_num
endif
else
exec '1wincmd w'
Vexplore
vertical resize 30
let t:expl_buf_num = bufnr(\"%\")
endif
endfunction
map <silent> <C-N> :call ToggleVExplorer()<CR>
set nu
syntax on
colorscheme elflord
set autoread
set wildmenu
set magic
set encoding=utf8
set shiftwidth=4
set tabstop=4
set background=dark
set ruler
set guioptions-=m \"remove menu bar
set guioptions-=T \"remove toolbar
set guioptions-=r \"remove right-hand scroll bar
set guioptions-=L \"remove left-hand scroll bar
let g:netrw_banner = 0
let g:netrw_keepdir = 0
let g:netrw_liststyle = 3
let g:netrw_sort_options = 'i'\"
let g:netrw_browse_split=4 \" Open file in previous buffer
let g:netrw_altv = 1
\" Change directory to the current buffer when opening files.
set autochdir
autocmd VimEnter * if argc() == 0 && !exists(\"s:std_in\") | :call ToggleVExplorer() | endif
" > ~/.vimrc;
}
#по ключу -f форсируем создание файлов без проверок на их наличие
if [ "$1" == "-f" ];
then
createSource;
createMakefile;
setVimrc;
else
#проверяем есть ли мейкфал, если нет - создаем
if test -a "Makefile"
then
echo "Makefile is already exist!";
else
createMakefile;
fi
#проверяем есть ли соус, если нет - создаем
if test -a "1.cc";
then
echo "1.cc is already exist!";
else
createSource;
fi
#а vimrc будем по кд перезапсывать, нам то што)))
setVimrc;
fi
vim 1.cc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment