Эх сурвалжийг харах

Merge branch 'master' of ssh://master/home/manu/public_git/kolter-dotfiles

Emmanuel Bouthenot 12 жил өмнө
parent
commit
7f074c9670

+ 6 - 0
.gitmodules

@@ -13,3 +13,9 @@
 [submodule ".vim/bundle/taglist"]
 	path = .vim/bundle/taglist
 	url = git://github.com/vim-scripts/taglist.vim.git
+[submodule ".vim/bundle/syntastic"]
+	path = .vim/bundle/syntastic
+	url = git://github.com/scrooloose/syntastic.git
+[submodule ".vim/bundle/ctrlp"]
+	path = .vim/bundle/ctrlp
+	url = git://github.com/kien/ctrlp.vim.git

+ 1 - 0
.tmux.conf

@@ -12,6 +12,7 @@
 # terminal type, history size, env
 #
 set -g default-terminal "screen-256color"
+set -g xterm-keys on
 set -g history-limit 102400
 set -g update-environment "DISPLAY WINDOWID SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION"
 #set -g terminal-overrides 'xterm*:smcup@:rmcup@'

+ 1 - 0
.vim/bundle/ctrlp

@@ -0,0 +1 @@
+Subproject commit 6ddbfe2cc00a7eeb2a4450552b78276488a2e2c9

+ 1 - 0
.vim/bundle/syntastic

@@ -0,0 +1 @@
+Subproject commit e5dfcc3488e407c8e28b308cb6e631336e77d060

+ 0 - 93
.vim/plugin/phplint.vim

@@ -1,93 +0,0 @@
-"
-" script downloaded from https://github.com/Jonty/phplint.vim/raw/master/phplint.vim
-"
-
-" Check we actually have PHP installed, otherwise you'll never be able to save
-if !exists("loadedPHPLint") && executable('php')
-    let loadedPHPLint = 1
-else
-    finish
-endif
-
-
-" To disable auto-lint, add "let noAutoLint = 1" to your .vimrc
-if !exists("noAutoLint")
-    autocmd BufWriteCmd *.php execute('call AutoLintPHPFile()')
-endif
-
-function AutoLintPHPFile()
-    if LintPHPFile()
-        " We have to handle the write op ourselves, as we overrode it
-        noautocmd w
-    endif
-endf
-
-
-" Allow manual linting with :Phplint
-command! PHPLint call LintPHPFile()
-
-function LintPHPFile()
-    if &filetype != 'php'
-        return 1
-    endif
-
-    let thisFile = expand("%")
-
-    " If the file isn't writable don't do anything, as it'll freak vim out
-    if filewritable(thisFile)
-        let testFile = tempname()
-
-        " This resets the view to the top, so we need to restore it
-        let view = winsaveview()
-        let bufferContents = getbufline(bufnr("%"), 1, "$")
-        exe writefile(bufferContents, testFile)
-        call winrestview(view)
-
-        " Check the test file got written, this might fail if the disk is 
-        " full and prevent you from saving. Which would be bad.
-        if filereadable(testFile)
-            let phpLint = system('php -l ' . testFile)
-            let phpLint = substitute(phpLint, testFile, thisFile, "g")
-            call delete(testFile)
-
-            let errLine = matchstr(phpLint, 'No syntax errors')
-            if strlen(errLine) > 0
-                cclose
-                redraw " Avoids the annoying 'Press ENTER to BLAH' message
-                return 1
-
-            else
-                let lintLines = split(phpLint, "\n")
-
-                let errorLines = []
-                for line in lintLines
-                    let pos = matchstr(line, 'on line')
-                    if strlen(pos) > 0 && stridx(line, 'PHP') != 0 " Some versions dupe the error
-                        call add(errorLines, line)
-                    endif
-                endfor
-
-                let cFile = tempname()
-                exe writefile(errorLines, cFile)
-
-                let oldCpoptions = &cpoptions
-                let oldErrorformat = &errorformat
-
-                set cpoptions-=F
-                set errorformat=%m\ in\ %f\ on\ line\ %l
-
-                exe "cfile " . cFile
-                copen 5
-                call delete(cFile)
-
-                let &cpoptions = oldCpoptions
-                let &errorformat = oldErrorformat
-
-                return 0
-
-            endif
-        endif
-    endif
-
-    return 1
-endf

