.zshrc
#{{{ ZSH Modules
autoload -U compinit promptinit zcalc zsh-mime-setup
autoload -U colors && colors
autoload -Uz vcs_info
compinit
promptinit
zsh-mime-setup
#}}}
#{{{ Options
# See `man zshoptions`
setopt CORRECT
setopt GLOB_COMPLETE
setopt RM_STAR_WAIT
setopt ZLE
setopt VI
setopt NO_HUP
setopt IGNORE_EOF
setopt NO_BEEP
setopt NUMERIC_GLOB_SORT
setopt EXTENDED_GLOB
setopt RC_EXPAND_PARAM
setopt APPEND_HISTORY
setopt COMPLETE_IN_WORD
setopt prompt_subst
setopt nohashdirs
setopt nohashcmds
unsetopt FLOW_CONTROL
unsetopt LIST_AMBIGUOUS
# History options
setopt EXTENDED_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_REDUCE_BLANKS
setopt HIST_IGNORE_SPACE
setopt HIST_NO_STORE
setopt HIST_VERIFY
setopt HIST_SAVE_NO_DUPS
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_FIND_NO_DUPS
#}}}
#{{{ Variables
export EDITOR=vim
export PAGER=less
export JAVA_HOME="/usr"
export _JAVA_AWT_WM_NONREPARENTING=1
export KEYTIMEOUT=1 # Reduce vi-mode lag
export ANDROID_HOME="/opt/android-sdk"
export ANDROID_SWT="/usr/share/java"
export ANDROID_TOOLS="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"
export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/opencascade/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:$ANDROID_TOOLS"
declare -U path
# History
HISTFILE=~/.history
SAVEHIST=1000
HISTSIZE=1000
#}}}
#{{{ Aliases
alias x='startx'
alias p='ping 8.8.8.8'
alias ls='ls --color'
alias vi='/usr/bin/vim'
alias vim='nvim'
alias emacs='emacs -nw'
alias am='alsamixer' alsamixer='alsamixer -g -c 0'
#}}}
#{{{ Completion
# See `man zshcompsys
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*:default' menu 'select=0'
zstyle ':completion:*' file-sort modification reverse
zstyle ':completion:*' list-colors "=(#b) #([0-9]#)*=36=31"
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:corrections' format '%B%d (errors %e)%b'
zstyle ':completion::*:(rm|vi):*' ignore-line true
zstyle ':completion:*' ignore-parents parent pwd
zstyle ':completion::approximate*:*' prefix-needed false
#}}}
#{{{ Key bindings
# Special keys works properly
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '\e[A' up-line-or-history
bindkey '\e[B' down-line-or-history
bindkey '\eOA' up-line-or-history
bindkey '\eOB' down-line-or-history
bindkey '\e[C' forward-char
bindkey '\e[D' backward-char
bindkey '\eOC' forward-char
bindkey '\eOD' backward-char
#}}}
#{{{ Prompt
zstyle ':vcs_info:*' stagedstr '%F{28}^'
zstyle ':vcs_info:*' unstagedstr '%F{11}^'
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{11}%r'
zstyle ':vcs_info:*' enable git svn
precmd()
{
if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]] {
zstyle ':vcs_info:*' formats ' [%F{green}%b%c%u%F{normal}]'
} else {
zstyle ':vcs_info:*' formats ' [%F{green}%b%c%u%F{red}^%F{normal}]'
}
vcs_info
}
PROMPT='%{$fg[blue]%}%B%n%b%{$reset_color%}@%{$fg[magenta]%}%B%M%b%{$reset_color%} %1~ ${vcs_info_msg_0_}%{$reset_color%}%# '
#}}}
#{{{ Vi-mode
# From `oh-my-zsh` vi-mode plugin
# Ensures that $terminfo values are valid and updates editor information when
# the keymap changes.
function zle-keymap-select zle-line-init zle-line-finish {
# The terminal must be in application mode when ZLE is active for $terminfo
# values to be valid.
if (( ${+terminfo[smkx]} )); then
printf '%s' ${terminfo[smkx]}
fi
if (( ${+terminfo[rmkx]} )); then
printf '%s' ${terminfo[rmkx]}
fi
zle reset-prompt
zle -R
}
# Ensure that the prompt is redrawn when the terminal size changes.
TRAPWINCH() {
if [[ -o zle ]]; then
zle reset-prompt
zle -R
fi
}
zle -N zle-line-init
zle -N zle-line-finish
zle -N zle-keymap-select
zle -N edit-command-line
bindkey -v
# Avoid dropping keystrokes after ESC hit
bindkey -as '\e' ''
# allow v to edit the command line
# autoload -Uz edit-command-line
# bindkey -M vicmd 'v' edit-command-line
# allow ctrl-p, ctrl-n, ctrl-r for navigate history (standard behaviour)
bindkey '^P' up-history
bindkey '^N' down-history
bindkey '^r' history-incremental-search-backward
# Incrementar search for / and ?
bindkey -M vicmd "/" history-incremental-search-backward
bindkey -M vicmd "?" history-incremental-search-forward
# allow ctrl-h, ctrl-w, ctrl-? for char and word deletion (standard behaviour)
bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
# Some extra vim like bindings
bindkey -a 'gg' beginning-of-buffer-or-history
bindkey -a 'G' end-of-buffer-or-history
bindkey -a 'u' undo
bindkey -a '^R' redo
# Mode indicator right prompt
function zle-line-init zle-keymap-select
{
RPS1="${${KEYMAP/vicmd/}/(main|viins)/-- INSERT --}"
RPS2=$RPS1
zle reset-prompt
}
# Allow Copy/Paste with the system clipboard
# behave as expected with vim commands ( y/p/d/c/s )
[[ -n $DISPLAY ]] && (( $+commands[xclip] )) && {
function cutbuffer() {
zle .$WIDGET
echo $CUTBUFFER | xclip -selection clipboard
}
zle_cut_widgets=(
vi-backward-delete-char
vi-change
vi-change-eol
vi-change-whole-line
vi-delete
vi-delete-char
vi-kill-eol
vi-substitute
vi-yank
vi-yank-eol
)
for widget in $zle_cut_widgets
do
zle -N $widget cutbuffer
done
function putbuffer() {
zle copy-region-as-kill "$(xclip -selection clipboard -o)"
zle .$WIDGET
}
zle_put_widgets=(
vi-put-after
vi-put-before
)
for widget in $zle_put_widgets
do
zle -N $widget putbuffer
done
}
#}}}
#{{{ Misc
# Deactivate Software flow control
stty -ixon
# Set proper terminal for SCREEN and TMUX
if [[ -z $TMUX ]]; then
if [ -e /usr/share/terminfo/x/xterm+256color ]; then
export TERM='xterm-256color'
else
export TERM='xterm'
fi
else
if [ -e /usr/share/terminfo/s/screen-256color ]; then
# export TERM='screen-256color'
export TERM='xterm-256color'
else
export TERM='screen'
fi
fi
# Autorun TMUX (Only when X11 is running)
# if [[ (-e /tmp/.X0-lock) ]]; then
# if [[ -n $TMUX ]]; then
# # Tmux running, do nothing
# else
# tmux -2
# fi
# fi
#}}}
#{{{ First Init
# Auto start X11 and Wifi connection
if [[ ! (-e /tmp/.X0-lock) ]]; then
# ~/.wifi.sh
./.ether.sh
startx
fi
#}}}
# vim:fdm=marker
.nvimrc
"{{{ VIM-PLUG
call plug#begin('~/.vim/plugged')
Plug 'wellle/targets.vim'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-repeat'
Plug 'michaeljsmith/vim-indent-object'
Plug 'scrooloose/syntastic'
Plug 'scrooloose/nerdtree'
Plug 'vim-scripts/taglist.vim'
Plug 'kien/ctrlp.vim'
Plug 'thanthese/Tortoise-Typing'
Plug 'mbbill/undotree'
Plug 'alx741/vinfo'
Plug 'godlygeek/tabular'
Plug 'bruno-/vim-man'
Plug 'altercation/vim-colors-solarized'
Plug 'junegunn/goyo.vim'
Plug 'jceb/vim-orgmode'
Plug 'EinfachToll/DidYouMean'
Plug 'tommcdo/vim-exchange'
Plug 'vitalk/vim-simple-todo'
Plug 'powerman/vim-plugin-viewdoc'
" On-demand loading
Plug 'scrooloose/syntastic', { 'on': 'SyntasticCheck' }
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'vim-scripts/taglist.vim', { 'on': 'TlistToggle' }
Plug 'thanthese/Tortoise-Typing', { 'on': 'TortoiseTyping' }
Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' }
Plug 'alx741/vinfo', { 'on': 'Vinfo' }
Plug 'godlygeek/tabular', { 'on': 'Tabularize' }
Plug 'bruno-/vim-man', { 'on': 'Man' }
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' }
call plug#end()
"}}}
"{{{ Auto Commands
" Reset format options when filetypes are loaded
autocmd FileType * set formatoptions=tcrql
" Trigger StyleMarks
autocmd VimEnter,BufWinEnter,BufWinLeave * call StyleMarks()
"}}}
"{{{ Maps
" Get raid of vim 'exclusivity' madness
" All movements are now inclusive
" onoremap h vh
" onoremap l vl
" onoremap b vb
" onoremap B vB
" onoremap F vF
" onoremap T vT
" onoremap ^ v^
" onoremap g^ vg^
" onoremap + v+
" onoremap g+ vg+
" onoremap ( v(
" onoremap ` v`
" Move with visual lines
nnoremap j gj
nnoremap k gk
nnoremap J gJ
nnoremap 0 g0
nnoremap ^ g^
nnoremap $ g$
" Search for visual selected area
vnoremap // y/<C-R>"<CR>
" Terminal mode leaving
tnoremap <esc> <C-\><C-n>
" Toggle folds
nnoremap <space> za
" Remove highlights using escape (this prevent using especial keys mappings!)
nnoremap <silent><esc> :noh<CR><esc>
"""" LEADER mappings
" Remove trailing white spaces ( \w )
map <silent><leader>f :call Format() <CR>
" Toggle spelling ( \s )
nnoremap <leader>s :call ToggleSpell() <cr>
" Trigger TagList plugin ( \t )
nnoremap <leader>t :TlistToggle <cr>
" Trigger UndoTree plugin ( \u )
nnoremap <leader>u :UndotreeToggle <cr>
" Trigger NerdTree plugin ( \n )
nnoremap <leader>n :NERDTreeToggle <cr>
" Trigger Ctags program for the current directory
nnoremap <silent><leader>c :!ctags -R . <cr>
"}}}
"{{{ Options and Configurations
" Status line
set statusline=[%n]\ %t\ [%{strlen(&fenc)?&fenc:'none'},\ %{&ff}]
set statusline+=\ [ft=%Y]\ %r\ %m
set statusline+=%=%c:%l/%L\ %P
" Color scheme
colors solarized
" Set various options
syntax on
syntax spell toplevel
set t_CO=16
set lazyredraw
set textwidth=80
set linebreak
set timeoutlen=1000 ttimeoutlen=0
" set cursorline
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
set showcmd
set completeopt-=preview
set completeopt+=longest
set number
set showmatch
set hlsearch
set incsearch
set ignorecase
set smartcase
set backspace=2
set autoindent
set cindent
set ruler
set autoread
set nojoinspaces
set background=light
set wrapscan
set laststatus=2
set wildmenu
set wildmode=longest,list,full
set wildignore=*.o,*.class
set hidden
set foldenable
set foldmethod=syntax
set foldnestmax=2
set foldlevel=3
let c_no_comment_fold=1
" Formatting options:
" * Auto wrap text using textwidth
" * Auto wrap comments using textwidth
" * Auto insert comment leader while inserting
" * Auto formatting of paragraphs
" * Don't auto brake lines
set formatoptions=tcrql
" Config the backup system
set backup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set backupskip=/tmp/*,/private/tmp/*
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set writebackup
"}}}
"{{{ Plugins configuration
" Syntastic
let $PYTHONPATH='/usr/lib/python3.4/site-packages'
let g:syntastic_mode_map = {
\ 'mode' : 'passive',
\ 'active_filetypes' : [],
\ 'passive_filetypes' : [] }
" Targets
" let g:targets_aiAI = 'aIAi'
"}}}
"{{{ Misc
" Set SDCC paths
set path+=/usr/share/sdcc/include/pic14,/usr/share/sdcc/include/pic16
set path+=/usr/share/sdcc/non-free/include/pic14,/usr/share/sdcc/non-free/include/pic16
" Sudo Write
command W w !sudo tee % >/dev/null
"}}}
"{{{ Personal functions
" Help files tags jump
" [g , ]g
nmap [g <Plug>unimpairedHelpTagPrevious
nmap ]g <Plug>unimpairedHelpTagNext
nnoremap <silent> <Plug>unimpairedHelpTagPrevious :call <SID>HelpTag(1)<CR>
nnoremap <silent> <Plug>unimpairedHelpTagNext :call <SID>HelpTag(0)<CR>
function! s:HelpTag(reverse)
call search('|\S\+|', a:reverse ? 'bW' : 'W')
endfunction
" Format document
"
" * Removes trailing white spaces
" * Removes blank lines at the end of the file
" * Replaces tabs with spaces
" * Re-Indent
"
" * If: C, CPP, PHP or JAVA code: format using 'astyle'
" * Style: allman
" * Braces in the first column
" * Spaces between operators
"
" * Leaves 'formatprg' option clean so `gq` can be used with the default
" behavior
function! Format()
silent! execute 'norm! mz'
if &ft ==? 'c' || &ft ==? 'cpp' || &ft ==? 'php'
set formatprg=astyle\ --mode=c\ --style=allman\ -j\ -p\ -f\ -xe\ -xC80\ -H
silent! execute 'norm! gggqG'
elseif &ft ==? 'java'
set formatprg=astyle\ --mode=java\ --style=allman\ -j\ -p\ -f\ -xe\ -xC80\ -H
silent! execute 'norm! gggqG'
endif
silent! execute '%s/\s\+$//ge'
silent! execute 'g/\v^$\n*%$/norm! dd'
silent! execute 'retab'
silent! execute 'gg=G'
silent! execute 'norm! `z'
set formatprg=
endfunction
" Alternate between { NOSPELL, EN, ES } spelling
function! ToggleSpell()
if &spell ==? 0
set spelllang=en
set spell
echom "Spell [EN]"
elseif &spell ==? 1
if &spelllang ==? 'en'
set spelllang=es
echom "Spell [ES]"
elseif &spelllang ==? 'es'
set spelllang=en
set nospell
echom "NO Spell"
endif
endif
endfunction
" Marks over length lines and trailing white spaces as errors
function! StyleMarks()
highlight OverLength ctermbg=blue ctermfg=white
call matchadd('OverLength', '\%81v.\+', 100)
highlight Trailing ctermbg=blue ctermfg=white
call matchadd('Trailing', '\s\+$', 100)
highlight Debugme ctermbg=red ctermfg=white
call matchadd('Debugme', 'debugme', 100)
call matchadd('Debugme', 'DEBUGME', 100)
endfunction
"}}}
" vim:fdm=marker
.tmux.conf
# Set the current working directory based on the current pane's current
# working directory (if set; if not, use the pane's starting directory)
# when creating # new windows and splits.
bind-key c new-window -c '#{pane_current_path}'
bind-key '"' split-window -c '#{pane_current_path}'
bind-key % split-window -h -c '#{pane_current_path}'
# use UTF8
set -g utf8
set-window-option -g utf8 on
# Index start from 1 (insted of 0)
set -g base-index 1
set -g status-keys vi
set -g history-limit 10000
setw -g mode-keys vi
setw -g mode-mouse off
# make tmux display things in 256 colors
set -g default-terminal "screen-256color"
# set scrollback history to 10000 (10k)
set -g history-limit 10000
# set Ctrl-s as the default prefix key combination
# and unbind C-b to free it up
set -g prefix C-s
unbind C-b
# use send-prefix to pass C-a through to application
bind C-s send-prefix
# shorten command delay
set -sg escape-time 1
# map Vi movement keys as pane movement keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# map Vi selectio/copy keys
bind-key -t vi-copy 'v' begin-selection # Begin selection in copy mode.
bind-key -t vi-copy 'C-v' rectangle-toggle # Begin selection in copy mode.
bind-key -t vi-copy 'y' copy-selection # Yank selection in copy mode
# resize panes using PREFIX H, J, K, L
bind-key H resize-pane -L 5
bind-key J resize-pane -D 5
bind-key K resize-pane -U 5
bind-key L resize-pane -R 5
#### COLOR (Solarized light)
#
## default statusbar colors
set-option -g status-bg white #base2
set-option -g status-fg yellow #yellow
set-option -g status-attr default
#
## default window title colors
set-window-option -g window-status-fg brightyellow #base00
set-window-option -g window-status-bg default
##set-window-option -g window-status-attr dim
#
## active window title colors
set-window-option -g window-status-current-fg brightred #orange
set-window-option -g window-status-current-bg default
##set-window-option -g window-status-current-attr bright
#
## pane border
set-option -g pane-border-fg white #base2
set-option -g pane-active-border-fg brightcyan #base1
#
## message text
set-option -g message-bg white #base2
set-option -g message-fg brightred #orange
#
## pane number display
set-option -g display-panes-active-colour blue #blue
set-option -g display-panes-colour brightred #orange
#
## clock
set-window-option -g clock-mode-colour green #green
# ----------------------
# Status Bar
# -----------------------
set -g status-right '#(~/.tmuxbar.sh)'
set-option -g status on # turn the status bar on
set -g status-utf8 on # set utf-8 for the status bar
set -g status-interval 15 # set update frequency (default 15 seconds)
set -g status-justify centre # center window list for clarity
# set-option -g status off # Hide tmux bar by default
bind-key a set -g status # Toggle tmux bar visibility
# set-option -g status-position top # position the status bar at top of screen
# visual notification of activity in other windows
# setw -g monitor-activity on
# set -g visual-activity on
#######################
# Tmux Plugin manager
#######################
# List of plugins
# Supports `github_username/repo` or full git repo URLs
set -g @tpm_plugins ' \
tmux-plugins/tpm \
tmux-plugins/tmux-sensible \
tmux-plugins/tmux-resurrect \
tmux-plugins/tmux-yank \
'
# Other examples:
# github_username/plugin_name \
# git@github.com/user/plugin \
# git@bitbucket.com/user/plugin \
# Initializes TMUX plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell '~/.tmux/plugins/tpm/tpm'
.ratpoisonrc
#{{{ Bindigs
# Escape
escape C-g
# Abort with ESC
bind Escape abort
# Only window
unbind q
bind o only
# Start graphical terminal emulator instance
bind c exec gnome-terminal
# Give temporally control to DWM
bind W tmpwm dwm
# Close current window
bind Q delete
unbind C-k
# Vi keys
bind j focusdown
bind h focusleft
bind k focusup
bind l focusright
bind J exchangedown
bind H exchangeleft
bind K exchangeup
bind L exchangeright
# Vi splits
unbind S
bind s vsplit
bind v hsplit
#}}}
# Banish the mouse pointer in every window change
addhook key banish
# Put cursor where it was previously
warp on
# Don't convert cursor in a box while waiting commands
set waitcursor 0
# Messages config
msgwait 2
startup_message off
set fgcolor black
set bgcolor papaya whip
# More informative date and time
bind a exec ratpoison -c "echo $( acpi -b | awk '{ print $3, $4 }' | tr -d ',' ) || $( date "+%F %r" )"
# If there is more than 1 screen, give focus to the second one
nextscreen
# vim:fdm=marker
Me han fascinado muchos ficheros de configuracion, buen post. Saludos cordiales desde Ecuador!