Add some aliases, leaders, bclose, and a text file to note things to change

This commit is contained in:
Andrew Tomaka 2013-05-09 17:02:25 -04:00
parent d1820370c0
commit e10d778eda
4 changed files with 88 additions and 1 deletions

View file

@ -1,7 +1,9 @@
alias a="ls -la" alias a="ls -la"
alias al="zsh_stats" alias al="zsh_stats"
alias c="clear"
alias ga="git add" alias ga="git add"
alias gaa="git add ." alias gaa="git add ."
alias gcf="git commit -F"
alias gcm="git commit -m" alias gcm="git commit -m"
alias gd="git diff" alias gd="git diff"
alias gl="git log" alias gl="git log"
@ -12,3 +14,4 @@ alias l="ls -lvh --color=auto"
alias s="cd ~/Source" alias s="cd ~/Source"
alias t="tmux" alias t="tmux"
alias v="vim" alias v="vim"
alias x="exit"

78
.vim/plugin/bclose.vim Normal file
View file

@ -0,0 +1,78 @@
" Delete buffer while keeping window layout (don't close buffer's windows).
" Version 2008-11-18 from http://vim.wikia.com/wiki/VimTip165
if v:version < 700 || exists('loaded_bclose') || &cp
finish
endif
let loaded_bclose = 1
if !exists('bclose_multiple')
let bclose_multiple = 1
endif
" Display an error message.
function! s:Warn(msg)
echohl ErrorMsg
echomsg a:msg
echohl NONE
endfunction
" Command ':Bclose' executes ':bd' to delete buffer in current window.
" The window will show the alternate buffer (Ctrl-^) if it exists,
" or the previous buffer (:bp), or a blank buffer if no previous.
" Command ':Bclose!' is the same, but executes ':bd!' (discard changes).
" An optional argument can specify which buffer to close (name or number).
function! s:Bclose(bang, buffer)
if empty(a:buffer)
let btarget = bufnr('%')
elseif a:buffer =~ '^\d\+$'
let btarget = bufnr(str2nr(a:buffer))
else
let btarget = bufnr(a:buffer)
endif
if btarget < 0
call 'bdelete'.a:bang
call s:Warn('No matching buffer for '.a:buffer)
return
endif
if empty(a:bang) && getbufvar(btarget, '&modified')
call s:Warn('No write since last change for buffer '.btarget.' (use :Bclose!)')
return
endif
" Numbers of windows that view target buffer which we will delete.
let wnums = filter(range(1, winnr('$')), 'winbufnr(v:val) == btarget')
if !g:bclose_multiple && len(wnums) > 1
call s:Warn('Buffer is in multiple windows (use ":let bclose_multiple=1")')
return
endif
let wcurrent = winnr()
for w in wnums
execute w.'wincmd w'
let prevbuf = bufnr('#')
if prevbuf > 0 && buflisted(prevbuf) && prevbuf != w
buffer #
else
bprevious
endif
if btarget == bufnr('%')
" Numbers of listed buffers which are not the target to be deleted.
let blisted = filter(range(1, bufnr('$')), 'buflisted(v:val) && v:val != btarget')
" Listed, not target, and not displayed.
let bhidden = filter(copy(blisted), 'bufwinnr(v:val) < 0')
" Take the first buffer, if any (could be more intelligent).
let bjump = (bhidden + blisted + [-1])[0]
if bjump > 0
execute 'buffer '.bjump
else
execute 'enew'.a:bang
endif
endif
endfor
execute 'bdelete'.a:bang.' '.btarget
execute wcurrent.'wincmd w'
endfunction
command! -bang -complete=buffer -nargs=? Bclose call <SID>Bclose('<bang>', '<args>')
" command! -bang -complete=buffer -nargs=? bc call <SID>Bclose('<bang>', '<args>')
nnoremap <silent> <Leader>bd :Bclose<CR>
nnoremap <silent> <Leader>bD :Bclose!<CR>
nnoremap <silent> <Leader>BD :Bclose!<CR>

6
.vimrc
View file

@ -17,6 +17,7 @@ set ffs=unix,dos " File format prefer unix endings
set eol " Add newlien at end of file set eol " Add newlien at end of file
set shellslash " Forward slashes set shellslash " Forward slashes
set nobk " No backup files set nobk " No backup files
set formatoptions=crq
set textwidth=80 set textwidth=80
set laststatus=2 " Always show status line set laststatus=2 " Always show status line
set showmode " Show current mode set showmode " Show current mode
@ -34,6 +35,8 @@ set hls " Highlight search (hlsearch?)
set ruler " Show cursor position set ruler " Show cursor position
set autoindent set autoindent
set number " Show line numbers set number " Show line numbers
set colorcolumn=80 " Ruler at line 80
set nomodeline
" Tabs are 2 spaces " Tabs are 2 spaces
set tabstop=2 set tabstop=2
set softtabstop=2 set softtabstop=2
@ -56,6 +59,7 @@ let mapleader = ","
map <Leader>s :e ~/Source/ map <Leader>s :e ~/Source/
map <Leader>nc :Nyancat<cr> map <Leader>nc :Nyancat<cr>
map <Leader>ts :sp ~/tool-sharpener.txt<cr>
" Set style " Set style
set guifont=Ubuntu\ Mono\ 10 set guifont=Ubuntu\ Mono\ 10
@ -65,4 +69,4 @@ set cursorline
hi CursorLine cterm=NONE ctermbg=234 hi CursorLine cterm=NONE ctermbg=234
highlight StatusLine ctermfg=white ctermbg=236 highlight StatusLine ctermfg=white ctermbg=236
hi SignColumn ctermbg=black hi SignColumn ctermbg=black
hi ColorColumn ctermbg=234

2
tool-sharpener.txt Normal file
View file

@ -0,0 +1,2 @@
* :Bclose leaders
* Alias: gcf => git commit -F