+ 66 - 28
.vim/vimrc

@@ -11,6 +11,15 @@
 "
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
+"Term settings (under tmux)
+if &term =~ '^screen'
+    "tmux will send xterm-style keys when its xterm-keys option is on
+    execute "set <xUp>=\e[1;*A"
+    execute "set <xDown>=\e[1;*B"
+    execute "set <xRight>=\e[1;*C"
+    execute "set <xLeft>=\e[1;*D"
+endif
+
 set nocompatible "no vi compatibility
 set history=200 "command history size
 set undolevels=120 "undo levels count
@@ -76,45 +85,43 @@ set modelines=3 "number of lines to check for modelines
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 " keep ctrl-a/ctrl-e for begining/end of line
-nmap <C-a> <C-o>I
-imap <C-a> <C-o>I
-vmap <C-a> <C-o>I
+nmap <c-a> <c-o>I
+imap <c-a> <c-o>I
+vmap <c-a> <c-o>I
 
-nmap <C-e> <C-o>A
-imap <C-e> <C-o>A
-vmap <C-e> <C-o>A
+nmap <c-e> <c-o>A
+imap <c-e> <c-o>A
+vmap <c-e> <c-o>A
 
 "reopen current file
-map <F5> :e!<CR>
+map <F5> :e!<cr>
 "using redraw to disable highlighted search patterns
-nnoremap <C-L> :nohl<CR><C-L>
+nnoremap <c-L> :nohl<cr><c-L>
 
 "map F1 to open previous buffer
-nmap <F1> :bp<CR>
-imap <F1> <ESC>:bp<CR>a
+nmap <F1> :bp<cr>
+imap <F1> <ESC>:bp<cr>a
 "map F2 to open next buffer
-nmap <F2> :bn<CR>
-imap <F2> <ESC>:bn<CR>a
+nmap <F2> :bn<cr>
+imap <F2> <ESC>:bn<cr>a
 
-"imap <C-Space> <C-X><C-O> "smart completion
-nmap <C-u> :u<CR>
-imap <C-u> <ESC>:u<CR>
+imap <c-@> <c-x><c-o>
 
-nmap <C-i> :tabnext<CR>
-"nmap <C-S-i> :tabprevious<CR>
-nmap <C-t> :tabnew<CR>
-"nmap <C-M-w> :tabclose<CR>
+nmap <c-s-left> :tabprevious<cr>
+nmap <c-s-right> :tabnext<cr>
+nmap <c-s-up> :tabnew<cr>
+nmap <c-s-down> :tabclose<cr>
 
-nmap <C-q> :call CleanClose()<CR>
+nmap <c-x> :bw<cr>
 
-nmap <F6> :vsplit<CR>
-nmap <F7> :split<CR>
+nmap <F6> :vsplit<cr>
+nmap <F7> :split<cr>
 
-"ctrl-$arrow no cycle around splitted windows
-map <C-left> <C-W>h
-map <C-right> <C-W>l
-map <C-Up> <C-W>k
-map <C-Down> <C-W>j
+"ctrl-$arrow to cycle around splitted windows
+map <c-left> <c-w>h
+map <c-right> <c-w>l
+map <c-Up> <c-w>k
+map <c-Down> <c-w>j
 
 "ident in visual mode keep selection
 vmap > >gv
@@ -294,7 +301,7 @@ endif
 
 
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" Gundo Setup
+" Gundo extension Setup
 "
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
@@ -313,3 +320,34 @@ let g:gundo_close_on_revert = 1
 
 " F3 key to show/hide Gundo sidebar
 nnoremap <F3> :GundoToggle<CR>
