-
-
Save ngdelcastillo/68171e2527d8b002f563f437f6794aea to your computer and use it in GitHub Desktop.
Pragtech Ubuntu Configs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac | |
# don't put duplicate lines or lines starting with space in the history. | |
# See bash(1) for more options | |
HISTCONTROL=ignoreboth | |
# append to the history file, don't overwrite it | |
shopt -s histappend | |
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) | |
HISTSIZE=1000 | |
HISTFILESIZE=2000 | |
# check the window size after each command and, if necessary, | |
# update the values of LINES and COLUMNS. | |
shopt -s checkwinsize | |
# If set, the pattern "**" used in a pathname expansion context will | |
# match all files and zero or more directories and subdirectories. | |
#shopt -s globstar | |
# make less more friendly for non-text input files, see lesspipe(1) | |
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" | |
# set variable identifying the chroot you work in (used in the prompt below) | |
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then | |
debian_chroot=$(cat /etc/debian_chroot) | |
fi | |
# set a fancy prompt (non-color, unless we know we "want" color) | |
case "$TERM" in | |
xterm-color) color_prompt=yes;; | |
esac | |
# uncomment for a colored prompt, if the terminal has the capability; turned | |
# off by default to not distract the user: the focus in a terminal window | |
# should be on the output of commands, not on the prompt | |
#force_color_prompt=yes | |
if [ -n "$force_color_prompt" ]; then | |
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then | |
# We have color support; assume it's compliant with Ecma-48 | |
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such | |
# a case would tend to support setf rather than setaf.) | |
color_prompt=yes | |
else | |
color_prompt= | |
fi | |
fi | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' | |
fi | |
unset color_prompt force_color_prompt | |
# If this is an xterm set the title to user@host:dir | |
case "$TERM" in | |
xterm*|rxvt*) | |
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" | |
;; | |
*) | |
;; | |
esac | |
# enable color support of ls and also add handy aliases | |
if [ -x /usr/bin/dircolors ]; then | |
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" | |
alias ls='ls --color=auto' | |
#alias dir='dir --color=auto' | |
#alias vdir='vdir --color=auto' | |
alias grep='grep --color=auto' | |
alias fgrep='fgrep --color=auto' | |
alias egrep='egrep --color=auto' | |
fi | |
# some more ls aliases | |
alias ll='ls -alF' | |
alias la='ls -A' | |
alias l='ls -CF' | |
# Add an "alert" alias for long running commands. Use like so: | |
# sleep 10; alert | |
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' | |
# Alias definitions. | |
# You may want to put all your additions into a separate file like | |
# ~/.bash_aliases, instead of adding them here directly. | |
# See /usr/share/doc/bash-doc/examples in the bash-doc package. | |
if [ -f ~/.bash_aliases ]; then | |
. ~/.bash_aliases | |
fi | |
# enable programmable completion features (you don't need to enable | |
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile | |
# sources /etc/bash.bashrc). | |
if ! shopt -oq posix; then | |
if [ -f /usr/share/bash-completion/bash_completion ]; then | |
. /usr/share/bash-completion/bash_completion | |
elif [ -f /etc/bash_completion ]; then | |
. /etc/bash_completion | |
fi | |
fi | |
export PATH="$HOME/.rbenv/bin:$PATH" | |
eval "$(rbenv init -)" | |
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH" | |
source ~/.bash-git-prompt/gitprompt.sh | |
# Ruby Aliases | |
alias b="bundle exec" | |
# Git Aliases | |
alias gs="git s" | |
alias go="git checkout " | |
alias ga="git add " | |
alias gp="git push -u origin " | |
alias gl="git pull origin " | |
alias gc="git commit " | |
alias gh="git lg" | |
alias gf="git fetch" | |
alias l="ls -a" | |
### Added by the Heroku Toolbelt | |
export PATH="/usr/local/heroku/bin:$PATH" | |
export NVM_DIR="/home/noel/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Load Pathogen | |
execute pathogen#infect() | |
syntax on | |
filetype plugin indent on | |
" Noel - after pathogen are loaded | |
set nocompatible | |
let mapleader=" " | |
set smartindent | |
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
" set ts=2 | |
color desert | |
set number " Display the line numbers | |
set showcmd | |
set showmode | |
set backspace=indent,eol,start | |
set incsearch " Highlight matches as you type | |
set hlsearch " Highlight matches | |
set wrap " Turn on line wrapping | |
set scrolloff=3 " Show 3 lines around the corner | |
set title " Set the terminal title | |
set visualbell " No beeping | |
set nobackup " Don't make a backup before overwriting a file set nowritebackup "and again | |
set laststatus=2 " Show the status line all the time | |
"" Set encoding | |
set encoding=utf-8 | |
" useful status information at bottom of screen | |
set statusline=[%n]\ %<%.99f\ %h%w%m%r%y\ %{fugitive#statusline()}%{exists('*CapsLockStatusline')?CapsLockStatusline():''}%=%-16(\ %l,%c-%v\ %)%P | |
map :f :find<space> | |
" Remap Esc with jj | |
imap jj <Esc> | |
" Add Save with ss | |
map ss :w<cr> | |
" Map exit | |
map qq :q <cr> | |
" Map the source to leader so | |
map <leader>so :so %<cr> | |
" Map suspend | |
map <leader>z <C-Z> | |
" Tab mappings. | |
map <leader>tt :tabnew<cr> | |
map <leader>te :tabedit | |
map <leader>tc :tabclose<cr> | |
map <leader>to :tabonly<cr> | |
map <leader>tn :tabnext<cr> | |
map <leader>tp :tabprevious<cr> | |
map <leader>tf :tabfirst<cr> | |
map <leader>tl :tablast<cr> | |
map <leader>tm :tabmov | |
set mouse=ia " Enable your track pad interaction | |
set clipboard=unnamedplus | |
vnoremap <C-c> "*y | |
set antialias " Macvim: smooth fonts | |
"set listchars=tab:▸\ | |
" Command-T mappings for rails | |
map <leader>gv :CommandTFlush<cr>\|:CommandT app/views<cr> | |
map <leader>gj :CommandTFlush<cr>\|:CommandT app/assets/javascripts<cr> | |
map <leader>gs :CommandTFlush<cr>\|:CommandT app/assets/stylesheets<cr> | |
map <leader>gc :CommandTFlush<cr>\|:CommandT app/controllers<cr> | |
map <leader>gm :CommandTFlush<cr>\|:CommandT app/models<cr> | |
map <leader>gh :CommandTFlush<cr>\|:CommandT app/helpers<cr> | |
map <leader>gt :CommandTFlush<cr>\|:CommandT spec<cr> | |
map <leader>gf :CommandTFlush<cr>\|:CommandT features<cr> | |
map <leader>gl :CommandTFlush<cr>\|:CommandT lib<cr> | |
map <leader>gp :CommandTFlush<cr>\|:CommandT public<cr> | |
map <leader>gr :vsplit config/routes.rb<cr> | |
map <leader>gg :vsplit Gemfile<cr> | |
map <leader>gl :left :vsplit config/locales/en.yml<cr> | |
map <leader>ge :CommandTFlush<cr>\|:CommandT config<cr> | |
" Map Node commands | |
map <leader>ev :CommandTFlush<cr>\|:CommandT app/views<cr> | |
map <leader>ej :CommandTFlush<cr>\|:CommandT public/js<cr> | |
map <leader>es :CommandTFlush<cr>\|:CommandT public/css<cr> | |
" Map windows | |
map <leader>mv :vsplit <cr> | |
map <leader>ms :split <cr> | |
map <leader>wh <C-W>h <cr> | |
map <leader>wj <C-W>j <cr> | |
map <leader>wk <C-W>k <cr> | |
map <leader>wl <C-W>l <cr> | |
" Open files with <leader>f | |
map <leader>f :CommandTFlush<cr>\|:CommandT<cr> | |
" Mappings to access buffers (don't use "\p" because a | |
" " delay before pressing "p" would accidentally paste). | |
" " \l : list buffers | |
" " \b \f \g : go back/forward/last-used | |
" " \1 \2 \3 : go to buffer 1/2/3 etc | |
nnoremap <Leader>l :ls<CR> | |
nnoremap <Leader>bf :bp<CR> | |
nnoremap <Leader>bn :bn<CR> | |
nnoremap <Leader>g :e#<CR> | |
nnoremap <Leader>1 :1b<CR> | |
nnoremap <Leader>2 :2b<CR> | |
nnoremap <Leader>3 :3b<CR> | |
nnoremap <Leader>4 :4b<CR> | |
nnoremap <Leader>5 :5b<CR> | |
nnoremap <Leader>6 :6b<CR> | |
nnoremap <Leader>7 :7b<CR> | |
nnoremap <Leader>8 :8b<CR> | |
nnoremap <Leader>9 :9b<CR> | |
nnoremap <Leader>0 :10b<CR> | |
" " Opens an edit command with the path of the currently edited file filled | |
" in | |
" " Normal mode: <Leader>e | |
map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR> | |
map <Leader>w :w <C-R>=expand("%:p:h") . "/" <CR> | |
" Make it easy to navigate on insert mode | |
imap <C-k> <Up> | |
imap <C-j> <Down> | |
imap <C-h> <Left> | |
imap <C-l> <Right> | |
" Folding | |
set foldmethod=indent | |
set foldnestmax=10 | |
set nofoldenable | |
set foldlevel=0 | |
" Navigate splits | |
nmap <tab> <c-w>w | |
" I want my NERDTree to be updated | |
map <leader>n :CommandTFlush<cr>\|:NERDTreeToggle<cr> | |
" " Test helpers from Gary Bernhardt's screen cast: | |
" " https://www.destroyallsoftware.com/screencasts/catalog/file-navigation-in-vim | |
" " https://www.destroyallsoftware.com/file-navigation-in-vim.html | |
function! RunTests(filename) | |
" Write the file and run tests for the given filename | |
:w | |
:silent !echo;echo;echo;echo;echo | |
exec ":!time spring rspec " . a:filename | |
endfunction | |
function! SetTestFile() | |
" Set the spec file that tests will be run for. | |
let t:grb_test_file=@% | |
endfunction | |
function! RunTestFile(...) | |
if a:0 | |
let command_suffix = a:1 | |
else | |
let command_suffix = "" | |
endif | |
" Run the tests for the previously-marked file. | |
let in_spec_file = match(expand("%"), '_spec.rb$') != -1 | |
if in_spec_file | |
call SetTestFile() | |
elseif !exists("t:grb_test_file") | |
return | |
end | |
call RunTests(t:grb_test_file . command_suffix) | |
endfunction | |
function! RunNearestTest() | |
let spec_line_number = line('.') | |
call RunTestFile(":" . spec_line_number) | |
endfunction | |
" Run this file | |
map <leader>rr :call RunTestFile()<cr> | |
" Run only the example under the cursor | |
map <leader>rl :call RunNearestTest()<cr> | |
" Run all test files | |
map <leader>ra :call RunTests('spec')<cr> | |
" @Vic Test scripts | |
" Run Rspec in current file | |
" function! RSpecRunLineWithSpring() | |
" execute("!clear && spring rspec " . expand("%p")) . ":" . line(".") . " -c" | |
" endfunction | |
" function! RSpecRunFileWithSpring() | |
" execute("!clear && spring rspec " . expand("%p")) . " -c" | |
" endfunction | |
" " Run cucumber in current file | |
" function! CucumberRunLineWithSpring() | |
" execute("!clear && spring cucumber " . expand("%p")) . ":" . line(".") . " --format=doc" | |
" endfunction | |
" map <Leader>rl :call RSpecRunLineWithSpring()<cr> | |
" map <Leader>rr :call RSpecRunFileWithSpring()<cr> | |
" map <Leader>cl :call CucumberRunLineWithSpring()<cr> | |
set listchars=tab:▸\ ,eol:˫,extends:❯,precedes:❮ | |
" TRAILING WHITESPACES MUST DIE | |
autocmd BufWritePre * :%s/\s\+$//e | |
augroup vimrcEX | |
autocmd! | |
autocmd FileType text setlocal textwidth=78 | |
"Jump to last cursor position | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line ("$") | | |
\ exe "normal g'\"" | | |
\ endif | |
augroup END | |
"Clear the search buffer when hitting return | |
:nnoremap <CR> :nohlsearch<cr> | |
"Indent at begining of line, else do completion | |
function! InsertTabWrapper() | |
let col = col('.') - 1 | |
if !col || getline('.')[col - 1] !~ '\k' | |
return "\<tab>" | |
else | |
return "\<c-p>" | |
endif | |
endfunction | |
inoremap <tab> <c-r>=InsertTabWrapper()<cr> | |
inoremap <s-tab> <c-n> | |
"Rename file | |
function! RenameFile() | |
let old_name = expand('%') | |
let new_name = input('New file name: ', expand('%')) | |
if new_name != '' && new_name != old_name | |
exec ':saveas ' . new_name | |
exec ':silent !rm ' . old_name | |
redraw! | |
endif | |
endfunction | |
map <leader>j :call RenameFile()<cr> | |
"Promote to Rspec Let | |
function! PromoteToLet() | |
:normal! dd | |
:normal! P | |
:.s/\(\w\+\) = \(.*\)$/let!(:\1) { \2 }/ | |
:normal == | |
endfunction | |
:command! PromoteToLet :call PromoteToLet() | |
map <leader>p :PromoteToLet<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment