#!/bin/bash msg() { echo >&2 -e "${1-}" } die() { local msg=$1 local code=${2-1} # default exit status 1 msg "$msg" exit "$code" } confirm() { # call with a prompt string or use a default read -r -p "${1:-Are you sure? [y/N]} " response case "$response" in [yY][eE][sS]|[yY]) true ;; *) die "Aborted execution." ;; esac } FILE=~/.vimrc if test -f "$FILE"; then msg "$FILE exists already. Continuing execution will override the file." confirm fi cat <>~/.vimrc " Don't try to be vi compatible set nocompatible " Turn on syntax highlighting syntax on " Enable global undo set undofile set undodir=~/.vim/undodir " Blink cursor on error instead of beeping (grr) set visualbell set vb t_vb= " Encoding set encoding=utf-8 " Rendering set ttyfast " Last line set showmode set showcmd set ruler " display cursor position in last line " Searching nnoremap / /\v vnoremap / /\v set hlsearch set incsearch set ignorecase set smartcase set showmatch map :let @/='' " clear search " Tabs map t :tabnew map [ :tabprevious map ] :tabnext " Markdown map md :set syntax=markdown " No banner for file listing let g:netrw_banner = 0 EOF msg "Successfully written to $FILE."