+
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Syntastic extension Setup
+"
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+" automatically open/close pane when errors (or not)
+let g:syntastic_auto_loc_list = 1
+" Redefine errors/warning symbols on sidebar
+let g:syntastic_error_symbol = 'EE'
+let g:syntastic_style_error_symbol = 'ee'
+let g:syntastic_warning_symbol = 'WW'
+let g:syntastic_style_warning_symbol = 'Ws'
+" redefine default python linter
+"let g:syntastic_python_checker = 'pylint'
+" add options to python linter
+"let g:syntastic_python_checker_args = ''
+
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" CtrlP extension Setup
+"
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+" Change default key
+let g:ctrlp_map = '<c-o>'
+" Match window height
+let g:ctrlp_max_height = 20
+" Add a key to search in opened buffers
+map <c-b> :CtrlPBuffer<cr>

+ 85 - 28
.zsh.d/config.d/prompt.zsh

@@ -6,53 +6,105 @@ setopt prompt_subst
 
 # enable colors
 autoload colors zsh/terminfo
-if [[ "$terminfo[colors]" -ge 8 ]]; then
+if [ "$terminfo[colors]" -ge 8 ]; then
     colors
 fi
-for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
+for color in RED GREEN YELLOW BLUE MAGENTA CYAN ORANGE WHITE; do
     eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
     eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
 done
 PR_NO_COLOR="%{$terminfo[sgr0]%}"
 
 export PR_OS_NAME=$(uname -s)
-export PR_OS_ARCH=$(uname -m)
 
 if [ -f /etc/debian_version ]; then
-    PR_OS_NAME="$(lsb_release -is)/$(lsb_release -cs)"
+    if which lsb_release >/dev/null 2>&1 ; then
+        PR_OS_NAME="${PR_BLUE}$(lsb_release -is)${PR_WHITE}/${PR_BLUE}$(lsb_release -cs)"
+    fi
     if [ -f /etc/debian_chroot ]; then
-        PR_OS_NAME="${PR_LIGHT_RED}chroot:${PR_WHITE}${PR_OS_NAME}"
+        PR_OS_NAME="${PR_RED}chroot${PR_WHITE}(${PR_OS_NAME}${PR_WHITE} ${PR_MAGENTA}$(uname -m)${PR_WHITE})"
     fi
 fi
-PR_OS_NAME="${PR_OS_NAME} ${PR_OS_ARCH}"
 
-if [ -n "$SSH_CLIENT" ]; then
-    export PR_OS_SSH="${PR_LIGHT_RED}ssh:"
+if [ -n "${SSH_CLIENT}" ]; then
+    export PR_OS_SSH=" via ${PR_LIGHT_RED}ssh"
 else
     export PR_OS_SSH=
 fi
 
-if [ "$UID" = 0 ]; then
-    export PR_ROOT_PREFIX='*'
-else
-    export PR_ROOT_PREFIX=
-fi
+pr_battery_level() {
+    if command -v acpi >/dev/null 2>&1 ; then
+        acpi --battery 2>/dev/null | sed -r 's/^Battery .*, ([0-9]*)%.*$/\1/'
+    fi
+}
 
