Last active
December 11, 2015 08:18
Revisions
-
kakawait revised this gist
Jan 21, 2013 . 1 changed file with 55 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,33 @@ " Use Vim settings, rather then Vi settings (much better!). " This must be first, because it changes other options as a side effect. set nocompatible " ================ General Config ==================== set number "Line numbers are good set numberwidth=6 set backspace=indent,eol,start "Allow backspace in insert mode set history=1000 "Store lots of :cmdline history set showcmd "Show incomplete cmds down the bottom set showmode "Show current mode down the bottom set gcr=a:blinkon0 "Disable cursor blink set autoread "Reload files changed outside vim " This makes vim act like all other editors, buffers can " exist in the background without being in a window. " http://items.sjbach.com/319/configuring-vim-right set hidden "turn on syntax highlighting syntax on " Use the OS clipboard by default (on versions compiled with `+clipboard`) set clipboard=unnamed " Enhance command-line completion set wildmenu " Allow cursor keys in insert mode set esckeys " Optimize for fast terminal connections set ttyfast " Add the g flag to search/replace by default @@ -23,37 +43,21 @@ set noeol set backupdir=~/.vim/backups set directory=~/.vim/swaps if exists("&undodir") set undodir=~/.vim/undo endif " Respect modeline in files set modeline set modelines=4 " Enable mouse in all modes set mouse=a " Disable error bells set noerrorbells " Don’t reset cursor to start of line when moving around. set nostartofline " Show the current mode set showmode " Show the filename in the window titlebar @@ -80,3 +84,31 @@ if has("autocmd") " Treat .json files as .js autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript endif " ================ Search Settings ================= set incsearch "Find the next match as we type the search set hlsearch "Hilight searches by default set viminfo='100,f1 "Save up to 100 marks, enable capital marks set ignorecase "Ignore case of searches " ================ Indentation ====================== set autoindent set smarttab set shiftwidth=2 set softtabstop=4 set tabstop=4 set expandtab set nowrap "Don't wrap lines set linebreak "Wrap lines at convenient points " ================ Folds ============================ set foldmethod=indent "fold based on indent set foldnestmax=3 "deepest fold is 3 levels set nofoldenable "dont fold by default "colors molokai colors monokai -
kakawait created this gist
Jan 19, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,191 @@ ############################# # MAIN # ############################# # Append to the Bash history file, rather than overwriting it shopt -s histappend # Autocorrect typos in path names when using `cd` shopt -s cdspell # Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards [ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh # Add `killall` tab completion for common apps complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall # If possible, add tab completion for many more commands if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi ############################# # RVM # ############################# [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* ############################# # ALIAS # ############################# # Easier navigation: .., ..., ...., ....., ~ and - alias ..="cd .." alias ...="cd ../.." # Shortcuts alias d="cd ~/Dropbox" alias dl="cd ~/Downloads" alias dt="cd ~/Desktop" alias p="cd ~/Projects" alias g="git" alias h="history" alias v="vim" alias o="open" alias oo="open ." # List all files colorized in long format, including dot files alias la="ls -laG" alias ll='ls -laG' # List only directories alias lsd='ls -lG | grep "^d"' # Always use color output for `ls` alias ls="command ls -G" export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:' # Get OS X Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm update npm -g; npm update -g; sudo gem update' # Show/hide hidden files in Finder alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" # Hide/show all desktop icons (useful when presenting) alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder" alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder" # URL-encode strings alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"' # Ring the terminal bell, and put a badge on Terminal.app’s Dock icon # (useful when executing time-consuming commands) alias badge="tput bel" # Easy access to sublime text 2 application alias subl="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" ############################# # EXPORT # ############################# # Make vim the default editor export EDITOR="vim" # Larger bash history (allow 32³ entries; default is 500) export HISTSIZE=32768 export HISTFILESIZE=$HISTSIZE export HISTCONTROL=ignoredups # Make some commands not show up in history export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help" # Highlight section titles in manual pages export LESS_TERMCAP_md="$ORANGE" # Don’t clear the screen after quitting a manual page export MANPAGER="less -X" ############################# # FUNCTION # ############################# # Determine size of a file or total size of a directory function fs() { if du -b /dev/null > /dev/null 2>&1; then local arg=-sbh else local arg=-sh fi if [[ -n "$@" ]]; then du $arg -- "$@" else du $arg .[^.]* * fi } # Use Git’s colored diff when available hash git &>/dev/null if [ $? -eq 0 ]; then function diff() { git diff --no-index --color-words "$@" } fi # Start an HTTP server from a directory, optionally specifying the port function httpserver() { local port="${1:-8000}" sleep 1 && open "http://localhost:${port}/" & # Set the default Content-Type to `text/plain` instead of `application/octet-stream` # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files) python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port" } # Start a PHP server from a directory, optionally specifying the port # (Requires PHP 5.4.0+.) function phpserver() { local port="${1:-4000}" local ip=$(ipconfig getifaddr en1) sleep 1 && open "http://${ip}:${port}/" & php -S "${ip}:${port}" } # Syntax-highlight JSON strings or files # Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json` function json() { if [ -t 0 ]; then # argument python -mjson.tool <<< "$*" | pygmentize -l javascript else # pipe python -mjson.tool | pygmentize -l javascript fi } # Add note to Notes.app (OS X 10.8) # Usage: `note 'foo'` or `echo 'foo' | note` function note() { local text if [ -t 0 ]; then # argument text="$1" else # pipe text=$(cat) fi body=$(echo "$text" | sed -E 's|$|<br>|g') osascript >/dev/null <<EOF tell application "Notes" tell account "iCloud" tell folder "Notes" make new note with properties {name:"$text", body:"$body"} end tell end tell end tell EOF } # Add reminder to Reminders.app (OS X 10.8) # Usage: `remind 'foo'` or `echo 'foo' | remind` function remind() { local text if [ -t 0 ]; then text="$1" # argument else text=$(cat) # pipe fi osascript >/dev/null <<EOF tell application "Reminders" tell the default list make new reminder with properties {name:"$text"} end tell end tell EOF } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ # Make Tab autocomplete regardless of filename case set completion-ignore-case on # List all matches in case multiple possible completions are possible set show-all-if-ambiguous on # Immediately add a trailing slash when autocompleting symlinks to directories set mark-symlinked-directories on # Use the text that has already been typed as the prefix for searching through # commands (i.e. more intelligent Up/Down behavior) "\e[B": history-search-forward "\e[A": history-search-backward # Do not autocomplete hidden files unless the pattern explicitly begins with a dot set match-hidden-files off # Show extra file information when completing, like `ls -F` does set visible-stats on This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,82 @@ " Make Vim more useful set nocompatible " Use the OS clipboard by default (on versions compiled with `+clipboard`) set clipboard=unnamed " Enhance command-line completion set wildmenu " Allow cursor keys in insert mode set esckeys " Allow backspace in insert mode set backspace=indent,eol,start " Optimize for fast terminal connections set ttyfast " Add the g flag to search/replace by default set gdefault " Use UTF-8 without BOM set encoding=utf-8 nobomb " Change mapleader let mapleader="," " Don’t add empty newlines at the end of files set binary set noeol " Centralize backups, swapfiles and undo history set backupdir=~/.vim/backups set directory=~/.vim/swaps if exists("&undodir") set undodir=~/.vim/undo endif " Respect modeline in files set modeline set modelines=4 " Enable per-directory .vimrc files and disable unsafe commands in them set exrc set secure " Enable line numbers set number " Enable syntax highlighting syntax on " Make tabs as wide as two spaces set tabstop=2 " Highlight searches set hlsearch " Ignore case of searches set ignorecase " Highlight dynamically as pattern is typed set incsearch " Always show status line set laststatus=2 " Enable mouse in all modes set mouse=a " Disable error bells set noerrorbells " Don’t reset cursor to start of line when moving around. set nostartofline " Show the cursor position set ruler " Show the current mode set showmode " Show the filename in the window titlebar set title " Show the (partial) command as it’s being typed set showcmd " Start scrolling three lines before the horizontal window border set scrolloff=3 " Strip trailing whitespace (,ss) function! StripWhitespace() let save_cursor = getpos(".") let old_query = getreg('/') :%s/\s\+$//e call setpos('.', save_cursor) call setreg('/', old_query) endfunction noremap <leader>ss :call StripWhitespace()<CR> " Automatic commands if has("autocmd") " Enable file type detection filetype on " Treat .json files as .js autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript endif This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ # Use the server-provided last modification date, if available timestamping = on # Retry a few times when a download fails, but don’t overdo it. (The default is 20!) tries = 3 # Retry even when the connection was refused retry_connrefused = on # Follow FTP links from HTML documents by default follow_ftp = on # Add a `.html` extension to `text/html` or `application/xhtml+xml` files that lack one, or a `.css` extension to `text/css` files that lack one adjust_extension = on # Ignore `robots.txt` and `<meta name=robots content=nofollow>` robots = off # Print the HTTP and FTP server responses server_response = on # Disguise as IE 9 on Windows 7 user_agent = Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)