-function mytitle {
-    # if running 'xterm like' terminal setting directory name in title bar
-    if [ "$TERM" = "xterm" ]; then
-        echo -ne "\033]0;${PR_ROOT_PREFIX}${1}\007"
+pr_battery() {
+    local battery_level=
+    local level=$(pr_battery_level)
+    if [ -n "$level" ] ; then
+        if [ "$level" -gt 60 ] ; then
+            local bat_color="${PR_GREEN}"
+        elif [ "$level" -gt 25 ] ; then
+            local bat_color="${PR_YELLOW}"
+        else
+            local bat_color="${PR_RED}"
+        fi
+        battery_level="${PR_WHITE}⌁${bat_color}${level}${PR_WHITE}%%"
     fi
+    echo -n "${battery_level}"
+}
+
+pr_git_branch() {
+    if command -v git >/dev/null 2>&1 ; then
+        git branch 2>/dev/null | sed -n 's/^\* //p'
+    fi
+}
+
+pr_git_prompt() {
+    local git_prompt=
+    local branch=$(pr_git_branch)
+    if [ -n "$branch" ] ; then
+        local modified=$(git diff --name-only | wc -l)
+        local cached=$(git diff --cached --name-only | wc -l)
+        git_prompt="${PR_YELLOW}${branch}${PR_NO_COLOR}"
+        if [ "$modified" -gt 0 ]; then
+            git_prompt="${git_prompt} ${PR_RED}${modified}${PR_NO_COLOR}⇆"
+        fi
+        if [ "$cached" -gt 0 ]; then
+            git_prompt="${git_prompt} ${PR_LIGHT_GREEN}${cached}${PR_NO_COLOR}⇆"
+        fi
+        local commits=$(git rev-list --no-merges --count origin/${branch}..${branch} 2>/dev/null)
+        if [ "$commits" -gt 0 ]; then
+            git_prompt="${git_prompt} ${PR_MAGENTA}${commits}${PR_NO_COLOR}↑"
+        fi
+        git_prompt="${PR_WHITE} on ${git_prompt}"
+    fi
+    echo -n "${git_prompt}"
 }
 
 function preexec {
-    local -a buffer
-    buffer=(${=1})
-    mytitle "$buffer[1]"
+    # get the command basename
+    local cmd=${1##*\/}
+    if [ -n "${SSH_CLIENT}" ]; then
+        cmd="%n@%M: ${cmd}"
+    fi
+    if [ -n "$TMUX" ]; then
+        print -Pn "\ek%-3 ${cmd}\e"
+    else
+        print -Pn "\e]0;${cmd}\a"
+    fi
 }
 
 function precmd {
-    mytitle "$(print -P %~)"
+    local cmd="%~"
+    if [ -n "${SSH_CLIENT}" ]; then
+        cmd="%n@%M: ${cmd}"
+    fi
+    if [ -n "$TMUX" ]; then
+        print -Pn "\ek%-3 ${cmd}\e"
+    else
+        print -Pn "\e]0;${cmd}\a"
+    fi
 }
 
 myprompt() {
@@ -60,13 +112,18 @@ myprompt() {
         PROMPT="-(%n@%m)-(%(!.%d.%~))->"
     else
         PROMPT='\
-${PR_BLUE}\
-%1(j.-(${PR_YELLOW}jobs:${PR_WHITE}%j${PR_BLUE}).)\
-${PR_BLUE}-(\
-%(!.${PR_RED}%n.${PR_LIGHT_GREEN}%n)\
-${PR_WHITE}@${PR_OS_SSH}${PR_MAGENTA}%m${PR_WHITE} ${PR_OS_PTY}${PR_BLUE})-(\
-${PR_WHITE}${PR_OS_NAME}${PR_BLUE})-(${PR_WHITE}%(!.%d.%~)${PR_BLUE})
-%0(?..${PR_RED}ret:${PR_WHITE}%?${PR_BLUE})>${PR_NO_COLOR}'
+ %(!.${PR_RED}%n.${PR_LIGHT_GREEN}%n)\
+${PR_WHITE} at \
+${PR_MAGENTA}%m\
+${PR_WHITE}${PR_OS_SSH}\
+${PR_WHITE} in \
+${PR_GREEN}%(!.%d.%~)\
+$(pr_git_prompt)\
+%1(j.${PR_WHITE} with ${PR_LIGHT_GREEN}%j${PR_WHITE} jobs.)\
+${PR_WHITE} using ${PR_OS_NAME}
+%0(?..${PR_RED}%?)\
+%(!.${PR_LIGHT_RED}.${PR_LIGHT_CYAN})>${PR_NO_COLOR}'
+    RPROMPT='$(pr_battery)'
     fi
 }