├── .gitignore ├── powerline ├── segments │ ├── __init__.py │ └── custom.py ├── .lvimrc ├── themes │ └── vim │ │ ├── help.json │ │ ├── quickfix.json │ │ └── default.json ├── config.json ├── colorschemes │ └── vim │ │ └── default.json └── colors.json ├── vim ├── .vim │ ├── .gitignore │ ├── after │ │ ├── ftplugin │ │ │ └── vim.vim │ │ ├── syntax │ │ │ ├── ruby.vim │ │ │ ├── html.vim │ │ │ └── python.vim │ │ └── autoload │ │ │ └── netrw_gitignore.vim │ ├── spell │ │ ├── en.utf-8.add.spl │ │ └── en.utf-8.add │ ├── .skeleton.html │ ├── indent │ │ └── apache.vim │ ├── syntax │ │ └── tasksheet.vim │ ├── colors │ │ └── hhdgray.vim │ └── ftplugin │ │ ├── html.vim │ │ └── xml.vim └── .vimrc ├── sh ├── .inputrc ├── presenting_prompt ├── homebrew_packages ├── .ackrc ├── .railsrc ├── .gitignore_global ├── bash_ruby_prompt ├── .bashrc.osx ├── bash_prompt_colors ├── .bashrc ├── .tmux-project.tmux ├── bash_prompt_vcs_colors ├── tmux_git_prompt ├── bash_aliases ├── .gitconfig ├── .tmux.conf ├── sweet_bash_prompt ├── bash_functions ├── .bash_profile └── bash_git_prompt ├── bin ├── pubkey_from_private_key ├── display-notification ├── tmux_status ├── Gemfile.default ├── list-git-objects ├── shell-properties ├── remove_broken_dotfile_symlinks ├── iploc ├── list256colors.sh ├── tmux-project ├── ok ├── mkproject ├── list-files ├── setup_common_symlinks ├── gemspec-init ├── 256colors2.pl ├── bootstrap ├── um └── num256colors └── slice ├── backup_slice └── setup_slice /.gitignore: -------------------------------------------------------------------------------- 1 | vim/.vim/bundle 2 | -------------------------------------------------------------------------------- /powerline/segments/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vim/.vim/.gitignore: -------------------------------------------------------------------------------- 1 | .netrwhist 2 | -------------------------------------------------------------------------------- /sh/.inputrc: -------------------------------------------------------------------------------- 1 | set show-all-if-ambiguous on 2 | -------------------------------------------------------------------------------- /vim/.vim/after/ftplugin/vim.vim: -------------------------------------------------------------------------------- 1 | setlocal keywordprg=:help 2 | -------------------------------------------------------------------------------- /vim/.vim/after/syntax/ruby.vim: -------------------------------------------------------------------------------- 1 | let b:eruby_subtype = "html" 2 | -------------------------------------------------------------------------------- /bin/pubkey_from_private_key: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ssh-keygen -f $1 -y 4 | -------------------------------------------------------------------------------- /powerline/.lvimrc: -------------------------------------------------------------------------------- 1 | if &ft == 'javascript' 2 | set noet nolist 3 | endif 4 | -------------------------------------------------------------------------------- /vim/.vim/spell/en.utf-8.add.spl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changemewtf/dotfiles/HEAD/vim/.vim/spell/en.utf-8.add.spl -------------------------------------------------------------------------------- /vim/.vim/spell/en.utf-8.add: -------------------------------------------------------------------------------- 1 | Installfest 2 | WDI 3 | App 4 | MacBookPro 5 | Xcode 6 | Homebrew 7 | iTerm2 8 | app 9 | jekyll 10 | -------------------------------------------------------------------------------- /sh/presenting_prompt: -------------------------------------------------------------------------------- 1 | # vim:ft=sh 2 | 3 | PS1='\[${BLUE}\]${PWD##*/}\[${RESET}\] $ ' 4 | 5 | echo "${RED}${PWD}${RESET}" 6 | 7 | echo 8 | -------------------------------------------------------------------------------- /bin/display-notification: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | osascript -e 'display notification "Lorem ipsumasdf dolor sit amet" sound name "Sosumi" with title "asdasdfafdsf"' 4 | -------------------------------------------------------------------------------- /vim/.vim/.skeleton.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sh/homebrew_packages: -------------------------------------------------------------------------------- 1 | bash-completion 2 | coreutils 3 | tmux 4 | rbenv 5 | ruby-build 6 | postgres 7 | redis 8 | vim 9 | reattach-to-user-namespace 10 | gcc 11 | -------------------------------------------------------------------------------- /sh/.ackrc: -------------------------------------------------------------------------------- 1 | --ignore-directory=is:node_modules 2 | --ignore-directory=is:bower_components 3 | --ignore-directory=is:tmp 4 | --ignore-directory=is:dist 5 | 6 | --ignore-file=is:tags 7 | -------------------------------------------------------------------------------- /bin/tmux_status: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source ~/.common-public/sh/bash_git_prompt 4 | source ~/.common-public/sh/tmux_git_prompt 5 | 6 | _update_git_variables 7 | tmux_git_prompt 8 | -------------------------------------------------------------------------------- /bin/Gemfile.default: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | source "https://rubygems.org" 3 | 4 | gem "rspec" 5 | gem "pry" 6 | gem "pry-byebug" 7 | gem "grimoire", github: "mcantor/grimoire", branch: "master" 8 | -------------------------------------------------------------------------------- /bin/list-git-objects: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find .git/objects | egrep '[0-9a-f]{38}' | ruby -n -e 'fi=$_.chomp; ob=fi.split("/")[-2..-1].join; ob_type=%x(git cat-file -t #{ob}).chomp; puts "#{ob} #{ob_type}"' 3 | -------------------------------------------------------------------------------- /sh/.railsrc: -------------------------------------------------------------------------------- 1 | --skip-keeps 2 | --skip-spring 3 | --skip-javascript 4 | --skip-turbolinks 5 | --skip-action-cable 6 | --skip-turbolinks 7 | --skip-test-unit 8 | --skip-action-mailer 9 | --database=postgresql 10 | -------------------------------------------------------------------------------- /bin/shell-properties: -------------------------------------------------------------------------------- 1 | # vim: set ft=sh 2 | 3 | # XXX: source this file, DO NOT EXECUTE IT! 4 | 5 | shopt -q login_shell && echo 'Login shell' || echo 'Not login shell' 6 | 7 | [[ $- == *i* ]] && echo 'Interactive shell' || echo 'Not interactive shell' 8 | 9 | -------------------------------------------------------------------------------- /bin/remove_broken_dotfile_symlinks: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function find_broken_symlinks { 4 | DIR=$1 5 | shift 6 | find -L $DIR -maxdepth 1 -type l "$@" 7 | } 8 | 9 | # not all dotfiles live forever 10 | find_broken_symlinks . -delete 11 | 12 | -------------------------------------------------------------------------------- /bin/iploc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | URL='http://www.ip-adress.com/ip_tracer/?QRY=' 4 | TMPDIR=$HOME/tmp 5 | BUFFER=$TMPDIR/out 6 | 7 | rm -rf $TMPDIR 8 | mkdir $TMPDIR 9 | 10 | lynx -dump $URL > $BUFFER 11 | 12 | gsed -nr s/'^.*My IP address city: (.+)$/\1/p' <$BUFFER 13 | gsed -nr s/'^.*My IP address state: (.+)$/\1/p' <$BUFFER 14 | -------------------------------------------------------------------------------- /sh/.gitignore_global: -------------------------------------------------------------------------------- 1 | # Shared 2 | *.db 3 | tags 4 | .session.vim 5 | .ackrc 6 | 7 | # C 8 | *.o 9 | 10 | # OS X 11 | .DS_Store 12 | 13 | # JavaScript 14 | node_modules 15 | bower_components 16 | 17 | # sass 18 | .sass-cache/ 19 | 20 | # Python 21 | __pycache__/ 22 | .virtualenv/ 23 | *.egg-info/ 24 | 25 | # Ruby 26 | .yardoc/ 27 | 28 | # Rails 29 | *.sqlite3 30 | 31 | # Qt5 32 | *.qmlc 33 | -------------------------------------------------------------------------------- /vim/.vim/after/syntax/html.vim: -------------------------------------------------------------------------------- 1 | " html 5.0 tags 2 | syn keyword htmlTagName contained article aside audio canvas command datalist 3 | syn keyword htmlTagName contained details embed figcaption figure footer header 4 | syn keyword htmlTagName contained hgroup keygen mark meter nav output progress 5 | syn keyword htmlTagName contained rp rt ruby section source summary time 6 | syn keyword htmlTagName contained video wbr 7 | -------------------------------------------------------------------------------- /bin/list256colors.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # one-liner: 4 | #( x=`tput op` y=`printf %$((${COLUMNS}-6))s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done; ) 5 | 6 | aa_256 () 7 | { 8 | ( x=`tput op` y=`printf %$((${COLUMNS}-6))s`; 9 | for i in {0..256}; 10 | do 11 | o=00$i; 12 | echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x; 13 | done ) 14 | } 15 | 16 | aa_256 17 | -------------------------------------------------------------------------------- /bin/tmux-project: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -eq 0 ]; then 4 | SESSION=$(basename $PWD) 5 | else 6 | SESSION=$1 7 | fi 8 | 9 | export SESSION=${SESSION//./} 10 | 11 | # set window title 12 | echo -ne "\033]0;${SESSION}\007" 13 | 14 | if [ -d ".virtualenv" ]; then 15 | export VIRTUAL_ENV="$(readlink -f .)/.virtualenv" 16 | fi 17 | 18 | PROGRAMMING_SUCKS=$PWD 19 | (cd && env -u PWD -u SESSION -u OLDPWD tmux new-session -s $SESSION -d -c $PROGRAMMING_SUCKS) 20 | export PROGRAMMING_SUCKS 21 | tmux attach-session -t $SESSION \; source-file ~/.common-public/sh/.tmux-project.tmux 22 | -------------------------------------------------------------------------------- /slice/backup_slice: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . slice_constants 4 | 5 | cd 6 | rm -rf $PAYLOAD 7 | mkdir $PAYLOAD 8 | mysqldump --all-databases -u root -p > $LOAD_DB 9 | svnadmin dump -q /var/repos > $LOAD_REPO 10 | tar -czf $LOAD_DOKU -C /var/apps doku 11 | tar -czf $LOAD_WP -C /var/apps wordpress 12 | 13 | mkdir $PAYLOAD/users 14 | 15 | for user in $HOSTED_USERS; do 16 | sudo tar -czf $PAYLOAD/users/$user.tar.gz -C /home $user 17 | done 18 | 19 | for file in $ETC_FILES; do 20 | sudo egrep "(${HOSTED_USERS// /|})" /etc/$file > $PAYLOAD/$file 21 | done 22 | 23 | cp $HOME/id_rsa.pub $PAYLOAD 24 | -------------------------------------------------------------------------------- /sh/bash_ruby_prompt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function has_ruby { 4 | [ -e .ruby-version ] && return 0 5 | return 1 6 | } 7 | 8 | function prompt_ruby { 9 | version=$(<.ruby-version) 10 | rbenv versions --bare | grep -Fxq "$version" 11 | if [ $? -eq 0 ]; then 12 | installed='true' 13 | else 14 | installed='false' 15 | fi 16 | 17 | echo -ne "<" 18 | if [ "$installed" = true ]; then 19 | echo -ne "\x01${BRIGHT_WHITE}\x02" 20 | else 21 | echo -ne "\x01${RED}\x02" 22 | fi 23 | echo -ne $version 24 | echo -ne "\x01${RESET}\x02" 25 | echo -ne ">" 26 | } 27 | -------------------------------------------------------------------------------- /bin/ok: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | import subprocess 5 | 6 | if sys.argv[1] == 'start_postgres': 7 | # OS X only 8 | cmd = 'pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start' 9 | elif sys.argv[1] == 'stop_postgres': 10 | # OS X only 11 | cmd = 'pg_ctl -D /usr/local/var/postgres stop -s -m fast' 12 | elif sys.argv[1] == 'check_postgres': 13 | cmd = 'pg_ctl -D /usr/local/var/postgres status' 14 | else: 15 | cmd = None 16 | 17 | if cmd: 18 | subprocess.call(cmd.split(' ')) 19 | 20 | # customizing rails app name in current directory 21 | # rails new . validations_in_controller_actions 22 | -------------------------------------------------------------------------------- /bin/mkproject: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PROJECT_FOLDER=$HOME/src/projects 4 | 5 | pname=$1 6 | 7 | cd $PROJECT_FOLDER 8 | 9 | if [ -d $pname ]; then 10 | echo "Folder ${pname} already exists." 11 | exit 1 12 | fi 13 | 14 | if [[ -z "$DOTFILE_DIR" ]]; then 15 | echo "Couldn't find dotfile directory." 16 | exit 1 17 | fi 18 | 19 | mkdir -p ${pname}/lib/${pname} 20 | 21 | cd $pname 22 | 23 | touch lib/${pname}.rb 24 | 25 | cp ${DOTFILE_DIR}/bin/Gemfile.default Gemfile 26 | bundle config local.grimoire ${PROJECT_FOLDER}/grimoire 27 | bundle 28 | 29 | bundle exec rspec --init 30 | touch spec/${pname}_spec.rb 31 | 32 | git init . 33 | git add -A 34 | git commit -m "First commit." 35 | 36 | tmux-project 37 | -------------------------------------------------------------------------------- /powerline/themes/vim/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "segments": { 3 | "left": [ 4 | { 5 | "name": "file_name", 6 | "draw_soft_divider": false 7 | }, 8 | { 9 | "type": "string", 10 | "highlight_group": ["background"], 11 | "draw_soft_divider": false, 12 | "draw_hard_divider": false, 13 | "width": "auto" 14 | } 15 | ], 16 | "right": [ 17 | { 18 | "name": "line_percent", 19 | "priority": 30, 20 | "width": 4, 21 | "align": "r" 22 | }, 23 | { 24 | "type": "string", 25 | "name": "line_current_symbol", 26 | "highlight_group": ["line_current_symbol", "line_current"] 27 | }, 28 | { 29 | "name": "line_current", 30 | "draw_soft_divider": false, 31 | "width": 3, 32 | "align": "r" 33 | } 34 | ] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sh/.bashrc.osx: -------------------------------------------------------------------------------- 1 | # vim:ft=sh 2 | 3 | # brew coreutils manpages 4 | MANPATH="/usr/local/opt/coreutils/libexec/gnuman" 5 | 6 | # set LS_COLORS to color broken links in ls, among other things 7 | eval $(dircolors) 8 | 9 | # gimme dat completion, brew 10 | if [ -f $(brew --prefix)/etc/bash_completion ]; then 11 | source $(brew --prefix)/etc/bash_completion 12 | fi 13 | 14 | # tmux detaches from the "user namespace", which means processes running 15 | # inside it do not have access to the same clipboard as the GUI. wrapping 16 | # vim with this brew package is a workaround, but it works. 17 | if [[ $TERM == screen-* ]]; then 18 | if hash reattach-to-user-namespace 2>/dev/null; then 19 | alias vim='reattach-to-user-namespace -l vim' 20 | else 21 | echo 'System clipboard will not function in vim.' 22 | fi 23 | fi 24 | -------------------------------------------------------------------------------- /bin/list-files: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/bash 2 | 3 | # out=$(mktemp) 4 | # trap "rm -f $out" SIGHUP SIGINT SIGTRAP SIGTERM 5 | 6 | # DIALOG="/usr/local/bin/dialog" 7 | DIALOG="/Users/mcantor/src/vendor/dialog-1.3-20170131/dialog" 8 | 9 | path=./ 10 | ndirs=$(find $path -maxdepth 1 -type d | wc -l) 11 | height=$(($ndirs + 4)) 12 | width=12 13 | 14 | opts=() 15 | opts+=("--begin 0 0") 16 | opts+=("--no-ok") 17 | opts+=("--no-cancel") 18 | opts+=("--output-fd 1") 19 | opts+=("--keep-tite") 20 | opts+=("--no-lines") 21 | opts+=("--dselect $path") 22 | opts+=("$height") 23 | opts+=("$width") 24 | 25 | result=$($DIALOG ${opts[*]}) 26 | ecode=$? 27 | 28 | echo -n "ecode $ecode; " 29 | 30 | case $ecode in 31 | 0) 32 | # result=$(<$out) 33 | echo "got '$result'" 34 | ;; 35 | 1) echo "Cancel pressed." ;; 36 | 255) echo "ESC pressed." ;; 37 | esac 38 | -------------------------------------------------------------------------------- /vim/.vim/after/syntax/python.vim: -------------------------------------------------------------------------------- 1 | unlet b:current_syntax 2 | syn include $VIMRUNTIME/syntax/html.vim 3 | 4 | unlet b:current_syntax 5 | syn include @xmlTop $VIMRUNTIME/syntax/xml.vim 6 | 7 | unlet b:current_syntax 8 | syn include @sqlTop $VIMRUNTIME/syntax/sql.vim 9 | syn cluster sqlTop remove=sqlString,sqlComment 10 | 11 | let b:current_syntax = 'python' 12 | 13 | syn region pythonString start=/html = \zs"""/ end=/"""/ contains=@htmlTop 14 | syn region pythonString start=/xml = \zs"""/ end=/"""/ contains=@xmlTop 15 | syn region pythonString start=/sql = \z('''\|"""\)/ end=/\z1/ contains=@sqlTop 16 | 17 | " Clear sqloracle.vim's problematic 'syn sync ccomment' directive 18 | syn sync clear 19 | 20 | " Directly copied from vim73/syntax/python.vim; we just want to 'reinstate' it 21 | syn sync match pythonSync grouphere NONE "^\s*\%(def\|class\)\s\+\h\w*\s*(" 22 | -------------------------------------------------------------------------------- /powerline/themes/vim/quickfix.json: -------------------------------------------------------------------------------- 1 | { 2 | "segment_data": { 3 | "buffer_name": { 4 | "contents": "Location List" 5 | } 6 | }, 7 | "segments": { 8 | "left": [ 9 | { 10 | "type": "string", 11 | "name": "buffer_name", 12 | "highlight_group": ["file_name"] 13 | }, 14 | { 15 | "name": "window_title", 16 | "draw_soft_divider": false 17 | }, 18 | { 19 | "type": "string", 20 | "highlight_group": ["background"], 21 | "draw_soft_divider": false, 22 | "draw_hard_divider": false, 23 | "width": "auto" 24 | } 25 | ], 26 | "right": [ 27 | { 28 | "type": "string", 29 | "name": "line_current_symbol", 30 | "highlight_group": ["line_current_symbol", "line_current"] 31 | }, 32 | { 33 | "name": "line_current", 34 | "draw_soft_divider": false, 35 | "width": 3, 36 | "align": "r" 37 | } 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /bin/setup_common_symlinks: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DOTFILE_DIR="$HOME/$(<$HOME/.dotfile_directory)" 4 | 5 | # Try to use GNU ln if we're on OS X 6 | if hash gln 2>/dev/null; then 7 | LN='gln' 8 | else 9 | LN='ln' 10 | fi 11 | 12 | cd $HOME 13 | 14 | ls -A $DOTFILE_DIR/sh | grep '^\.' | awk '{ print "'$DOTFILE_DIR'/sh/"$0 }' 15 | ls -A $DOTFILE_DIR/sh | grep '^\.' | awk '{ print "'$DOTFILE_DIR'/sh/"$0 }' | xargs $LN -sf -t . 16 | 17 | if [ -d .common-private ]; then 18 | ls -A .common-private/sh | awk '{ print ".common-private/sh/"$0 }' | xargs $LN -sf -t . 19 | fi 20 | 21 | mkdir -p .config 22 | 23 | $LN -sf -t .config $DOTFILE_DIR/powerline 24 | 25 | $LN -sf -t . $DOTFILE_DIR/{vim/.vim,vim/.vimrc} 26 | 27 | if [ -d .common-private ]; then 28 | $LN -sf -t . .common-private/irssi/.irssi 29 | fi 30 | 31 | mkdir -p .ssh 32 | chmod -R a=,u=rwX .ssh 33 | if [ -d .common-private ]; then 34 | $LN -sf -t .ssh ../.common-private/ssh/config 35 | fi 36 | -------------------------------------------------------------------------------- /sh/bash_prompt_colors: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Terminal Foregrounds 4 | BLACK=$(tput setaf 0) 5 | RED=$(tput setaf 1) 6 | GREEN=$(tput setaf 2) 7 | YELLOW=$(tput setaf 3) 8 | BLUE=$(tput setaf 4) 9 | MAGENTA=$(tput setaf 5) 10 | CYAN=$(tput setaf 6) 11 | WHITE=$(tput setaf 7) 12 | RESET=$(tput sgr0) 13 | 14 | # Formatting 15 | BOLD=$(tput bold) 16 | 17 | # 256-color Foregrounds 18 | LIGHT_BLUE=$(tput setaf 51) 19 | LIGHT_GREEN=$(tput setaf 46) 20 | CRIMSON=$(tput setaf 196) 21 | BRIGHT_WHITE='\033[1;37m' 22 | 23 | # 256-color Backgrounds 24 | BG_DARK_GRAY=$(tput setab 234) 25 | 26 | # Basic Prompt 27 | USER_HOST_COLOR="$CYAN" 28 | JOBS_COLOR="$BRIGHT_WHITE" 29 | 30 | # Directory 31 | VANILLA_PWD="$WHITE" 32 | SVN_PWD="${BG_DARK_GRAY}${BOLD}${CRIMSON}" 33 | HG_PWD="${BG_DARK_GRAY}${BOLD}${LIGHT_GREEN}" 34 | GIT_PWD="${BG_DARK_GRAY}${BOLD}${LIGHT_BLUE}" 35 | 36 | # git 37 | GIT_BRANCH_COLOR=$GREEN 38 | GIT_DETACHED_COLOR=$YELLOW 39 | GIT_ACTIVITY_COLOR=$(tput setab 17)$(tput setaf 141) 40 | 41 | -------------------------------------------------------------------------------- /sh/.bashrc: -------------------------------------------------------------------------------- 1 | DOTFILE_DIR="$HOME/$(<$HOME/.dotfile_directory)" 2 | 3 | # Set some basic shell options 4 | HISTCONTROL='ignorespace:erasedups' # tweak what gets added to history 5 | shopt -s histappend # multiple terminals don't clobber each others' history 6 | shopt -s checkwinsize # update LINES and COLUMNS 7 | shopt -s no_empty_cmd_completion 8 | 9 | # if a 256color terminfo is available for our terminal, switch to it 10 | if [[ $TERM != *-256color ]]; then 11 | POTENTIAL_TERM=${TERM}-256color 12 | toe -a | awk '{print $1}' | grep -Fxq $POTENTIAL_TERM && TERM=$POTENTIAL_TERM 13 | fi 14 | 15 | # don't presume remote boxes will have 256-color terminfo files 16 | [[ $TERM == *-256color ]] && alias ssh='TERM=${TERM%-256color} ssh' 17 | 18 | # set up my sweet shell prompt 19 | source $DOTFILE_DIR/sh/sweet_bash_prompt 20 | 21 | # source convenient things 22 | source $DOTFILE_DIR/sh/bash_aliases 23 | source $DOTFILE_DIR/sh/bash_functions 24 | 25 | # setup completion if available 26 | [ -f /etc/bash_completion ] && source /etc/bash_completion 27 | 28 | [ "$PLATFORM" = "OSX" ] && source $DOTFILE_DIR/sh/.bashrc.osx 29 | -------------------------------------------------------------------------------- /sh/.tmux-project.tmux: -------------------------------------------------------------------------------- 1 | # vim: ft=tmux 2 | 3 | unbind-key q 4 | # sleep to wait for vim and servers to finish closing 5 | bind-key q if-shell "tmux list-windows | cut -d' ' -f2 | grep srv" "send-keys -t srv C-c" \; send-keys -t lib ":call MySessionSave()" C-m \; run-shell "sleep 0.1" \; kill-session 6 | 7 | set-window-option -g automatic-rename off 8 | 9 | rename-window git 10 | send-keys "tree" C-m 11 | send-keys "git status" C-m 12 | 13 | new-window -n lib 14 | send-keys "if [ -e .session.vim ]; then vim -S .session.vim; else vim -c NERDTree; fi" C-m 15 | 16 | new-window -n bash 17 | 18 | # use single quotes instead of double to prevent premature variable expansion 19 | # tmux doesn't actually respect session env variables within sourced conf files 20 | if-shell 'cd $PROGRAMMING_SUCKS && test -d spec' "new-window -n spec ; send-keys 'bundle exec rspec' C-m" 21 | 22 | new-window -n search -t 8 ; send-keys 'test -e .searchrc && source .searchrc' C-m 'clear' C-m 23 | bind-key g select-window -t search 24 | 25 | new-window -n srv -t 9 26 | 27 | if-shell 'cd $PROGRAMMING_SUCKS && test -e Procfile' "select-window -t srv ; send-keys 'foreman start' C-m" 28 | 29 | select-window -t lib 30 | -------------------------------------------------------------------------------- /sh/bash_prompt_vcs_colors: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function should_mask_vcs { 4 | currdir=${PWD} 5 | vcs=$1 6 | 7 | while [[ -e "$currdir" ]]; do 8 | if [[ -d "$currdir/.$vcs" ]]; then 9 | return 0 10 | else 11 | currdir=${currdir%/*} # now check parent directory 12 | fi 13 | done 14 | 15 | return 1 16 | } 17 | 18 | # use a mask so we can communicate multiple VCS control in a single dir 19 | # in case we're dealing with fucked repos that have .git and .svn 20 | svn_mask=$((1 << 0)) 21 | hg_mask=$((1 << 1)) 22 | git_mask=$((1 << 2)) 23 | 24 | VCS_MASK=0 25 | 26 | function set_vcs_mask { 27 | VCS_MASK=0 28 | [[ -d .svn ]] && let "VCS_MASK |= $svn_mask" 29 | should_mask_vcs hg && let "VCS_MASK |= $hg_mask" 30 | should_mask_vcs git && let "VCS_MASK |= $git_mask" 31 | return 0 32 | } 33 | 34 | function is_vcs { 35 | [[ $(($VCS_MASK & $1)) -ne 0 ]] && return 0 36 | return 1 37 | } 38 | 39 | function get_vcs_pwd_color { 40 | VCS_PWD=$VANILLA_PWD 41 | 42 | is_vcs $svn_mask && VCS_PWD=$SVN_PWD 43 | is_vcs $hg_mask && VCS_PWD=$HG_PWD 44 | is_vcs $git_mask && VCS_PWD=$GIT_PWD 45 | 46 | echo -e $VCS_PWD 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /sh/tmux_git_prompt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | _default_fg="colour246" 4 | 5 | _tmux_prompt_git_changes() { 6 | staged="+" 7 | unstaged="!" 8 | untracked="?" 9 | 10 | delimiter='|' 11 | count=0 12 | 13 | [ "$_git_num_staged" -gt "0" ] && (( count+=1 )) && echo -n "#[fg=colour82]${staged}#[fg=$_default_fg]" 14 | [ "$_git_num_unstaged" -gt "0" ] && [ "$count" -gt "0" ] && echo -n "$delimiter" 15 | [ "$_git_num_unstaged" -gt "0" ] && (( count+=1 )) && echo -n "#[fg=colour226]${unstaged}#[fg=$_default_fg]" 16 | [ "$_git_num_untracked" -gt "0" ] && [ "$count" -gt "0" ] && echo -n "$delimiter" 17 | [ "$_git_num_untracked" -gt "0" ] && (( count+=1 )) && echo -n "#[fg=colour196]${untracked}#[fg=$_default_fg]" 18 | } 19 | 20 | _tmux_prompt_git_branch() { 21 | echo -n "(" 22 | echo -n "#[fg=colour76]$_git_branch" 23 | echo -n "#[fg=$_default_fg]) " 24 | } 25 | 26 | tmux_git_prompt() { 27 | changes=$(_tmux_prompt_git_changes) 28 | 29 | echo -n "#[bg=colour236,fg=$_default_fg]" 30 | echo -n " [" 31 | echo -n "#[fg=colour231]${SESSION}#[fg=$_default_fg]]" 32 | echo -n " " 33 | if [ -n "$_git_dir" ]; then 34 | echo -n "$(_tmux_prompt_git_branch)" 35 | [ -n "$changes" ] && echo -n "[$changes] " 36 | fi 37 | echo -n "#[default] " 38 | } 39 | -------------------------------------------------------------------------------- /sh/bash_aliases: -------------------------------------------------------------------------------- 1 | # vim:ft=sh 2 | 3 | alias be='bundle exec' 4 | alias gerp='grep -rs --include=*.{js,coffee,hbs,json,rb,py} --exclude-dir={bower_components,node_modules,tmp,dist}' 5 | alias all_vars='(set -o posix; set) | less -R' 6 | alias cm='cd '$DOTFILE_DIR 7 | alias cdg='cd $(git root)' 8 | alias gemdir='cd $(gem environment gemdir)' 9 | alias tree='tree -Ca --noreport -I ".sass-cache|.git|node_modules|bower_components|tmp|__pycache__|.virtualenv"' 10 | alias ll='ls -la' 11 | alias la='ls -A' 12 | alias l='ls -CF' 13 | alias src='. $HOME/.bashrc' 14 | alias spf='. $HOME/.bash_profile' 15 | alias stripescapes='sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"' 16 | alias vi='vim' 17 | alias path='echo $PATH | tr ":" "\n"' 18 | alias pythonpath='echo $PYTHONPATH | tr ":" "\n"' 19 | alias :q='logout' 20 | alias :e='vim' 21 | alias ,e='vim $HOME/.vimrc' 22 | alias which='type -a' 23 | alias wget='wget --content-disposition' 24 | alias loc="find . -type f -iname \"*.rb\" -exec cat {} \; | sed '/^\s*#/d;/^\s*$/d' | wc -l" 25 | alias rbdoc="cd ~/my-ruby/src/ruby-2.1.2 && yard server -m core .yardoc-core stdlib-2.1.2 .yardoc-stdlib" 26 | alias curriculum='cd $HOME/src/nycda/nycda-curriculum && tree curriculums/web-development-intensive' 27 | alias ecurriculum='cd $HOME/src/nycda/nycda-curriculum && vim curriculums/web-development-intensive/web-development-intensive.md' 28 | -------------------------------------------------------------------------------- /powerline/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "common": { 3 | "term_truecolor": false, 4 | "dividers": { 5 | "left": { 6 | "hard": " ", 7 | "soft": " " 8 | }, 9 | "right": { 10 | "hard": " ", 11 | "soft": " " 12 | } 13 | }, 14 | "spaces": 1, 15 | "paths": [ 16 | "~/.config/powerline/segments" 17 | ] 18 | }, 19 | "ext": { 20 | "ipython": { 21 | "colorscheme": "default", 22 | "theme": "in", 23 | "local_themes": { 24 | "rewrite": "rewrite", 25 | "out": "out", 26 | "in2": "in2" 27 | } 28 | }, 29 | "shell": { 30 | "colorscheme": "default", 31 | "theme": "default", 32 | "local_themes": { 33 | "continuation": "continuation", 34 | "select": "select" 35 | } 36 | }, 37 | "tmux": { 38 | "colorscheme": "default", 39 | "theme": "default" 40 | }, 41 | "vim": { 42 | "colorscheme": "default", 43 | "theme": "default", 44 | "local_themes": { 45 | "cmdwin": "cmdwin", 46 | "help": "help", 47 | "quickfix": "quickfix", 48 | 49 | "powerline.matchers.plugin.nerdtree.nerdtree": "plugin_nerdtree", 50 | "powerline.matchers.plugin.ctrlp.ctrlp": "plugin_ctrlp", 51 | "powerline.matchers.plugin.gundo.gundo": "plugin_gundo", 52 | "powerline.matchers.plugin.gundo.gundo_preview": "plugin_gundo-preview" 53 | } 54 | }, 55 | "wm": { 56 | "colorscheme": "default", 57 | "theme": "default" 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /vim/.vim/indent/apache.vim: -------------------------------------------------------------------------------- 1 | " Language: apache 2 | " Maintainer: Satya P 3 | " Last Change: Sat, 27 Jan 2007 11:24:59 EST 4 | " Notes: 0) Copied from Johannes Zellner 's xml 5 | " indent script 6 | 7 | " Only load this indent file when no other was loaded. 8 | if exists("b:did_indent") 9 | finish 10 | endif 11 | let b:did_indent = 1 12 | 13 | " [-- local settings (must come before aborting the script) --] 14 | setlocal indentexpr=ApacheIndentGet(v:lnum,1) 15 | setlocal indentkeys=o,O,*,<>>,<<>,/,{,} 16 | 17 | set cpo-=C 18 | 19 | " [-- finish, if the function already exists --] 20 | if exists('*ApacheIndentGet') | finish | endif 21 | 22 | fun! ApacheIndentGet(lnum, use_syntax_check) 23 | " Find a non-empty line above the current line. 24 | let lnum = prevnonblank(a:lnum - 1) 25 | 26 | " Hit the start of the file, use zero indent. 27 | if lnum == 0 28 | return 0 29 | endif 30 | 31 | let prevline=getline(lnum) 32 | let line=getline(a:lnum) 33 | let ind=indent(lnum) 34 | let inddelta=0 35 | if match(line, '^\s* $upstream/${tracked##*/}\"; \ 31 | fi; \ 32 | done" 33 | 34 | root = !pwd 35 | 36 | [color] 37 | ui = true 38 | 39 | [color "status"] 40 | changed = yellow 41 | 42 | [user] 43 | name = Max Cantor 44 | email = max@maxcantor.net 45 | 46 | [push] 47 | default = simple 48 | 49 | [merge] 50 | tool = vimdiff 51 | 52 | [core] 53 | excludesfile = ~/.gitignore_global 54 | -------------------------------------------------------------------------------- /powerline/segments/custom.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals, absolute_import, division 2 | 3 | import os 4 | import vim 5 | 6 | from powerline.bindings.vim import vim_get_func 7 | 8 | # from powerline.bindings.vim import (vim_get_func, getbufvar, vim_getbufoption, 9 | # buffer_name, vim_getwinvar) 10 | # from powerline.theme import requires_segment_info, requires_filesystem_watcher 11 | # from powerline.lib import add_divider_highlight_group 12 | # from powerline.lib.vcs import guess, tree_status 13 | # from powerline.lib.humanize_bytes import humanize_bytes 14 | # from powerline.lib import wraps_saveargs as wraps 15 | # from collections import defaultdict 16 | 17 | vim_funcs = { 18 | # 'fnamemodify': vim_get_func('fnamemodify'), 19 | # 'expand': vim_get_func('expand'), 20 | # 'bufnr': vim_get_func('bufnr', rettype=int), 21 | # 'line2byte': vim_get_func('line2byte', rettype=int), 22 | 'virtcol': vim_get_func('virtcol', rettype=int), 23 | 'getline': vim_get_func('getline'), 24 | } 25 | 26 | def character_info(pl): 27 | line_contents = vim_funcs['getline']('.') 28 | cursor_column = int(vim_funcs['virtcol']('.')) 29 | 30 | if line_contents and cursor_column <= len(line_contents): 31 | character = line_contents.decode('utf-8')[cursor_column - 1] 32 | codepoint = ord(character) 33 | 34 | if codepoint <= 255: 35 | highlight_group = "current_character" 36 | else: 37 | highlight_group = "current_character_utf" 38 | 39 | contents = str(codepoint) 40 | 41 | return [ 42 | { 43 | "contents": contents, 44 | "highlight_group": highlight_group 45 | } 46 | ] 47 | else: 48 | return None 49 | -------------------------------------------------------------------------------- /bin/gemspec-init: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # Usage: gemspec [-s] GEMNAME 3 | # 4 | # Prints a basic gemspec for GEMNAME based on your git-config info. 5 | # If -s is passed, saves it as a GEMNAME.gemspec in the current 6 | # directory. Otherwise prints to standard output. 7 | # 8 | # Once you check this gemspec into your project, releasing a new gem 9 | # is dead simple: 10 | # 11 | # $ gem build GEMNAME.gemspec 12 | # $ gem push GEMNAME-VERSION.gem 13 | # 14 | # Wants you to have a "lib/GEMNAME/version.rb" file in your project 15 | # which sets the GEMNAME::VERSION constant. 16 | 17 | fullname = `git config --get user.name`.chomp 18 | email = `git config --get user.email`.chomp 19 | login = `git config --get github.user`.chomp 20 | 21 | save = ARGV.delete('-s') 22 | abort "* Pass a gem name." unless name = ARGV[0] 23 | 24 | gemspec = < 3 | # $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $ 4 | 5 | # use the resources for colors 0-15 - usually more-or-less a 6 | # reproduction of the standard ANSI colors, but possibly more 7 | # pleasing shades 8 | 9 | # colors 16-231 are a 6x6x6 color cube 10 | for ($red = 0; $red < 6; $red++) { 11 | for ($green = 0; $green < 6; $green++) { 12 | for ($blue = 0; $blue < 6; $blue++) { 13 | printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", 14 | 16 + ($red * 36) + ($green * 6) + $blue, 15 | ($red ? ($red * 40 + 55) : 0), 16 | ($green ? ($green * 40 + 55) : 0), 17 | ($blue ? ($blue * 40 + 55) : 0)); 18 | } 19 | } 20 | } 21 | 22 | # colors 232-255 are a grayscale ramp, intentionally leaving out 23 | # black and white 24 | for ($gray = 0; $gray < 24; $gray++) { 25 | $level = ($gray * 10) + 8; 26 | printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", 27 | 232 + $gray, $level, $level, $level); 28 | } 29 | 30 | 31 | # display the colors 32 | 33 | # first the system ones: 34 | print "System colors:\n"; 35 | for ($color = 0; $color < 8; $color++) { 36 | print "\x1b[48;5;${color}m "; 37 | } 38 | print "\x1b[0m\n"; 39 | for ($color = 8; $color < 16; $color++) { 40 | print "\x1b[48;5;${color}m "; 41 | } 42 | print "\x1b[0m\n\n"; 43 | 44 | # now the color cube 45 | print "Color cube, 6x6x6:\n"; 46 | for ($green = 0; $green < 6; $green++) { 47 | for ($red = 0; $red < 6; $red++) { 48 | for ($blue = 0; $blue < 6; $blue++) { 49 | $color = 16 + ($red * 36) + ($green * 6) + $blue; 50 | print "\x1b[48;5;${color}m "; 51 | #print "${color}: \x1b[48;5;${color}m \x1b[0m\n"; 52 | } 53 | print "\x1b[0m "; 54 | } 55 | print "\n"; 56 | } 57 | 58 | 59 | # now the grayscale ramp 60 | print "Grayscale ramp:\n"; 61 | for ($color = 232; $color < 256; $color++) { 62 | print "\x1b[48;5;${color}m "; 63 | } 64 | print "\x1b[0m\n"; 65 | -------------------------------------------------------------------------------- /vim/.vim/syntax/tasksheet.vim: -------------------------------------------------------------------------------- 1 | syntax clear 2 | 3 | syn match taskComplete /^COMPLETE$/ 4 | syn match Comment /^\/\/.*$/ 5 | 6 | " define task description color for this region; it's the best way to express 7 | " 'everything except the taskNumber and taskBudget'. since the budget is 8 | " optional, we can't use nextgroup, because taskDescription would always match 9 | " first. 10 | syn region taskDefinitionLine start=/^[0-9]\{4\}/ end=/$/ oneline contains=taskNumber,taskBudget,taskProject 11 | syn match taskNumber /^[0-9]\{4\}/ contains=@taskNumberMod contained 12 | syn match taskBudget /[0-9]\+\.[0-9]\{2\}/ contained 13 | syn region taskProject start=/\[/hs=e+1 end=/\]/he=s-1 oneline contained 14 | 15 | syn region taskRemain matchgroup=taskRemainHeader start=/^REMAIN/ end=/$/ oneline contains=taskRemainAmount,taskTotal 16 | syn match taskRemainAmount /[0-9]\+\.[0-9]\{1,2\}/ contained 17 | 18 | syn region taskTotal matchgroup=taskTotalHeader start=/TOTAL/ end=/$/ oneline contains=taskTotalAmount 19 | syn match taskTotalAmount /[0-9]\+\.[0-9]\{1,2\}/ contained 20 | 21 | syn region sheetSettings matchgroup=settingsHeader start=/^Settings/ matchgroup=NONE end=/$/ oneline contains=settingsHeader,settingPair 22 | syn region settingPair matchgroup=settingKey start=/[a-zA-Z_]\+/ matchgroup=settingValue end=/[^, ]\+/ oneline contained 23 | 24 | hi link taskNumber Keyword 25 | hi link taskDefinitionLine Constant 26 | hi link taskBudget Identifier 27 | hi taskProject ctermfg=red 28 | 29 | hi taskProjectHeader ctermfg=red 30 | 31 | hi link taskRemainHeader Keyword 32 | hi link taskRemainAmount Directory 33 | hi link taskTotalHeader Keyword 34 | hi link taskTotalAmount Directory 35 | 36 | hi link settingsHeader Directory 37 | hi link settingKey Constant 38 | hi link settingValue Identifier 39 | 40 | hi link taskComplete Directory 41 | 42 | syntax cluster taskNumberMod contains=taskBudgetExceeded,taskBudgetExhausted 43 | hi link taskBudgetExceeded ErrorMsg 44 | hi link taskBudgetExhausted Ignore 45 | 46 | let b:current_syntax = "tasksheet" 47 | -------------------------------------------------------------------------------- /sh/.tmux.conf: -------------------------------------------------------------------------------- 1 | # vim: fdm=marker 2 | 3 | set -g prefix C-a 4 | bind-key a send-prefix 5 | unbind-key C-b 6 | 7 | # http://stackoverflow.com/questions/8645053/how-do-i-start-tmux-with-my-current-environment 8 | # so tmux gets new prompt stuff when presenting 9 | set -ga update-environment ' ITERM_PROFILE' 10 | 11 | # https://gist.github.com/datagrok/2199506 12 | set -ga update-environment ' VIRTUAL_ENV' 13 | 14 | set -ga update-environment ' PWD SESSION' 15 | 16 | set -ga update-environment ' PROGRAMMING_SUCKS' 17 | 18 | set -g status-keys emacs 19 | setw -g mode-keys vi 20 | 21 | bind-key -t vi-edit C-u delete-line 22 | 23 | # {{{ status line prettification 24 | 25 | # disabled for now :-( 26 | # set -g status-left '#(~/.common-public/bin/tmux_status)' 27 | # set -g status-interval 1 28 | set -g status-left '#[bg=colour236,fg=colour246] [#[fg=colour231]#S#[fg=colour246]] #[default]' 29 | set -g status-left-length 50 30 | set -g status-bg colour252 31 | set -g status-right " %H:%M %d-%b-%y " 32 | setw -g window-status-separator "" 33 | setw -g window-status-format " #I:#{?window_flags,#{window_flags},}#W " 34 | setw -g window-status-current-format " #I:#{?window_flags,#{window_flags},}#W " 35 | setw -g window-status-current-bg colour236 36 | setw -g window-status-current-fg colour156 37 | setw -g window-status-current-attr bright 38 | 39 | # }}} 40 | 41 | setw -g clock-mode-style 12 42 | 43 | bind-key C-n next-window 44 | bind-key C-p previous-window 45 | bind-key C-a last-window 46 | 47 | # {{{ pane management 48 | 49 | bind-key k select-pane -U 50 | bind-key j select-pane -D 51 | bind-key h select-pane -L 52 | bind-key l select-pane -R 53 | 54 | unbind-key Up 55 | unbind-key Down 56 | unbind-key Left 57 | unbind-key Right 58 | 59 | bind-key M-k resize-pane -U 5 60 | bind-key M-j resize-pane -D 5 61 | bind-key M-h resize-pane -L 5 62 | bind-key M-l resize-pane -R 5 63 | 64 | unbind-key M-Up 65 | unbind-key M-Down 66 | unbind-key M-Left 67 | unbind-key M-Right 68 | 69 | bind-key C-k resize-pane -U 70 | bind-key C-j resize-pane -D 71 | bind-key C-h resize-pane -L 72 | bind-key C-l resize-pane -R 73 | 74 | unbind-key C-Up 75 | unbind-key C-Down 76 | unbind-key C-Left 77 | unbind-key C-Right 78 | 79 | # }}} 80 | 81 | set -g history-limit 5000 82 | -------------------------------------------------------------------------------- /sh/sweet_bash_prompt: -------------------------------------------------------------------------------- 1 | # vim:ft=sh 2 | 3 | case "$TERM" in 4 | screen*|putty*|xterm*) 5 | source $DOTFILE_DIR/sh/bash_prompt_colors 6 | 7 | if [ "$ITERM_PROFILE" = "Presenting" ]; then 8 | source $DOTFILE_DIR/sh/presenting_prompt 9 | else 10 | source $DOTFILE_DIR/sh/bash_prompt_vcs_colors 11 | source $DOTFILE_DIR/sh/bash_git_prompt 12 | source $DOTFILE_DIR/sh/bash_ruby_prompt 13 | 14 | PS1='\[$USER_HOST_COLOR\]\u@\h ' 15 | PS1=$PS1'\[$(get_vcs_pwd_color)\]\w\[$RESET\]' 16 | # If tmux is active, let it handle git prompt 17 | # this is disabled for now; see TMUX below 18 | # [ -z "$TMUX" ] && PS1=$PS1'$( $(is_vcs $git_mask) && echo -ne " $(prompt_git)" )' 19 | PS1=$PS1'$( $(is_vcs $git_mask) && echo -ne " $(prompt_git)" )' 20 | PS1=$PS1'$( (( \j > 0 )) && echo -ne " (\[$JOBS_COLOR\]\j\[$RESET\])" )' 21 | PS1=$PS1'$( $(has_ruby) && echo -ne " $(prompt_ruby)" )' 22 | PS1=$PS1': ' 23 | 24 | # to be shared between bash_git_prompt's prompt_git and tmux_git_prompt 25 | PROMPT_COMMAND='_update_git_variables' 26 | 27 | # detect vcs for prompt coloring 28 | PROMPT_COMMAND+=' && set_vcs_mask' 29 | 30 | # one newline before printing so our output has some breathing room 31 | PROMPT_COMMAND+=' && echo' 32 | 33 | # for real though, what if I just did this and had my prompt command 34 | # re-evaluate my PS1 every time? it couldn't be THAT bad... 35 | # PROMPT_COMMAND='PS1="$(source $DOTFILE_DIR/sh/sweet_prompt)"' 36 | fi 37 | 38 | # this seems to be making my machine lock up, and additionally does not 39 | # gracefully handle multiple sessions attached to the same client, so I'm 40 | # disabling it for now. 41 | # if [ -n "$TMUX" ]; then 42 | # PROMPT_COMMAND+='; tmux refresh-client -S' 43 | # fi 44 | 45 | if $(type -P dircolors &>/dev/null); then 46 | eval $(dircolors -b) 47 | alias ls='ls --color=auto' 48 | else 49 | # On OS X, get pleasant light blue back for directories 50 | export CLICOLOR=1 51 | export LSCOLORS=Exfxcxdxbxegedabagacad 52 | fi 53 | ;; 54 | *) 55 | PS1="\u@\h \w: " 56 | ;; 57 | esac 58 | 59 | 60 | -------------------------------------------------------------------------------- /powerline/themes/vim/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "segment_data": { 3 | "branch": { 4 | "before": " " 5 | }, 6 | "modified_indicator": { 7 | "args": { "text": "+" } 8 | }, 9 | "line_percent": { 10 | "args": { "gradient": true }, 11 | "after": "%" 12 | }, 13 | "line_current_symbol": { 14 | "contents": " " 15 | } 16 | }, 17 | "segments": { 18 | "left": [ 19 | { 20 | "name": "mode", 21 | "exclude_modes": ["nc"] 22 | }, 23 | { 24 | "name": "visual_range", 25 | "exclude_modes": ["nc"], 26 | "priority": 10 27 | }, 28 | { 29 | "name": "paste_indicator", 30 | "exclude_modes": ["nc"], 31 | "priority": 10 32 | }, 33 | { 34 | "name": "branch", 35 | "exclude_modes": ["nc"], 36 | "priority": 30 37 | }, 38 | { 39 | "name": "readonly_indicator", 40 | "draw_soft_divider": false, 41 | "after": " " 42 | }, 43 | { 44 | "name": "file_directory", 45 | "priority": 40, 46 | "draw_soft_divider": false 47 | }, 48 | { 49 | "name": "file_name", 50 | "draw_soft_divider": false 51 | }, 52 | { 53 | "name": "file_vcs_status", 54 | "before": " ", 55 | "draw_soft_divider": false 56 | }, 57 | { 58 | "name": "modified_indicator", 59 | "before": " " 60 | }, 61 | { 62 | "exclude_modes": ["nc"], 63 | "module": "powerline.segments.plugin.syntastic", 64 | "name": "syntastic", 65 | "priority": 50 66 | }, 67 | { 68 | "exclude_modes": ["nc"], 69 | "module": "powerline.segments.plugin.tagbar", 70 | "name": "current_tag", 71 | "draw_soft_divider": false, 72 | "priority": 50 73 | }, 74 | { 75 | "type": "string", 76 | "highlight_group": ["background"], 77 | "draw_soft_divider": false, 78 | "draw_hard_divider": false, 79 | "width": "auto" 80 | } 81 | ], 82 | "right": [ 83 | { 84 | "name": "character_info", 85 | "module": "custom", 86 | "draw_soft_divider": false 87 | }, 88 | { 89 | "name": "file_format", 90 | "draw_soft_divider": false, 91 | "exclude_modes": ["nc"], 92 | "priority": 60 93 | }, 94 | { 95 | "name": "file_encoding", 96 | "exclude_modes": ["nc"], 97 | "priority": 60 98 | }, 99 | { 100 | "name": "file_type", 101 | "exclude_modes": ["nc"], 102 | "priority": 60 103 | }, 104 | { 105 | "name": "line_percent", 106 | "priority": 50, 107 | "width": 4, 108 | "align": "r" 109 | }, 110 | { 111 | "type": "string", 112 | "name": "line_current_symbol", 113 | "highlight_group": ["line_current_symbol", "line_current"] 114 | }, 115 | { 116 | "name": "line_current", 117 | "draw_soft_divider": false, 118 | "width": 3, 119 | "align": "r" 120 | }, 121 | { 122 | "name": "virtcol_current", 123 | "draw_soft_divider": false, 124 | "priority": 20, 125 | "before": ":", 126 | "width": 3, 127 | "align": "l" 128 | } 129 | ] 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /sh/bash_functions: -------------------------------------------------------------------------------- 1 | # vim:ft=sh 2 | 3 | # These are basically just aliases, but complex enough to warrant a function. 4 | 5 | function wdi { 6 | export PS1="$ " 7 | alias cdw="cd ~/Documents/WDI\ DC\ November" 8 | clear 9 | cd ~/Documents/WDI\ DC\ November 10 | pwd 11 | ls 12 | } 13 | 14 | # http://superuser.com/a/560941 - default tmux rc 15 | # http://superuser.com/a/538719 - tmux shell semicolon escapes 16 | function default_tmux_rc { tmux -L unconfigured -f /dev/null start-server \; list-keys \; show-options -s \; show-options -g \; show-options -gw; } 17 | function gittotal { git log --author="Max Cantor" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; } 18 | function diffcount { egrep -v "^[-+]{3}" | egrep -o "^[-+]" | sort | uniq -c; } # to be piped after a diff 19 | function netlines { awk "/-/ { del=\$1 } /+/ { add=\$1 } END { print add - del }"; } # to be piped after diffcount() 20 | function zipit { zip -r $1 $2 --exclude \*\.svn/\*; } 21 | function :he { vim -c ":he $1" -c :only; } 22 | function find_symlinks { DIR=$1; shift; find $DIR -type l -maxdepth 1 "$@"; } 23 | function find_broken_symlinks { DIR=$1; shift; find -L $DIR -type l -maxdepth 1 "$@"; } 24 | function copy_ssh_pubkey { REMOTE=$1; cat ~/.ssh/id_rsa.pub | ssh $REMOTE 'umask 077; cat >> .ssh/authorized_keys'; } 25 | function capture { 26 | sudo dtrace -p "$1" -qn ' 27 | syscall::write*:entry 28 | /pid == $target && arg0 == 1/ { 29 | printf("%s", copyinstr(arg1, arg2)); 30 | } 31 | ' 32 | } 33 | 34 | TIMETRACK="$HOME/timetrack" 35 | function chin { echo "$(date +%s) $@" >> $TIMETRACK && tail -n5 $TIMETRACK; } 36 | #BEGINC="\[\033[1;34m\]" 37 | #ENDC="\[\033[0m\]" 38 | BEGINC="\033[1;34m" 39 | ENDC="\033[0m" 40 | function peek { awk -v BEGINC="$BEGINC" -v ENDC="$ENDC" '{ cmd = "date -d@"$1" +%r"; cmd | getline var; $1=""; print BEGINC var ENDC":"$0; }' $TIMETRACK; } 41 | 42 | # Android Development 10/01/2016 43 | 44 | # Fundamentals: https://developer.android.com/guide/components/fundamentals.html 45 | # Widgets: https://developer.android.com/guide/topics/appwidgets/index.html 46 | 47 | ANDROID_PACKAGE_DOMAIN="com.maxcantor" 48 | ANDROID_TARGET="android-2" 49 | 50 | # http://incise.org/android-development-on-the-command-line.html 51 | function create_android_project { 52 | android create project \ 53 | `# android list targets to show target IDs (android-23 is 6.0)` \ 54 | --target android-23 \ 55 | `# Project name 'Perfect Picture Widget' contains invalid characters.` \ 56 | `# Allowed characters are: a-z A-Z 0-9 _` \ 57 | --name "$1" \ 58 | `# naming conventions: http://stackoverflow.com/questions/6273892/android-package-name-convention` \ 59 | --package "$ANDROID_PACKAGE_DOMAIN.$2" \ 60 | `# https://developer.android.com/reference/android/app/Activity.html` \ 61 | --activity "$3" \ 62 | --path "$4" \ 63 | ; 64 | } 65 | 66 | function build_android_debug { 67 | ant debug install && adb shell "am start -n $ANDROID_PACKAGE_DOMAIN.$1/.$2"; 68 | } 69 | -------------------------------------------------------------------------------- /vim/.vim/after/autoload/netrw_gitignore.vim: -------------------------------------------------------------------------------- 1 | " netrw_gitignore#Hide: gitignore-based hiding 2 | " Function returns a string of comma separated patterns convenient for 3 | " assignment to `g:netrw_list_hide` option. 4 | " Function can take additional filenames as arguments, example: 5 | " netrw_gitignore#Hide('custom_gitignore1', 'custom_gitignore2') 6 | " 7 | " Usage examples: 8 | " let g:netrw_list_hide = netrw_gitignore#Hide() 9 | " let g:netrw_list_hide = netrw_gitignore#Hide() . 'more,hide,patterns' 10 | " 11 | " Copyright: Copyright (C) 2013 Bruno Sutic {{{1 12 | " Permission is hereby granted to use and distribute this code, 13 | " with or without modifications, provided that this copyright 14 | " notice is copied with it. Like anything else that's free, 15 | " netrw_gitignore.vim is provided *as is* and comes with no 16 | " warranty of any kind, either expressed or implied. By using 17 | " this plugin, you agree that in no event will the copyright 18 | " holder be liable for any damages resulting from the use 19 | " of this software. 20 | function! netrw_gitignore#Hide(...) 21 | let additional_files = a:000 22 | 23 | let default_files = ['.gitignore', '.git/info/exclude'] 24 | 25 | " get existing global/system gitignore files 26 | let global_gitignore = expand(substitute(system("git config --global core.excludesfile"), '\n', '', 'g')) 27 | if global_gitignore !=# '' 28 | let default_files = add(default_files, global_gitignore) 29 | endif 30 | let system_gitignore = expand(substitute(system("git config --system core.excludesfile"), '\n', '', 'g')) 31 | if system_gitignore !=# '' 32 | let default_files = add(default_files, system_gitignore) 33 | endif 34 | 35 | " append additional files if given as function arguments 36 | if additional_files !=# [] 37 | let files = extend(default_files, additional_files) 38 | else 39 | let files = default_files 40 | endif 41 | 42 | " keep only existing/readable files 43 | let gitignore_files = [] 44 | for file in files 45 | if filereadable(file) 46 | let gitignore_files = add(gitignore_files, file) 47 | endif 48 | endfor 49 | 50 | " get contents of gitignore patterns from those files 51 | let gitignore_lines = [] 52 | for file in gitignore_files 53 | for line in readfile(file) 54 | " filter empty lines and comments 55 | if line !~# '^#' && line !~# '^$' 56 | let gitignore_lines = add(gitignore_lines, line) 57 | endif 58 | endfor 59 | endfor 60 | 61 | " convert gitignore patterns to Netrw/Vim regex patterns 62 | let escaped_lines = [] 63 | for line in gitignore_lines 64 | let escaped = line 65 | let escaped = substitute(escaped, '\*\*', '*', 'g') 66 | let escaped = substitute(escaped, '\.', '\\.', 'g') 67 | let escaped = substitute(escaped, '\$', '\\$', 'g') 68 | let escaped = substitute(escaped, '*', '.*', 'g') 69 | " correction: dot, dollar and asterisks chars shouldn't be escaped when 70 | " within regex matching groups. 71 | let escaped = substitute(escaped, '\(\[[^]]*\)\zs\\\.', '\.', 'g') 72 | let escaped = substitute(escaped, '\(\[[^]]*\)\zs\\\$', '\$', 'g') 73 | let escaped = substitute(escaped, '\(\[[^]]*\)\zs\.\*', '*', 'g') 74 | let escaped_lines = add(escaped_lines, escaped) 75 | endfor 76 | 77 | return join(escaped_lines, ',') 78 | endfunction -------------------------------------------------------------------------------- /sh/.bash_profile: -------------------------------------------------------------------------------- 1 | DOTFILE_DIR="$HOME/$(<$HOME/.dotfile_directory)" 2 | 3 | # platform-specific stuff 4 | if [ $(uname -s) = "Darwin" ]; then 5 | PLATFORM="OSX" 6 | else 7 | PLATFORM="Linux" 8 | fi 9 | 10 | # Obviously. 11 | EDITOR='vim' 12 | 13 | # when using PuTTY on Windows 7 to connect to my Macbook Air, vim complains 14 | # that the ¬ character is an invalid argument to the 'listchars' option if 15 | # its 'encoding' is 'latin-1', but setting this environment variable causes 16 | # vim to use 'utf-8' as the value of 'encoding', which fixes the issue. 17 | # I'm not sure why this doesn't happen when sshing from PuTTY... it probably 18 | # has to do with the env set by local login shells vs. those created by the 19 | # ssh daemon. 20 | # 21 | # it seems like this affects a lot of other shell utilities as well, including 22 | # git: running 'git diff' before checking in this change results in 23 | # instead of the nbsp character, but running 'LANG=en_US.utf-8 git diff' shows 24 | # the correct output. 25 | LANG='en_US.utf-8' 26 | 27 | # https://golang.org/doc/code.html#GOPATH 28 | GOPATH="$HOME/src/go" 29 | 30 | # Load local private API keys 31 | [[ -f ~/.local/sh/api_keys ]] && . ~/.local/sh/api_keys 32 | 33 | # Just override the stupid path and start in my dotfiles bin 34 | PATH=$DOTFILE_DIR'/bin' 35 | 36 | # Nexus project 37 | [ -d $HOME/src/projects/nexus ] && PATH+=":$HOME/src/projects/nexus/exe" 38 | 39 | # Homebrew et al. 40 | [ -d /usr/local/bin ] && PATH+=':/usr/local/bin' 41 | 42 | # OSX stuff 43 | if [ "$PLATFORM" = "OSX" ]; then 44 | [ -d /opt/X11/bin ] && PATH+=':/opt/X11/bin' 45 | hash heroku 2>/dev/null && PATH+=':/usr/local/heroku/bin' 46 | hash pg_config 2>/dev/null && PATH+=":$(pg_config --bindir)" 47 | [ -d /usr/local/opt/coreutils/libexec/gnubin ] && PATH+=':/usr/local/opt/coreutils/libexec/gnubin' 48 | 49 | if [ -d $HOME/Library/Android/sdk ]; then 50 | ANDROID_HOME=$HOME/Library/Android/sdk 51 | PATH+=:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools 52 | fi 53 | fi 54 | 55 | # system stuff 56 | PATH+=':/usr/bin:/bin:/usr/sbin:/sbin' 57 | 58 | # other stuff 59 | [ -d "$GOPATH/bin" ] && PATH+=":$GOPATH/bin" 60 | 61 | # tmux opening in python virtualenv 62 | if [ -n "$VIRTUAL_ENV" ]; then 63 | PATH=$VIRTUAL_ENV/bin:$PATH 64 | fi 65 | 66 | # Now that the PATH has been set, we can source .bashrc (certain things in 67 | # .bashrc may rely on the path, particularly platform-specific stuff where we 68 | # will want to use the GNU version of basic utils like ls, dircolors, etc. 69 | # 70 | # .bashrc is read automatically by non-login shells, but most terminal clients 71 | # (including iTerm2 and tmux) launch bash as a login shell, so we need to 72 | # manually source it here. 73 | # 74 | # An example of a non-login shell is if you type "bash" into a bash prompt and 75 | # hit enter. The "inner", or "child" process will not be a login shell, and 76 | # thus it will read .bashrc directly while skipping this file. 77 | source $DOTFILE_DIR/sh/.bashrc 78 | 79 | # These together add a noticeable delay to shell startup time. I kinda want to 80 | # take them out and just manually run them as needed, but that seems awfully 81 | # pedantic even to me. 82 | hash rbenv 2>/dev/null && eval "$(rbenv init -)" 83 | hash pyenv 2>/dev/null && eval "$(pyenv init -)" 84 | 85 | # For convenient editing of ruby projects and gems 86 | RUBYLIB="./lib:." 87 | 88 | # https://iterm2.com/documentation-shell-integration.html 89 | test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash" 90 | 91 | # Since this file is supposedly read only once per login session, its variables 92 | # are exported so that child processes (including other bash sessions) will 93 | # have access to them. 94 | export PATH EDITOR LANG PLATFORM RUBYLIB GOPATH VIRTUAL_ENV ANDROID_HOME DOTFILE_DIR 95 | -------------------------------------------------------------------------------- /bin/bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | [[ -z "$EMAIL" ]] && EMAIL="max@maxcantor.net" 4 | [[ -z "$DOTFILE_DIRNAME" ]] && DOTFILE_DIRNAME=".common-public" 5 | [[ -z "$GET_PRIVATE" ]] && GET_PRIVATE=true 6 | 7 | echo $DOTFILE_DIRNAME > $HOME/.dotfile_directory 8 | 9 | DOTFILE_DIR="$HOME/$(<$HOME/.dotfile_directory)" 10 | 11 | # setup new ssh key 12 | if ! [ -d .ssh ]; then 13 | echo "Generating a new SSH key..." 14 | 15 | mkdir .ssh 16 | chmod 700 .ssh 17 | ssh-keygen -t rsa -N "" -C "$EMAIL" -f .ssh/id_rsa 18 | chmod 600 .ssh/id_rsa 19 | 20 | GITHUB_SSH_URL=https://github.com/settings/ssh 21 | 22 | if [ $(uname -s) = "Darwin" ]; then 23 | pbcopy < .ssh/id_rsa.pub 24 | open $GITHUB_SSH_URL 25 | else 26 | cat .ssh/id_rsa.pub 27 | echo 28 | echo $GITHUB_SSH_URL 29 | fi 30 | 31 | read -p "Hit ENTER after adding GitHub pubkey" 32 | else 33 | echo ".ssh directory already exists, not generating." 34 | fi 35 | 36 | if ! [ -d $DOTFILE_DIR ]; then 37 | echo "Getting dotfiles..." 38 | git clone git@github.com:mcantor/dotfiles.git $DOTFILE_DIR 39 | else 40 | echo "${DOTFILE_DIR} already exists; not cloning." 41 | fi 42 | 43 | if [ -d .common-private ]; then 44 | echo ".common-private already exists; not cloning." 45 | elif [ "$GET_PRIVATE" = false ]; then 46 | echo "\$GET_PRIVATE set to false; not cloning." 47 | else 48 | echo "Getting private files..." 49 | git clone makoto.kenpachi.net:common.git .common-private 50 | fi 51 | 52 | # OS X stuff 53 | if [ $(uname -s) = "Darwin" ]; then 54 | xcode-select --install 55 | 56 | # Make Finder quittable 57 | defaults write com.apple.finder QuitMenuItem -bool YES 58 | 59 | # homebrew must come first so we have ln from coreutils, which 60 | # is expected by the setup_common_symlinks script 61 | if ! hash brew 2>/dev/null; then 62 | echo "Installing Homebrew..." 63 | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 64 | hash -r 65 | 66 | if ! hash brew 2>/dev/null; then 67 | echo "brew did not seem to install successfully." 68 | exit 1 69 | fi 70 | fi 71 | 72 | # other stuff to do: 73 | # Install Charles Web Proxy, Sublime Text 2, Deckset 74 | # Install Anonymous Pro and Chevy Ray's Pixel Fonts 75 | # Install Moom, Alfred, iTerm 2, DragonDrop 76 | # Synchronize settings for Moom, Alfred, iTerm 2 77 | # Install Evernote, Photoshop 78 | # Install nice brushes for Photoshop 79 | 80 | brew install $(tr '\n' ' ' <$DOTFILE_DIR/sh/homebrew_packages) 81 | brew install findutils --with-default-names 82 | 83 | if brew ls redis 2>/dev/null; then 84 | ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents 85 | launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist 86 | fi 87 | 88 | if brew ls postgres 2>/dev/null; then 89 | ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents 90 | launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist 91 | fi 92 | fi 93 | 94 | # Ubuntu stuff 95 | if [ $(uname -s) = "Linux" ]; then 96 | sudo apt-get install build-essential 97 | 98 | # nginx 99 | sudo apt-get install nginx 100 | sudo groupadd nginx-admin 101 | sudo usermod -aG nginx-admin mcantor 102 | sudo chown -R root:nginx-admin /etc/nginx 103 | sudo chmod -R g+w /etc/nginx 104 | 105 | # ruby 106 | sudo apt-get install libssl-dev libreadline-dev zlib1g-dev 107 | echo "Setting up rbenv..." 108 | git clone https://github.com/rbenv/rbenv.git ~/.rbenv 109 | echo "Setting up ruby-build..." 110 | git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build 111 | 112 | # tmux 113 | sudo apt-get install automake pkg-config libevent-dev libncurses5-dev 114 | mdkir -p src 115 | (cd src && \ 116 | git clone https://github.com/tmux/tmux.git && \ 117 | cd tmux && \ 118 | git co 2.2 && \ 119 | sh autogen.sh && \ 120 | ./configure && \ 121 | make && \ 122 | sudo mv tmux /usr/local/bin) 123 | fi 124 | 125 | # setup dotfile symlinks 126 | echo "Sourcing bash profile" 127 | source $DOTFILE_DIR/sh/.bash_profile 128 | echo "Setting up home directory symlinks..." 129 | $DOTFILE_DIR/bin/setup_common_symlinks 130 | 131 | # vim stuff 132 | echo "Creating vim swap directories..." 133 | mkdir -p ~/.backups/{backups,swaps,undofiles} 134 | 135 | if ! [ -d ~/.vim/bundle/Vundle.vim ]; then 136 | echo "Installing Vundle for Vim..." 137 | git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim 138 | vim +PluginInstall +qall 139 | fi 140 | -------------------------------------------------------------------------------- /powerline/colorschemes/vim/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Default color scheme", 3 | "groups": { 4 | "background": { "fg": "white", "bg": "gray2" }, 5 | "background:divider": { "fg": "gray6", "bg": "gray2" }, 6 | "mode": { "fg": "darkestgreen", "bg": "brightgreen", "attr": ["bold"] }, 7 | "visual_range": { "fg": "brightestorange", "bg": "darkorange", "attr": ["bold"] }, 8 | "modified_indicator": { "fg": "brightyellow", "bg": "gray4", "attr": ["bold"] }, 9 | "paste_indicator": { "fg": "white", "bg": "mediumorange", "attr": ["bold"] }, 10 | "readonly_indicator": { "fg": "brightestred", "bg": "gray4" }, 11 | "branch": { "fg": "gray9", "bg": "gray4" }, 12 | "branch_dirty": { "fg": "brightyellow", "bg": "gray4" }, 13 | "branch_clean": { "fg": "gray9", "bg": "gray4" }, 14 | "branch:divider": { "fg": "gray7", "bg": "gray4" }, 15 | "file_directory": { "fg": "gray9", "bg": "gray4" }, 16 | "file_name": { "fg": "white", "bg": "gray4", "attr": ["bold"] }, 17 | "window_title": { "fg": "white", "bg": "gray4" }, 18 | "file_size": { "fg": "gray8", "bg": "gray2" }, 19 | "file_name_no_file": { "fg": "gray9", "bg": "gray4", "attr": ["bold"] }, 20 | "file_name_empty": { "fg": "gray9", "bg": "gray4" }, 21 | "file_format": { "fg": "gray8", "bg": "gray2" }, 22 | "file_encoding": { "fg": "gray8", "bg": "gray2" }, 23 | "file_type": { "fg": "gray8", "bg": "gray2" }, 24 | "file_vcs_status": { "fg": "brightestred", "bg": "gray4" }, 25 | "file_vcs_status_M": { "fg": "brightyellow", "bg": "gray4" }, 26 | "file_vcs_status_A": { "fg": "brightgreen", "bg": "gray4" }, 27 | "line_percent": { "fg": "gray9", "bg": "gray4" }, 28 | "line_percent_gradient": { "fg": "dark_green_gray", "bg": "gray4" }, 29 | "position": { "fg": "gray9", "bg": "gray4" }, 30 | "position_gradient": { "fg": "green_yellow_red", "bg": "gray4" }, 31 | "line_current": { "fg": "gray1", "bg": "gray10", "attr": ["bold"] }, 32 | "line_current_symbol": { "fg": "gray1", "bg": "gray10" }, 33 | "virtcol_current_gradient": { "fg": "dark_GREEN_Orange_red", "bg": "gray10" }, 34 | "col_current": { "fg": "gray6", "bg": "gray10" }, 35 | "modified_buffers": { "fg": "brightyellow", "bg": "gray2" }, 36 | "environment": { "fg": "gray8", "bg": "gray2" }, 37 | "error": { "fg": "brightestred", "bg": "darkred", "attr": ["bold"] }, 38 | "warning": { "fg": "brightyellow", "bg": "darkorange", "attr": ["bold"] }, 39 | "current_tag": { "fg": "gray9", "bg": "gray2" }, 40 | "current_character": { "fg": "gray9", "bg": "gray4" }, 41 | "current_character_utf": { "fg": "gray9", "bg": "darkred" } 42 | }, 43 | "mode_translations": { 44 | "nc": { 45 | "colors": { 46 | "brightyellow": "darkorange", 47 | "brightestred": "darkred", 48 | "gray0": "gray0", 49 | "gray1": "gray0", 50 | "gray2": "gray0", 51 | "gray3": "gray1", 52 | "gray4": "gray1", 53 | "gray5": "gray1", 54 | "gray6": "gray1", 55 | "gray7": "gray4", 56 | "gray8": "gray4", 57 | "gray9": "gray4", 58 | "gray10": "gray5", 59 | "white": "gray6", 60 | "dark_green_gray": "gray5" 61 | } 62 | }, 63 | "i": { 64 | "colors": { 65 | "gray0": "darkestblue", 66 | "gray1": "darkestblue", 67 | "gray2": "darkestblue", 68 | "gray3": "darkblue", 69 | "gray4": "darkblue", 70 | "gray5": "darkestcyan", 71 | "gray6": "darkestcyan", 72 | "gray7": "darkestcyan", 73 | "gray8": "mediumcyan", 74 | "gray9": "mediumcyan", 75 | "gray10": "mediumcyan", 76 | "green_yellow_red": "gray5", 77 | "dark_green_gray": "light_green_gray" 78 | }, 79 | "groups": { 80 | "mode": { "fg": "darkestcyan", "bg": "white", "attr": ["bold"] }, 81 | "background:divider": { "fg": "darkcyan", "bg": "darkestblue" }, 82 | "branch:divider": { "fg": "darkcyan", "bg": "darkblue" } 83 | } 84 | }, 85 | "v": { 86 | "groups": { 87 | "mode": { "fg": "darkorange", "bg": "brightestorange", "attr": ["bold"] } 88 | } 89 | }, 90 | "V": { 91 | "groups": { 92 | "mode": { "fg": "darkorange", "bg": "brightestorange", "attr": ["bold"] } 93 | } 94 | }, 95 | "^V": { 96 | "groups": { 97 | "mode": { "fg": "darkorange", "bg": "brightestorange", "attr": ["bold"] } 98 | } 99 | }, 100 | "R": { 101 | "groups": { 102 | "mode": { "fg": "white", "bg": "brightred", "attr": ["bold"] } 103 | } 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /bin/um: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys, os, subprocess 4 | 5 | # NOTES / TODO 6 | 7 | # [_] pop(0)s context hints until it doesn't find anymore so you can write 8 | # them in any order: 9 | # - um py if 10 | # - um if ruby 11 | # - um js array reverse 12 | # - um reverse python array 13 | # 14 | # [_] remembers prior language context, so if you do `um bash if file exists` 15 | # then next time you can just say `um if string equals` and it does bash 16 | # 17 | # [_] data-driven lookup to allow for always-excellent bash completion 18 | # 19 | # [_] make this into first project for new students?? 20 | # 21 | # [_] make OS-aware 22 | # 23 | # [_] prints context and summaries with syntax hilighting 24 | 25 | # USAGE: just make shit up i guess 26 | 27 | def um(args): 28 | if len(args) == 0: 29 | print("ok") 30 | sys.exit(0) 31 | 32 | post_processor = lambda cmd: None 33 | 34 | if args[0] == "ok": 35 | args.pop(0) 36 | cmd = do(args) 37 | post_processor = lambda cmd: subprocess.call(cmd.split(' ')) 38 | elif args[0].startswith("alias") or args[0].startswith("function"): 39 | do_alias(args.pop(0), args.pop(0), args) 40 | elif args[1].startswith("alias") or args[1].startswith("function"): 41 | do_alias(args.pop(1), args.pop(0), args) 42 | else: 43 | cmd = do(args) 44 | 45 | print(cmd) 46 | post_processor(cmd) 47 | 48 | def read_file(filename): 49 | fh = open(filename, 'r') 50 | return fh.read().strip() 51 | 52 | def dotfile_dir(): 53 | home = os.environ["HOME"] 54 | dir_name = read_file("{0}/.dotfile_directory".format(home)) 55 | return "{0}/{1}".format(home, dir_name) 56 | 57 | def append_line(filename, string): 58 | fh = open(filename, 'a') 59 | fh.write(string) 60 | return True 61 | 62 | def show_end_context(filename): 63 | fh = open(filename, 'r') 64 | lines = fh.readlines() 65 | print("".join(lines[-5:])) 66 | 67 | def do_alias(which, subcmd, args): 68 | which = { 69 | "alias": "alias", 70 | "aliases": "alias", 71 | "function": "function", 72 | "functions": "function" 73 | }[which] 74 | 75 | file_name = { 76 | "alias": "bash_aliases", 77 | "function": "bash_functions" 78 | }[which] 79 | 80 | path = "{0}/sh/{1}".format(dotfile_dir(), file_name) 81 | 82 | if subcmd == "add": 83 | pattern = { 84 | "alias": "alias {0}='{1}'", 85 | "function": "function {0} {{ {1}; }}" 86 | }[which] 87 | 88 | string = pattern.format(args[0], " ".join(args[1:])) 89 | string_c = color(string, "green") 90 | path_c = color(path, "red") 91 | 92 | confirmation = input("Append {0} to {1}?: ".format(string_c, path_c)) 93 | if confirmation == "" or confirmation == "y": 94 | append_line(path, string) 95 | show_end_context(path) 96 | 97 | sys.exit(0) 98 | 99 | def do(args): 100 | if args[0] == "if": 101 | if args[1] == "file": 102 | if args[2] == "exists": 103 | return '[ -e "$file" ]' 104 | 105 | elif args[1] == "string": 106 | if args[2] == "equals": 107 | return '[ "$string" = "$file" ]' 108 | 109 | elif args[0] == "android": 110 | if args[1] == "activate": 111 | if args[2] == "developer": 112 | return 'Settings -> About -> Tap "Build number" seven times' 113 | 114 | elif args[0] == "bash": 115 | if args[1] == "delete": 116 | if args[2] == "function": 117 | return 'unset -f $funcName' 118 | 119 | elif args[0] == "string": 120 | return '${String%ABC}' 121 | 122 | elif args[0] == "ok": 123 | 124 | if args[1] == 'start_postgres': 125 | # OS X only 126 | return 'pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start' 127 | 128 | elif args[1] == 'stop_postgres': 129 | # OS X only 130 | return 'pg_ctl -D /usr/local/var/postgres stop -s -m fast' 131 | 132 | elif args[1] == 'check_postgres': 133 | return 'pg_ctl -D /usr/local/var/postgres status' 134 | 135 | else: 136 | return None 137 | 138 | if cmd: 139 | print(cmd) 140 | 141 | def color(string, name, bold=False): 142 | attr = [] 143 | 144 | num = { 145 | "green": 32, 146 | "red": 31, 147 | }[name] 148 | 149 | attr.append(num) 150 | 151 | if bold: 152 | attr.append(1) 153 | 154 | attrs = ";".join(map(lambda a: str(a), attr)) 155 | 156 | return '\x1b[{0}m{1}\x1b[0m'.format(attrs, string) 157 | 158 | um(sys.argv[1:]) 159 | -------------------------------------------------------------------------------- /slice/setup_slice: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # vim: tw=0 sts=4 sw=4 et list 3 | 4 | function safe_update_sudoers { 5 | if [ -e /etc/sudoers.tmp -o "$(pidof visudo)" ]; then 6 | echo "/etc/sudoers busy, try again later" 7 | exit 1 8 | fi 9 | 10 | cp /etc/sudoers /etc/sudoers.bak 11 | cp /etc/sudoers /etc/sudoers.tmp 12 | 13 | chmod 0640 /etc/sudoers.tmp 14 | echo "$1" >> /etc/sudoers.tmp 15 | chmod 0440 /etc/sudoers.tmp 16 | 17 | mv /etc/sudoers.tmp /etc/sudoers 18 | } 19 | 20 | . slice_constants 21 | 22 | # check for files 23 | for file in $LOAD_PUBKEY $LOAD_REPO $LOAD_DB $LOAD_DOKU $LOAD_WP; do 24 | if ! [[ -s $file ]] || ! [[ -r $file ]]; then 25 | echo "Required file $file is empty or nonexistant." 26 | exit 1 27 | fi 28 | done 29 | 30 | for user in $HOSTED_USERS; do 31 | if ! [[ -s $PAYLOAD/users/$user.tar.gz ]] || ! [[ -r $PAYLOAD/users/$user.tar.gz ]]; then 32 | echo "Required file $file is empty or nonexistant." 33 | exit 1 34 | fi 35 | done 36 | 37 | # add admin user 38 | adduser $ADMIN_USERNAME --disabled-password --gecos "" 39 | safe_update_sudoers "$ADMIN_USERNAME ALL=(ALL) ALL" 40 | 41 | # populate ssh dir 42 | SSH=/home/$ADMIN_USERNAME/.ssh 43 | mkdir $SSH 44 | cp $LOAD_PUBKEY $SSH/authorized_keys 45 | chmod 700 $SSH 46 | chmod 600 $SSH/authorized_keys 47 | chown -R $ADMIN_USERNAME:$ADMIN_USERNAME $SSH 48 | 49 | # create & load svn repo 50 | aptitude -q -y install subversion 51 | svnadmin create $SVN_PATH 52 | svnadmin load -q $SVN_PATH < $LOAD_REPO 53 | 54 | # load homedir 55 | su $ADMIN_USERNAME -c "cd && rm .bashrc && svn co file://$SVN_PATH/home/branches/$HOME_BRANCH ." 56 | 57 | # create & load database 58 | # disable whiptail password prompt 59 | echo mysql-server-5.0 mysql-server/root_password password $TMP_PASSWORD | debconf-set-selections 60 | echo mysql-server-5.0 mysql-server/root_password_again password $TMP_PASSWORD | debconf-set-selections 61 | aptitude -q -y install mysql-server 62 | mysql -u root -p$TMP_PASSWORD < $LOAD_DB 63 | mysql -u root -p$TMP_PASSWORD -e "flush privileges;" 64 | 65 | # install webservers, staggered so lighttpd gets port 80 66 | chown -R mcantor:mcantor $SITES 67 | chown mcantor:www-data $SITES/*/log 68 | chmod g+w $SITES/*/log 69 | aptitude -q -y install php5-cgi php5-mysql lighttpd 70 | aptitude -q -y install apache2 libapache2-svn 71 | 72 | # checkout sites 73 | svn co file://$SVN_PATH/sites $SITES 74 | chown -R $ADMIN_USERNAME:$ADMIN_USERNAME $SITES 75 | chgrp -R www-data $SITES/*/log 76 | chmod g+w $SITES/*/log 77 | 78 | # lighty conf 79 | ln -sf /home/$ADMIN_USERNAME/etc/lighttpd.conf /etc/lighttpd/lighttpd.conf 80 | /etc/init.d/lighttpd restart 81 | 82 | # apache conf 83 | adduser svn --system --group --no-create-home --disabled-login --gecos "" 84 | chown -R svn:svn $SVN_PATH 85 | APACHE=/etc/apache2 86 | APACHE_ETC=/home/$ADMIN_USERNAME/etc/apache 87 | rm $APACHE/sites-enabled/default 88 | ln -sf $APACHE_ETC/apache2.conf $APACHE/apache2.conf 89 | ln -sf $APACHE_ETC/ports.conf $APACHE/ports.conf 90 | ln -sf $APACHE_ETC/envvars $APACHE/envvars 91 | ln -sf $SITES/svn/www/etc/vhost.conf $APACHE/sites-enabled/svn 92 | ln -sf /home/$ADMIN_USERNAME/etc/svn/authz $SVN_PATH/conf/authz 93 | ln -sf /home/$ADMIN_USERNAME/etc/svn/svn-auth-file-digest $SVN_PATH/conf/svn-auth-file-digest 94 | ln -sf $SVN_PATH/conf/svn-auth-file-digest $SVN_PATH/conf/svn-auth-file 95 | a2enmod auth_digest 96 | /etc/init.d/apache2 start 97 | 98 | # relocate from filesystem to apache repo 99 | su $ADMIN_USERNAME -c "svn switch --relocate {file://$SVN_PATH,$SVN_WEB}/home/branches/$HOME_BRANCH $HOME" 100 | su $ADMIN_USERNAME -c "svn switch --relocate {file://$SVN_PATH,$SVN_WEB}/home/trunk $HOME/.common" 101 | su $ADMIN_USERNAME -c "svn switch --relocate {file://$SVN_PATH,$SVN_WEB}/sites /var/sites" 102 | 103 | # apps 104 | mkdir $APPS 105 | 106 | # wiki 107 | tar -xvzf $LOAD_DOKU -C $APPS 108 | 109 | # checkout wiki docs 110 | WIKIDOCS=/home/$ADMIN_USERNAME/wikidocs 111 | svn co file://$SVN_PATH/documents/wiki/trunk $WIKIDOCS 112 | chown -R $ADMIN_USERNAME:www-data $WIKIDOCS 113 | chmod g+w -R $WIKIDOCS 114 | 115 | # wordpress 116 | tar -xvzf $LOAD_WP -C $APPS 117 | 118 | # configure timezone 119 | echo "America/New_York" > /etc/timezone 120 | dpkg-reconfigure -f noninteractive tzdata 121 | 122 | # add hosted users 123 | for file in $ETC_FILES; do 124 | cat $PAYLOAD/$file >> /etc/$file 125 | done 126 | 127 | # extract homedirs 128 | for user in $HOSTED_USERS; do 129 | tar -xvzf $PAYLOAD/users/$user.tar.gz -C /home 130 | done 131 | 132 | # install basic packages 133 | aptitude -q -y install screen ncurses-term man-db manpages ctags git-core mercurial 134 | 135 | # update 136 | aptitude -q -y update && aptitude -q -y safe-upgrade 137 | rm -f /etc/motd.tail 138 | -------------------------------------------------------------------------------- /sh/bash_git_prompt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function _update_git_variables { 4 | _update_git_dir &> /dev/null 5 | if [ "$?" -eq 0 ]; then 6 | _update_git_head 7 | _update_git_detached 8 | _update_git_branch 9 | _update_git_changes 10 | fi 11 | } 12 | 13 | function _update_git_dir { 14 | _git_dir="$(git rev-parse --git-dir)" 15 | } 16 | 17 | function _update_git_head { 18 | read _git_raw_head <"$_git_dir/HEAD" 19 | _git_head=${_git_raw_head#ref: } 20 | } 21 | 22 | function _update_git_detached { 23 | if [ "$_git_head" = "$_git_raw_head" ]; then 24 | _git_detached=$(git rev-parse --short HEAD) 25 | else 26 | _get_detached= 27 | fi 28 | } 29 | 30 | function _update_git_branch { 31 | if [ -n "$_git_detached" ]; then 32 | _git_branch=$(git describe --contains --all HEAD) 33 | else 34 | _git_branch=${_git_head##refs/heads/} 35 | fi 36 | } 37 | 38 | function _update_git_changes { 39 | _git_num_staged=$(git diff --cached --numstat | wc -l | tr -d ' ') 40 | _git_num_unstaged=$(git diff --numstat | wc -l | tr -d ' ') 41 | _git_num_untracked=$(git ls-files --others --exclude-standard | wc -l | tr -d ' ') 42 | _git_staged_color=$BG_DARK_GRAY$(git config --get-color color.status.added green) 43 | _git_unstaged_color=$BG_DARK_GRAY$(git config --get-color color.status.changed red) 44 | _git_untracked_color=$BG_DARK_GRAY$(git config --get-color color.status.untracked red) 45 | 46 | } 47 | 48 | # shamelessly ganked from official git repo's __git_ps1 49 | function prompt_git_activity { 50 | if [ -d "$_git_dir/rebase-merge" ]; then 51 | read step 2>/dev/null <"$_git_dir/rebase-merge/msgnum" 52 | read total 2>/dev/null <"$_git_dir/rebase-merge/end" 53 | if [ -f "$_git_dir/rebase-merge/interactive" ]; then 54 | act_message="REBASE-i" 55 | else 56 | act_message="REBASE-m" 57 | fi 58 | else 59 | if [ -d "$_git_dir/rebase-apply" ]; then 60 | read step 2>/dev/null <"$_git_dir/rebase-apply/next" 61 | read total 2>/dev/null <"$_git_dir/rebase-apply/last" 62 | if [ -f "$_git_dir/rebase-apply/rebasing" ]; then 63 | act_message="REBASING" 64 | elif [ -f "$_git_dir/rebase-apply/applying" ]; then 65 | act_message="AM" 66 | else 67 | act_message="AM/REBASE" 68 | fi 69 | elif [ -f "$_git_dir/MERGE_HEAD" ]; then 70 | act_message="MERGING" 71 | elif [ -f "$_git_dir/CHERRY_PICK_HEAD" ]; then 72 | act_message="CHERRY-PICKING" 73 | elif [ -f "$_git_dir/REVERT_HEAD" ]; then 74 | act_message="REVERTING" 75 | elif [ -f "$_git_dir/BISECT_LOG" ]; then 76 | act_message="BISECTING" 77 | fi 78 | fi 79 | 80 | if [ -n "$step" ] && [ -n "$total" ]; then 81 | act_message="$act_message $step/$total" 82 | fi 83 | 84 | [ -n "$act_message" ] && echo -ne "\x01${GIT_ACTIVITY_COLOR}\x02$act_message\x01${RESET}\x02" 85 | } 86 | 87 | function prompt_git_branch { 88 | echo -ne "\x01${GIT_BRANCH_COLOR}\x02${_git_branch}\x01${RESET}\x02" 89 | [ -n "$_git_detached" ] && echo -ne "|\x01${GIT_DETACHED_COLOR}\x020${_git_detached}\x01${RESET}\x02" 90 | } 91 | 92 | function prompt_git_changes { 93 | mode='symbols' # count, symbols 94 | 95 | case "$mode" in 96 | count) 97 | staged=$_git_num_staged 98 | unstaged=$_git_num_unstaged 99 | untracked=$_git_num_untracked 100 | ;; 101 | symbols) 102 | staged="+" 103 | unstaged="!" 104 | untracked="?" 105 | ;; 106 | esac 107 | 108 | # turns out there IS a way to escape colors from within a function, and it's 109 | # using \x01 and \x02. however, trying to output numbers directly after \x02 110 | # causes the first digit of the number to be consumed, so there is a 0 after 111 | # each \x02 before the variable in each line of output below. I have no idea 112 | # why it works, but it works :-( 113 | 114 | delimiter='|' 115 | count=0 116 | 117 | [ "$_git_num_staged" -gt "0" ] && (( count+=1 )) && echo -ne "\x01${_git_staged_color}\x02${staged}\x01${RESET}\x02" 118 | [ "$_git_num_unstaged" -gt "0" ] && [ "$count" -gt "0" ] && echo -ne "$delimiter" 119 | [ "$_git_num_unstaged" -gt "0" ] && (( count+=1 )) && echo -ne "\x01${_git_unstaged_color}\x02${unstaged}\x01${RESET}\x02" 120 | [ "$_git_num_untracked" -gt "0" ] && [ "$count" -gt "0" ] && echo -ne "$delimiter" 121 | [ "$_git_num_untracked" -gt "0" ] && (( count+=1 )) && echo -ne "\x01${_git_untracked_color}\x02${untracked}\x01${RESET}\x02" 122 | } 123 | 124 | function prompt_git { 125 | branch=$(prompt_git_branch) 126 | changes=$(prompt_git_changes) 127 | activity=$(prompt_git_activity) 128 | 129 | echo -ne "(" 130 | echo -ne "$branch" 131 | [ -n "$activity" ] && echo -ne "|$activity" 132 | echo -ne ")" 133 | [ -n "$changes" ] && echo -ne " [$changes]" 134 | } 135 | 136 | 137 | -------------------------------------------------------------------------------- /vim/.vim/colors/hhdgray.vim: -------------------------------------------------------------------------------- 1 | " Vim color file 2 | " Maintainer: max@maxcantor.net 3 | " Last Change: $Date$ 4 | " Version: $Id$ 5 | 6 | set background=dark 7 | hi clear 8 | if exists("syntax_on") 9 | syntax reset 10 | endif 11 | 12 | let g:colors_name = "hhdgray" 13 | 14 | hi Normal gui=NONE guifg=lightgray guibg=black 15 | hi Normal cterm=NONE ctermfg=lightgray ctermbg=NONE 16 | 17 | hi NonText gui=UNDERLINE guifg=darkgray guibg=black 18 | hi NonText cterm=UNDERLINE ctermfg=darkgray ctermbg=NONE 19 | hi Folded gui=NONE guifg=darkgray guibg=black 20 | hi Folded cterm=NONE ctermfg=darkgray ctermbg=NONE 21 | hi FoldColumn gui=NONE guifg=darkgray guibg=black 22 | hi FoldColumn cterm=NONE ctermfg=darkgray ctermbg=NONE 23 | hi StatusLineNC gui=UNDERLINE guifg=black guibg=darkgray 24 | hi StatusLineNC cterm=UNDERLINE ctermfg=black ctermbg=darkgray 25 | hi LineNr gui=NONE guifg=black guibg=lightgray 26 | hi LineNr cterm=NONE ctermfg=black ctermbg=lightgray 27 | hi VertSplit gui=NONE guifg=darkgray guibg=darkgray 28 | hi VertSplit cterm=NONE ctermfg=darkgray ctermbg=darkgray 29 | 30 | hi Title gui=UNDERLINE guifg=lightgray guibg=darkgray 31 | hi Title cterm=UNDERLINE ctermfg=lightgray ctermbg=darkgray 32 | 33 | hi MoreMsg gui=UNDERLINE guifg=black guibg=darkgray 34 | hi MoreMsg cterm=UNDERLINE ctermfg=black ctermbg=darkgray 35 | hi Question gui=UNDERLINE guifg=black guibg=darkgray 36 | hi Question cterm=UNDERLINE ctermfg=black ctermbg=darkgray 37 | 38 | hi StatusLine gui=UNDERLINE guifg=black guibg=gray 39 | hi StatusLine cterm=UNDERLINE ctermfg=black ctermbg=gray 40 | hi WildMenu gui=UNDERLINE guifg=black guibg=green 41 | hi WildMenu cterm=UNDERLINE ctermfg=black ctermbg=green 42 | hi Cursor gui=UNDERLINE guifg=black guibg=green 43 | hi Cursor cterm=UNDERLINE ctermfg=black ctermbg=green 44 | hi IncSearch gui=UNDERLINE guifg=black guibg=green 45 | hi IncSearch cterm=UNDERLINE ctermfg=black ctermbg=green 46 | hi Search gui=UNDERLINE guifg=black guibg=yellow 47 | hi Search cterm=UNDERLINE ctermfg=black ctermbg=yellow 48 | hi Visual gui=UNDERLINE guifg=black guibg=gray 49 | hi Visual cterm=UNDERLINE ctermfg=black ctermbg=gray 50 | 51 | hi ErrorMsg gui=UNDERLINE guifg=black guibg=red 52 | hi ErrorMsg cterm=UNDERLINE ctermfg=black ctermbg=red 53 | hi WarningMsg gui=UNDERLINE guifg=black guibg=yellow 54 | hi WarningMsg cterm=UNDERLINE ctermfg=black ctermbg=yellow 55 | hi ModeMsg gui=UNDERLINE guifg=black guibg=green 56 | hi ModeMsg cterm=UNDERLINE ctermfg=black ctermbg=green 57 | 58 | hi Ignore gui=NONE guifg=black guibg=black 59 | hi Ignore cterm=NONE ctermfg=darkgray ctermbg=black 60 | hi Todo gui=UNDERLINE guifg=black guibg=red 61 | hi Todo cterm=UNDERLINE ctermfg=black ctermbg=red 62 | hi Error gui=UNDERLINE guifg=lightgray guibg=red 63 | hi Error cterm=UNDERLINE ctermfg=lightgray ctermbg=red 64 | hi Special gui=NONE guifg=lightcyan guibg=black 65 | hi Special cterm=NONE ctermfg=lightcyan ctermbg=NONE 66 | hi Identifier gui=NONE guifg=cyan guibg=black 67 | hi Identifier cterm=NONE ctermfg=cyan ctermbg=NONE 68 | hi Constant gui=NONE guifg=lightred guibg=black 69 | hi Constant cterm=NONE ctermfg=lightred ctermbg=NONE 70 | hi Statement gui=NONE guifg=lightyellow guibg=black 71 | hi Statement cterm=NONE ctermfg=229 ctermbg=NONE 72 | hi Comment gui=NONE guifg=lightblue guibg=black 73 | hi Comment cterm=NONE ctermfg=lightblue ctermbg=NONE 74 | hi Underlined gui=UNDERLINE guifg=lightblue guibg=black 75 | hi Underlined cterm=UNDERLINE ctermfg=lightblue ctermbg=NONE 76 | hi PreProc gui=NONE guifg=lightmagenta guibg=black 77 | hi PreProc cterm=NONE ctermfg=lightmagenta ctermbg=NONE 78 | hi Type gui=NONE guifg=lightgreen guibg=black 79 | hi Type cterm=NONE ctermfg=lightgreen ctermbg=NONE 80 | 81 | hi SpecialKey gui=NONE guifg=cyan guibg=black 82 | hi SpecialKey cterm=NONE ctermfg=cyan ctermbg=NONE 83 | hi Directory gui=NONE guifg=lightgreen guibg=black 84 | hi Directory cterm=NONE ctermfg=lightgreen ctermbg=NONE 85 | hi LineNr gui=UNDERLINE guifg=black guibg=darkgray 86 | hi LineNr cterm=UNDERLINE ctermfg=black ctermbg=darkgray 87 | 88 | hi NonText gui=NONE guifg=darkgray guibg=black 89 | hi NonText cterm=NONE ctermfg=darkgray ctermbg=NONE 90 | 91 | hi DiffText gui=UNDERLINE guifg=black guibg=red 92 | hi DiffText cterm=UNDERLINE ctermfg=black ctermbg=red 93 | hi DiffChange gui=UNDERLINE guifg=black guibg=lightgray 94 | hi DiffChange cterm=UNDERLINE ctermfg=black ctermbg=lightgray 95 | hi DiffDelete gui=NONE guifg=black guibg=blue 96 | hi DiffDelete cterm=NONE ctermfg=black ctermbg=blue 97 | hi DiffAdd gui=UNDERLINE guifg=black guibg=cyan 98 | hi DiffAdd cterm=UNDERLINE ctermfg=black ctermbg=cyan 99 | 100 | hi htmlLink guifg=lightblue guibg=black 101 | hi htmlLink ctermfg=lightblue ctermbg=NONE 102 | 103 | hi htmlBold gui=bold 104 | hi htmlBold cterm=bold 105 | hi htmlUnderline gui=underline 106 | hi htmlUnderline cterm=underline 107 | hi htmlBoldUnderline gui=bold,underline 108 | hi htmlBoldUnderline cterm=bold,underline 109 | hi htmlItalic gui=italic 110 | hi htmlItalic cterm=italic 111 | hi htmlBoldItalic gui=bold,italic 112 | hi htmlBoldItalic cterm=bold,italic 113 | hi htmlUnderlineItalic gui=underline,italic 114 | hi htmlUnderlineItalic cterm=underline,italic 115 | hi htmlBoldUnderlineItalic gui=bold,underline,italic 116 | hi htmlBoldUnderlineItalic cterm=bold,underline,italic 117 | 118 | hi Pmenu cterm=bold ctermbg=brown guibg=brown gui=bold 119 | -------------------------------------------------------------------------------- /bin/num256colors: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | push(@arr, [( " 16: 00/00/00", " 17: 00/00/5f", " 18: 00/00/87", " 19: 00/00/af", " 20: 00/00/d7", " 21: 00/00/ff")] ); 4 | push(@arr, [( " 22: 00/5f/00", " 23: 00/5f/5f", " 24: 00/5f/87", " 25: 00/5f/af", " 26: 00/5f/d7", " 27: 00/5f/ff")] ); 5 | push(@arr, [( " 28: 00/87/00", " 29: 00/87/5f", " 30: 00/87/87", " 31: 00/87/af", " 32: 00/87/d7", " 33: 00/87/ff")] ); 6 | push(@arr, [( " 34: 00/af/00", " 35: 00/af/5f", " 36: 00/af/87", " 37: 00/af/af", " 38: 00/af/d7", " 39: 00/af/ff")] ); 7 | push(@arr, [( " 40: 00/d7/00", " 41: 00/d7/5f", " 42: 00/d7/87", " 43: 00/d7/af", " 44: 00/d7/d7", " 45: 00/d7/ff")] ); 8 | push(@arr, [( " 46: 00/ff/00", " 47: 00/ff/5f", " 48: 00/ff/87", " 49: 00/ff/af", " 50: 00/ff/d7", " 51: 00/ff/ff")] ); 9 | push(@arr, [( " 52: 5f/00/00", " 53: 5f/00/5f", " 54: 5f/00/87", " 55: 5f/00/af", " 56: 5f/00/d7", " 57: 5f/00/ff")] ); 10 | push(@arr, [( " 58: 5f/5f/00", " 59: 5f/5f/5f", " 60: 5f/5f/87", " 61: 5f/5f/af", " 62: 5f/5f/d7", " 63: 5f/5f/ff")] ); 11 | push(@arr, [( " 64: 5f/87/00", " 65: 5f/87/5f", " 66: 5f/87/87", " 67: 5f/87/af", " 68: 5f/87/d7", " 69: 5f/87/ff")] ); 12 | push(@arr, [( " 70: 5f/af/00", " 71: 5f/af/5f", " 72: 5f/af/87", " 73: 5f/af/af", " 74: 5f/af/d7", " 75: 5f/af/ff")] ); 13 | push(@arr, [( " 76: 5f/d7/00", " 77: 5f/d7/5f", " 78: 5f/d7/87", " 79: 5f/d7/af", " 80: 5f/d7/d7", " 81: 5f/d7/ff")] ); 14 | push(@arr, [( " 82: 5f/ff/00", " 83: 5f/ff/5f", " 84: 5f/ff/87", " 85: 5f/ff/af", " 86: 5f/ff/d7", " 87: 5f/ff/ff")] ); 15 | push(@arr, [( " 88: 87/00/00", " 89: 87/00/5f", " 90: 87/00/87", " 91: 87/00/af", " 92: 87/00/d7", " 93: 87/00/ff")] ); 16 | push(@arr, [( " 94: 87/5f/00", " 95: 87/5f/5f", " 96: 87/5f/87", " 97: 87/5f/af", " 98: 87/5f/d7", " 99: 87/5f/ff")] ); 17 | push(@arr, [( " 100: 87/87/00", " 101: 87/87/5f", " 102: 87/87/87", " 103: 87/87/af", " 104: 87/87/d7", " 105: 87/87/ff")] ); 18 | push(@arr, [( " 106: 87/af/00", " 107: 87/af/5f", " 108: 87/af/87", " 109: 87/af/af", " 110: 87/af/d7", " 111: 87/af/ff")] ); 19 | push(@arr, [( " 112: 87/d7/00", " 113: 87/d7/5f", " 114: 87/d7/87", " 115: 87/d7/af", " 116: 87/d7/d7", " 117: 87/d7/ff")] ); 20 | push(@arr, [( " 118: 87/ff/00", " 119: 87/ff/5f", " 120: 87/ff/87", " 121: 87/ff/af", " 122: 87/ff/d7", " 123: 87/ff/ff")] ); 21 | push(@arr, [( " 124: af/00/00", " 125: af/00/5f", " 126: af/00/87", " 127: af/00/af", " 128: af/00/d7", " 129: af/00/ff")] ); 22 | push(@arr, [( " 130: af/5f/00", " 131: af/5f/5f", " 132: af/5f/87", " 133: af/5f/af", " 134: af/5f/d7", " 135: af/5f/ff")] ); 23 | push(@arr, [( " 136: af/87/00", " 137: af/87/5f", " 138: af/87/87", " 139: af/87/af", " 140: af/87/d7", " 141: af/87/ff")] ); 24 | push(@arr, [( " 142: af/af/00", " 143: af/af/5f", " 144: af/af/87", " 145: af/af/af", " 146: af/af/d7", " 147: af/af/ff")] ); 25 | push(@arr, [( " 148: af/d7/00", " 149: af/d7/5f", " 150: af/d7/87", " 151: af/d7/af", " 152: af/d7/d7", " 153: af/d7/ff")] ); 26 | push(@arr, [( " 154: af/ff/00", " 155: af/ff/5f", " 156: af/ff/87", " 157: af/ff/af", " 158: af/ff/d7", " 159: af/ff/ff")] ); 27 | push(@arr, [( " 160: d7/00/00", " 161: d7/00/5f", " 162: d7/00/87", " 163: d7/00/af", " 164: d7/00/d7", " 165: d7/00/ff")] ); 28 | push(@arr, [( " 166: d7/5f/00", " 167: d7/5f/5f", " 168: d7/5f/87", " 169: d7/5f/af", " 170: d7/5f/d7", " 171: d7/5f/ff")] ); 29 | push(@arr, [( " 172: d7/87/00", " 173: d7/87/5f", " 174: d7/87/87", " 175: d7/87/af", " 176: d7/87/d7", " 177: d7/87/ff")] ); 30 | push(@arr, [( " 178: d7/af/00", " 179: d7/af/5f", " 180: d7/af/87", " 181: d7/af/af", " 182: d7/af/d7", " 183: d7/af/ff")] ); 31 | push(@arr, [( " 184: d7/d7/00", " 185: d7/d7/5f", " 186: d7/d7/87", " 187: d7/d7/af", " 188: d7/d7/d7", " 189: d7/d7/ff")] ); 32 | push(@arr, [( " 190: d7/ff/00", " 191: d7/ff/5f", " 192: d7/ff/87", " 193: d7/ff/af", " 194: d7/ff/d7", " 195: d7/ff/ff")] ); 33 | push(@arr, [( " 196: ff/00/00", " 197: ff/00/5f", " 198: ff/00/87", " 199: ff/00/af", " 200: ff/00/d7", " 201: ff/00/ff")] ); 34 | push(@arr, [( " 202: ff/5f/00", " 203: ff/5f/5f", " 204: ff/5f/87", " 205: ff/5f/af", " 206: ff/5f/d7", " 207: ff/5f/ff")] ); 35 | push(@arr, [( " 208: ff/87/00", " 209: ff/87/5f", " 210: ff/87/87", " 211: ff/87/af", " 212: ff/87/d7", " 213: ff/87/ff")] ); 36 | push(@arr, [( " 214: ff/af/00", " 215: ff/af/5f", " 216: ff/af/87", " 217: ff/af/af", " 218: ff/af/d7", " 219: ff/af/ff")] ); 37 | push(@arr, [( " 220: ff/d7/00", " 221: ff/d7/5f", " 222: ff/d7/87", " 223: ff/d7/af", " 224: ff/d7/d7", " 225: ff/d7/ff")] ); 38 | push(@arr, [( " 226: ff/ff/00", " 227: ff/ff/5f", " 228: ff/ff/87", " 229: ff/ff/af", " 230: ff/ff/d7", " 231: ff/ff/ff")] ); 39 | push(@arr, [( " 232: 08/08/08", " 233: 12/12/12", " 234: 1c/1c/1c", " 235: 26/26/26", " 236: 30/30/30", " 237: 3a/3a/3a")] ); 40 | push(@arr, [( " 238: 44/44/44", " 239: 4e/4e/4e", " 240: 58/58/58", " 241: 62/62/62", " 242: 6c/6c/6c", " 243: 76/76/76")] ); 41 | push(@arr, [( " 244: 80/80/80", " 245: 8a/8a/8a", " 246: 94/94/94", " 247: 9e/9e/9e", " 248: a8/a8/a8", " 249: b2/b2/b2")] ); 42 | push(@arr, [( " 250: bc/bc/bc", " 251: c6/c6/c6", " 252: d0/d0/d0", " 253: da/da/da", " 254: e4/e4/e4", " 255: ee/ee/ee")] ); 43 | 44 | $padding = " "; 45 | 46 | for( $dimone = 0; $dimone < scalar @arr; $dimone++ ) { 47 | 48 | $seed = ($dimone % 6) * -1; 49 | for( $dimtwo = 0; $dimtwo < 6; $dimtwo++ ) { 50 | 51 | $movone = $seed; 52 | $movtwo = $seed * -1; 53 | 54 | $newone = $dimone+$movone; 55 | $newtwo = $dimtwo+$movtwo; 56 | 57 | if( $newone < scalar @arr ){ 58 | print $arr[$newone][$newtwo] . $padding; 59 | } 60 | 61 | $seed = $seed+1; 62 | } 63 | 64 | print "\n"; 65 | } 66 | exit; 67 | -------------------------------------------------------------------------------- /powerline/colors.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors": { 3 | "black": 16, 4 | "white": 231, 5 | 6 | "darkestgreen": 22, 7 | "darkgreen": 28, 8 | "mediumgreen": 70, 9 | "brightgreen": 148, 10 | 11 | "darkestcyan": 23, 12 | "darkcyan": 74, 13 | "mediumcyan": 117, 14 | "brightcyan": 159, 15 | 16 | "darkestblue": 24, 17 | "darkblue": 31, 18 | 19 | "darkestred": 52, 20 | "darkred": 88, 21 | "mediumred": 124, 22 | "brightred": 160, 23 | "brightestred": 196, 24 | 25 | "darkestpurple": 55, 26 | "mediumpurple": 98, 27 | "brightpurple": 189, 28 | 29 | "darkorange": 94, 30 | "mediumorange": 166, 31 | "brightorange": 208, 32 | "brightestorange": 214, 33 | 34 | "brightyellow": 220, 35 | 36 | "gray0": 233, 37 | "gray1": 235, 38 | "gray2": 236, 39 | "gray3": 239, 40 | "gray4": 240, 41 | "gray5": 241, 42 | "gray6": 244, 43 | "gray7": 245, 44 | "gray8": 247, 45 | "gray9": 250, 46 | "gray10": 252, 47 | 48 | "gray61": [14, "93a1a1"], 49 | "gray13": [8, "002b36"], 50 | 51 | "royalblue5": [0, "073642"], 52 | "darkgreencopper": [10, "586e75"], 53 | "lightskyblue4": [11, "657b83"], 54 | "azure4": [12, "839496"], 55 | "lightyellow": [7, "eee8d5"], 56 | "oldlace": [15, "fdf6e3"], 57 | 58 | "green": [2, "719e07"], 59 | "cyan": [6, "2aa198"], 60 | "blue": [4, "268bd2"], 61 | "red": [1, "dc322f"], 62 | "magenta": [5, "d33682"], 63 | "violet": [13, "6c71c4"], 64 | "orange": [9, "cb4b16"], 65 | "yellow": [3, "b58900"], 66 | 67 | "lightyellowgreen": 106, 68 | "gold3": 178, 69 | "orangered": 202, 70 | 71 | "steelblue": 67, 72 | "darkorange3": 166, 73 | "skyblue1": 117, 74 | "khaki1": 228 75 | }, 76 | "gradients": { 77 | "dark_GREEN_Orange_red": [ 78 | [22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 94, 94, 94, 94, 94, 94, 94, 88, 52], 79 | ["006000", "006000", "006000", "006000", "006000", "006000", "006000", "006000", "006000", "036000", "076000", "0a6000", "0d6000", "106000", "126000", "146000", "166000", "186000", "1a6000", "1b6000", "1d6000", "1e6000", "206000", "216000", "236000", "246000", "256000", "266000", "286000", "296000", "2a6000", "2b6000", "2c6100", "2d6100", "2f6100", "306100", "316100", "326100", "336100", "346100", "356100", "366100", "376100", "386100", "386100", "396100", "3a6100", "3b6100", "3c6100", "3d6100", "3e6100", "3f6100", "406100", "406100", "416100", "426000", "436000", "446000", "456000", "456000", "466000", "476000", "486000", "496000", "496000", "4a6000", "4b6000", "4c6000", "4d6000", "4d6000", "4e6000", "4f6000", "506000", "506000", "516000", "526000", "536000", "536000", "546000", "556000", "566000", "566000", "576000", "586000", "596000", "596000", "5a6000", "5d6000", "616000", "646000", "686000", "6b6000", "6f6000", "726000", "766000", "796000", "7d6000", "806000", "7e5500", "6f3105", "5d0001"] 80 | ], 81 | "GREEN_Orange_red": [ 82 | [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1], 83 | ["005f00", "015f00", "025f00", "035f00", "045f00", "055f00", "065f00", "075f00", "085f00", "095f00", "0b5f00", "0c5f00", "0d5f00", "0e5f00", "0f5f00", "105f00", "115f00", "125f00", "135f00", "145f00", "165f00", "175f00", "185f00", "195f00", "1a5f00", "1b5f00", "1c5f00", "1d5f00", "1e5f00", "1f5f00", "215f00", "225f00", "235f00", "245f00", "255f00", "265f00", "275f00", "285f00", "295f00", "2a5f00", "2c5f00", "2d5f00", "2e5f00", "2f5f00", "305f00", "315f00", "325f00", "335f00", "345f00", "355f00", "375f00", "385f00", "395f00", "3a5f00", "3b5f00", "3c5f00", "3d5f00", "3e5f00", "3f5f00", "415f00", "425f00", "435f00", "445f00", "455f00", "465f00", "475f00", "485f00", "495f00", "4a5f00", "4c5f00", "4d5f00", "4e5f00", "4f5f00", "505f00", "515f00", "525f00", "535f00", "545f00", "555f00", "575f00", "585f00", "595f00", "5a5f00", "5b5f00", "5c5f00", "5d5f00", "5e5f00", "615f00", "655f00", "685f00", "6c5f00", "6f5f00", "735f00", "765f00", "7a5f00", "7d5f00", "815f00", "845f00", "815200", "702900"] 84 | ], 85 | "green_yellow_red": [ 86 | [190, 184, 178, 172, 166, 160], 87 | ["8ae71c", "8ce71c", "8fe71c", "92e71c", "95e71d", "98e71d", "9ae71d", "9de71d", "a0e71e", "a3e71e", "a6e71e", "a8e71e", "abe71f", "aee71f", "b1e71f", "b4e71f", "b6e720", "b9e720", "bce720", "bfe720", "c2e821", "c3e721", "c5e621", "c7e521", "c9e522", "cbe422", "cde322", "cfe222", "d1e223", "d3e123", "d5e023", "d7df23", "d9df24", "dbde24", "dddd24", "dfdc24", "e1dc25", "e3db25", "e5da25", "e7d925", "e9d926", "e9d626", "e9d426", "e9d126", "e9cf27", "e9cc27", "e9ca27", "e9c727", "e9c528", "e9c228", "e9c028", "e9bd28", "e9bb29", "e9b829", "e9b629", "e9b329", "e9b12a", "e9ae2a", "e9ac2a", "e9a92a", "eaa72b", "eaa42b", "eaa22b", "ea9f2b", "ea9d2c", "ea9b2c", "ea982c", "ea962c", "ea942d", "ea912d", "ea8f2d", "ea8d2d", "ea8a2e", "ea882e", "ea862e", "ea832e", "ea812f", "ea7f2f", "ea7c2f", "ea7a2f", "eb7830", "eb7530", "eb7330", "eb7130", "eb6f31", "eb6c31", "eb6a31", "eb6831", "eb6632", "eb6332", "eb6132", "eb5f32", "eb5d33", "eb5a33", "eb5833", "eb5633", "eb5434", "eb5134", "eb4f34", "eb4d34", "ec4b35"] 88 | ], 89 | "green_yellow_orange_red": [ 90 | [2, 3, 9, 1], 91 | ["719e07", "739d06", "759c06", "779c06", "799b06", "7b9a05", "7d9a05", "7f9905", "819805", "839805", "859704", "879704", "899604", "8b9504", "8d9504", "8f9403", "919303", "949303", "969203", "989102", "9a9102", "9c9002", "9e9002", "a08f02", "a28e01", "a48e01", "a68d01", "a88c01", "aa8c01", "ac8b00", "ae8a00", "b08a00", "b28900", "b58900", "b58700", "b68501", "b78302", "b78102", "b87f03", "b97d04", "b97b04", "ba7905", "bb7806", "bb7606", "bc7407", "bd7208", "bd7008", "be6e09", "bf6c0a", "bf6a0a", "c0690b", "c1670c", "c1650c", "c2630d", "c3610e", "c35f0e", "c45d0f", "c55b10", "c55a10", "c65811", "c75612", "c75412", "c85213", "c95014", "c94e14", "ca4c15", "cb4b16", "cb4a16", "cc4917", "cc4818", "cd4719", "cd4719", "ce461a", "ce451b", "cf441c", "cf441c", "d0431d", "d0421e", "d1411f", "d1411f", "d24020", "d23f21", "d33e22", "d33e22", "d43d23", "d43c24", "d53b25", "d53b25", "d63a26", "d63927", "d73828", "d73828", "d83729", "d8362a", "d9352b", "d9352b", "da342c", "da332d", "db322e", "dc322f"] 92 | ], 93 | "yellow_red": [ 94 | [220, 178, 172, 166, 160], 95 | ["ffd700", "fdd500", "fbd300", "fad200", "f8d000", "f7cf00", "f5cd00", "f3cb00", "f2ca00", "f0c800", "efc700", "edc500", "ebc300", "eac200", "e8c000", "e7bf00", "e5bd00", "e3bb00", "e2ba00", "e0b800", "dfb700", "ddb500", "dbb300", "dab200", "d8b000", "d7af00", "d7ad00", "d7ab00", "d7aa00", "d7a800", "d7a700", "d7a500", "d7a300", "d7a200", "d7a000", "d79f00", "d79d00", "d79b00", "d79a00", "d79800", "d79700", "d79500", "d79300", "d79200", "d79000", "d78f00", "d78d00", "d78b00", "d78a00", "d78800", "d78700", "d78500", "d78300", "d78200", "d78000", "d77f00", "d77d00", "d77b00", "d77a00", "d77800", "d77700", "d77500", "d77300", "d77200", "d77000", "d76f00", "d76d00", "d76b00", "d76a00", "d76800", "d76700", "d76500", "d76300", "d76200", "d76000", "d75f00", "d75b00", "d75700", "d75300", "d74f00", "d74c00", "d74800", "d74400", "d74000", "d73c00", "d73900", "d73500", "d73100", "d72d00", "d72900", "d72600", "d72200", "d71e00", "d71a00", "d71600", "d71300", "d70f00", "d70b00", "d70700"] 96 | ], 97 | "yellow_orange_red": [ 98 | [3, 9, 1], 99 | ["b58900", "b58700", "b58600", "b68501", "b68401", "b78202", "b78102", "b88003", "b87f03", "b87d03", "b97c04", "b97b04", "ba7a05", "ba7805", "bb7706", "bb7606", "bc7507", "bc7307", "bc7207", "bd7108", "bd7008", "be6e09", "be6d09", "bf6c0a", "bf6b0a", "c06a0b", "c0680b", "c0670b", "c1660c", "c1650c", "c2630d", "c2620d", "c3610e", "c3600e", "c35e0e", "c45d0f", "c45c0f", "c55b10", "c55910", "c65811", "c65711", "c75612", "c75412", "c75312", "c85213", "c85113", "c94f14", "c94e14", "ca4d15", "ca4c15", "cb4b16", "cb4a16", "cb4a17", "cc4917", "cc4918", "cc4818", "cd4819", "cd4719", "cd471a", "ce461a", "ce461b", "ce451b", "cf451c", "cf441c", "cf441d", "d0431d", "d0431e", "d0421e", "d1421f", "d1411f", "d14120", "d24020", "d24021", "d23f21", "d33f22", "d33e22", "d33e23", "d43d23", "d43d24", "d43c24", "d53c25", "d53b25", "d53b26", "d63a26", "d63a27", "d63927", "d73928", "d73828", "d73829", "d83729", "d8372a", "d8362a", "d9362b", "d9352b", "d9352c", "da342c", "da342d", "da332d", "db332e"] 100 | ], 101 | "blue_red": [ 102 | [39, 74, 68, 67, 103, 97, 96, 132, 131, 167, 203, 197], 103 | ["19b4fe", "1bb2fc", "1db1fa", "1faff8", "22aef6", "24adf4", "26abf2", "29aaf0", "2ba9ee", "2da7ec", "30a6ea", "32a5e8", "34a3e6", "36a2e4", "39a0e2", "3b9fe1", "3d9edf", "409cdd", "429bdb", "449ad9", "4798d7", "4997d5", "4b96d3", "4d94d1", "5093cf", "5292cd", "5490cb", "578fc9", "598dc7", "5b8cc6", "5e8bc4", "6089c2", "6288c0", "6487be", "6785bc", "6984ba", "6b83b8", "6e81b6", "7080b4", "727eb2", "757db0", "777cae", "797aac", "7b79ab", "7e78a9", "8076a7", "8275a5", "8574a3", "8772a1", "89719f", "8c709d", "8e6e9b", "906d99", "926b97", "956a95", "976993", "996791", "9c668f", "9e658e", "a0638c", "a3628a", "a56188", "a75f86", "a95e84", "ac5c82", "ae5b80", "b05a7e", "b3587c", "b5577a", "b75678", "ba5476", "bc5374", "be5273", "c05071", "c34f6f", "c54e6d", "c74c6b", "ca4b69", "cc4967", "ce4865", "d14763", "d34561", "d5445f", "d7435d", "da415b", "dc4059", "de3f58", "e13d56", "e33c54", "e53a52", "e83950", "ea384e", "ec364c", "ee354a", "f13448", "f33246", "f53144", "f83042", "fa2e40"] 104 | ], 105 | "white_red": [ 106 | [231, 255, 223, 216, 209, 202, 196], 107 | ["ffffff", "fefefe", "fdfdfd", "fdfdfd", "fcfcfc", "fbfbfb", "fafafa", "fafafa", "f9f9f9", "f8f8f8", "f7f7f7", "f7f7f7", "f6f6f6", "f5f5f5", "f4f4f4", "f4f3f4", "f3f3f3", "f2f2f2", "f1f1f1", "f0f0f0", "f0f0f0", "efefef", "eeeeee", "efecea", "f1eae4", "f2e8de", "f3e6d8", "f5e4d3", "f6e2cd", "f7e0c7", "f8dec2", "f9dcbc", "fadab6", "fad8b1", "fbd5ac", "fbd2a9", "fbcea5", "fbcaa1", "fbc79e", "fbc39a", "fbc097", "fbbc93", "fbb88f", "fbb58c", "fab188", "faad85", "faaa81", "fba67e", "fba37a", "fb9f76", "fb9c73", "fb986f", "fb946c", "fb9168", "fa8d65", "fa8961", "fa865c", "fa8256", "fb7f4f", "fb7b48", "fb7841", "fb743a", "fb7133", "fb6d2c", "fa6a23", "fa661a", "fa620e", "fa5f03", "fa5d03", "fa5b03", "fa5a03", "fa5803", "fa5703", "fa5503", "fa5303", "fa5103", "fa4f03", "fa4e03", "fa4c03", "fa4a04", "fa4804", "fa4604", "fa4404", "fa4204", "fa3f04", "fa3d04", "fa3b04", "fa3805", "fa3605", "fa3305", "fb3105", "fb2e05", "fb2a05", "fb2705", "fb2306", "fb1f06", "fb1b06", "fb1506", "fb0e06", "fa0506", "fa0007"] 108 | ], 109 | "dark_green_gray": [ 110 | [70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247], 111 | ["51b000", "52b000", "54b000", "55b002", "56b007", "57b00d", "58b011", "59af15", "5aaf18", "5caf1b", "5daf1e", "5eaf21", "5faf23", "60ae25", "61ae27", "62ae2a", "63ae2c", "64ae2e", "65ae30", "66ae31", "67ad33", "68ad35", "69ad37", "69ad38", "6aad3a", "6bad3c", "6cac3d", "6dac3f", "6eac40", "6fac42", "70ac44", "70ac45", "71ab47", "72ab48", "73ab49", "74ab4b", "75ab4c", "75ab4e", "76aa4f", "77aa51", "78aa52", "79aa53", "79aa55", "7aaa56", "7ba957", "7ca959", "7ca95a", "7da95b", "7ea95d", "7fa95e", "7fa85f", "80a861", "81a862", "81a863", "82a865", "83a766", "83a767", "84a768", "85a76a", "85a76b", "86a66c", "87a66d", "87a66f", "88a670", "89a671", "89a672", "8aa574", "8ba575", "8ba576", "8ca577", "8da579", "8da47a", "8ea47b", "8ea47c", "8fa47d", "90a47f", "90a380", "91a381", "91a382", "92a384", "93a385", "93a286", "94a287", "94a288", "95a28a", "95a18b", "96a18c", "97a18d", "97a18e", "98a190", "98a091", "99a092", "99a093", "9aa094", "9aa096", "9b9f97", "9b9f98", "9c9f99", "9c9f9a", "9d9e9c", "9d9e9d"] 112 | ], 113 | "light_green_gray": [ 114 | [148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 187, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250], 115 | ["a3d900", "a4d800", "a4d800", "a5d805", "a5d80d", "a6d714", "a6d719", "a6d71d", "a7d621", "a7d625", "a8d628", "a8d62b", "a8d52e", "a9d531", "a9d533", "aad536", "aad438", "aad43a", "abd43d", "abd33f", "abd341", "acd343", "acd345", "acd247", "add249", "add24b", "add14d", "aed14f", "aed151", "aed152", "afd054", "afd056", "afd058", "b0d059", "b0cf5b", "b0cf5d", "b1cf5e", "b1ce60", "b1ce62", "b1ce63", "b2ce65", "b2cd67", "b2cd68", "b3cd6a", "b3cc6b", "b3cc6d", "b3cc6e", "b4cc70", "b4cb71", "b4cb73", "b4cb75", "b5ca76", "b5ca78", "b5ca79", "b5ca7a", "b6c97c", "b6c97d", "b6c97f", "b6c880", "b6c882", "b7c883", "b7c885", "b7c786", "b7c788", "b7c789", "b8c68a", "b8c68c", "b8c68d", "b8c68f", "b8c590", "b9c591", "b9c593", "b9c494", "b9c496", "b9c497", "b9c498", "bac39a", "bac39b", "bac39d", "bac29e", "bac29f", "bac2a1", "bac2a2", "bac1a4", "bbc1a5", "bbc1a6", "bbc0a8", "bbc0a9", "bbc0aa", "bbc0ac", "bbbfad", "bbbfae", "bbbfb0", "bbbeb1", "bcbeb3", "bcbeb4", "bcbdb5", "bcbdb7", "bcbdb8", "bcbdb9", "bcbcbb"] 116 | ] 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /vim/.vim/ftplugin/html.vim: -------------------------------------------------------------------------------- 1 | " Vim script file vim600:fdm=marker: 2 | " FileType: XML 3 | " Author: Devin Weaver 4 | " Maintainer: Devin Weaver 5 | " Last Change: Fri Sep 17 08:00:13 EDT 2010 6 | " Version: 1.9.4 7 | " Location: http://www.vim.org/scripts/script.php?script_id=301 8 | " Licence: This program is free software; you can redistribute it 9 | " and/or modify it under the terms of the GNU General Public 10 | " License. See http://www.gnu.org/copyleft/gpl.txt 11 | " GetLatestVimScripts: 301 1 :AutoInstall: xmledit.vba 12 | 13 | " This script provides some convenience when editing XML (and some SGML) 14 | " formated documents. 15 | 16 | " Section: Documentation 17 | " ---------------------- 18 | " 19 | " Documentation should be available by ":help xml-plugin" command, once the 20 | " script has been copied in you .vim/plugin directory. 21 | " 22 | " You still can read the documentation in the file "doc/xml-plugin.txt" 23 | 24 | " Note: If you used the 5.x version of this file (xmledit.vim) you'll need to 25 | " comment out the section where you called it since it is no longer used in 26 | " version 6.x. 27 | 28 | " TODO: Revamp ParseTag to pull appart a tag a rebuild it properly. 29 | " a tag like: < test nowrap testatt=foo > 30 | " should be fixed to: 31 | 32 | "============================================================================== 33 | 34 | " Only do this when not done yet for this buffer 35 | if exists("b:did_ftplugin") || exists("loaded_xmledit") 36 | finish 37 | endif 38 | " sboles, init these variables so vim doesn't complain on wrap cancel 39 | let b:last_wrap_tag_used = "" 40 | let b:last_wrap_atts_used = "" 41 | 42 | " WrapTag -> Places an XML tag around a visual selection. {{{1 43 | " Brad Phelan: Wrap the argument in an XML tag 44 | " Added nice GUI support to the dialogs. 45 | " Rewrote function to implement new algorythem that addresses several bugs. 46 | if !exists("*s:WrapTag") 47 | function s:WrapTag(text) 48 | if (line(".") < line("'<")) 49 | let insert_cmd = "o" 50 | elseif (col(".") < col("'<")) 51 | let insert_cmd = "a" 52 | else 53 | let insert_cmd = "i" 54 | endif 55 | if strlen(a:text) > 10 56 | let input_text = strpart(a:text, 0, 10) . '...' 57 | else 58 | let input_text = a:text 59 | endif 60 | if exists("b:last_wrap_tag_used") 61 | let default_tag = b:last_wrap_tag_used 62 | else 63 | let default_tag = "" 64 | endif 65 | let wraptag = inputdialog('Tag to wrap "' . input_text . '" : ', default_tag) 66 | if strlen(wraptag)==0 67 | undo 68 | return 69 | else 70 | if wraptag == default_tag && exists("b:last_wrap_atts_used") 71 | let default_atts = b:last_wrap_atts_used 72 | else 73 | let default_atts = "" 74 | endif 75 | let atts = inputdialog('Attributes in <' . wraptag . '> : ', default_atts) 76 | endif 77 | if (visualmode() ==# 'V') 78 | let text = strpart(a:text,0,strlen(a:text)-1) 79 | if (insert_cmd ==# "o") 80 | let eol_cmd = "" 81 | else 82 | let eol_cmd = "\" 83 | endif 84 | else 85 | let text = a:text 86 | let eol_cmd = "" 87 | endif 88 | if strlen(atts)==0 89 | let text = "<".wraptag.">".text."" 90 | let b:last_wrap_tag_used = wraptag 91 | let b:last_wrap_atts_used = "" 92 | else 93 | let text = "<".wraptag." ".atts.">".text."" 94 | let b:last_wrap_tag_used = wraptag 95 | let b:last_wrap_atts_used = atts 96 | endif 97 | execute "normal! ".insert_cmd.text.eol_cmd 98 | endfunction 99 | endif 100 | 101 | " NewFileXML -> Inserts at top of new file. {{{1 102 | if !exists("*s:NewFileXML") 103 | function s:NewFileXML( ) 104 | " Where is g:did_xhtmlcf_inits defined? 105 | if &filetype == 'docbk' || &filetype == 'xml' || (!exists ("g:did_xhtmlcf_inits") && exists ("g:xml_use_xhtml") && (&filetype == 'html' || &filetype == 'xhtml')) 106 | if append (0, '') 107 | normal! G 108 | endif 109 | endif 110 | endfunction 111 | endif 112 | 113 | 114 | " Callback -> Checks for tag callbacks and executes them. {{{1 115 | if !exists("*s:Callback") 116 | function s:Callback( xml_tag, isHtml ) 117 | let text = 0 118 | if a:isHtml == 1 && exists ("*HtmlAttribCallback") 119 | let text = HtmlAttribCallback (a:xml_tag) 120 | elseif exists ("*XmlAttribCallback") 121 | let text = XmlAttribCallback (a:xml_tag) 122 | endif 123 | if text != '0' 124 | execute "normal! i " . text ."\l" 125 | endif 126 | endfunction 127 | endif 128 | 129 | 130 | " IsParsableTag -> Check to see if the tag is a real tag. {{{1 131 | if !exists("*s:IsParsableTag") 132 | function s:IsParsableTag( tag ) 133 | " The "Should I parse?" flag. 134 | let parse = 1 135 | 136 | " make sure a:tag has a proper tag in it and is not a instruction or end tag. 137 | if a:tag !~ '^<[[:alnum:]_:\-].*>$' 138 | let parse = 0 139 | endif 140 | 141 | " make sure this tag isn't already closed. 142 | if strpart (a:tag, strlen (a:tag) - 2, 1) == '/' 143 | let parse = 0 144 | endif 145 | 146 | return parse 147 | endfunction 148 | endif 149 | 150 | 151 | " ParseTag -> The major work hourse for tag completion. {{{1 152 | if !exists("*s:ParseTag") 153 | function s:ParseTag( ) 154 | " Save registers 155 | let old_reg_save = @" 156 | let old_save_x = @x 157 | 158 | if (!exists("g:xml_no_auto_nesting") && strpart (getline ("."), col (".") - 2, 2) == '>>') 159 | let multi_line = 1 160 | execute "normal! \"xX" 161 | else 162 | let multi_line = 0 163 | endif 164 | 165 | let @" = "" 166 | execute "normal! \"xy%%" 167 | let ltag = @" 168 | if (&filetype == 'html' || &filetype == 'xhtml') && (!exists ("g:xml_no_html")) 169 | let html_mode = 1 170 | let ltag = substitute (ltag, '[^[:graph:]]\+', ' ', 'g') 171 | let ltag = substitute (ltag, '<\s*\([^[:alnum:]_:\-[:blank:]]\=\)\s*\([[:alnum:]_:\-]\+\)\>', '<\1\2', '') 172 | else 173 | let html_mode = 0 174 | endif 175 | 176 | if IsParsableTag (ltag) 177 | " find the break between tag name and atributes (or closing of tag) 178 | let index = matchend (ltag, '[[:alnum:]_:\.\-]\+') 179 | 180 | let tag_name = strpart (ltag, 1, index - 1) 181 | if strpart (ltag, index) =~ '[^/>[:blank:]]' 182 | let has_attrib = 1 183 | else 184 | let has_attrib = 0 185 | endif 186 | 187 | " That's (index - 1) + 2, 2 for the '' is ignored because puts the curser on top 189 | " of the '>' 190 | let index = index + 2 191 | 192 | " print out the end tag and place the cursor back were it left off 193 | if html_mode && tag_name =~? '^\(img\|input\|param\|frame\|br\|hr\|meta\|link\|base\|area\)$' 194 | if has_attrib == 0 195 | call Callback (tag_name, html_mode) 196 | endif 197 | if exists ("g:xml_use_xhtml") 198 | execute "normal! i /\l" 199 | endif 200 | else 201 | if multi_line 202 | " Can't use \ because that indents 'tabstop' not 'shiftwidth' 203 | " Also >> doesn't shift on an empty line hence the temporary char 'x' 204 | let com_save = &comments 205 | set comments-=n:> 206 | execute "normal! a\\\kAx\>>$\"xx" 207 | execute "set comments=" . substitute(com_save, " ", "\\\\ ", "g") 208 | else 209 | if has_attrib == 0 210 | call Callback (tag_name, html_mode) 211 | endif 212 | if exists("g:xml_jump_string") 213 | let index = index + strlen(g:xml_jump_string) 214 | let jump_char = g:xml_jump_string 215 | call InitEditFromJump() 216 | else 217 | let jump_char = "" 218 | endif 219 | execute "normal! a" . jump_char . "\" . index . "h" 220 | endif 221 | endif 222 | endif 223 | 224 | " restore registers 225 | let @" = old_reg_save 226 | let @x = old_save_x 227 | 228 | if multi_line 229 | startinsert! 230 | else 231 | execute "normal! l" 232 | startinsert 233 | endif 234 | endfunction 235 | endif 236 | 237 | 238 | " ParseTag2 -> Experimental function to replace ParseTag {{{1 239 | "if !exists("*s:ParseTag2") 240 | "function s:ParseTag2( ) 241 | " My thought is to pull the tag out and reformat it to a normalized tag 242 | " and put it back. 243 | "endfunction 244 | "endif 245 | 246 | 247 | " BuildTagName -> Grabs the tag's name for tag matching. {{{1 248 | if !exists("*s:BuildTagName") 249 | function s:BuildTagName( ) 250 | "First check to see if we Are allready on the end of the tag. The / search 251 | "forwards command will jump to the next tag otherwise 252 | 253 | " Store contents of register x in a variable 254 | let b:xreg = @x 255 | 256 | exec "normal! v\"xy" 257 | if @x=='>' 258 | " Don't do anything 259 | else 260 | exec "normal! />/\" 261 | endif 262 | 263 | " Now we head back to the < to reach the beginning. 264 | exec "normal! ?" 265 | 266 | " Capture the tag (a > will be catured by the /$/ match) 267 | exec "normal! v/\\s\\|$/\\"xy" 268 | 269 | " We need to strip off any junk at the end. 270 | let @x=strpart(@x, 0, match(@x, "[[:blank:]>\]")) 271 | 272 | "remove <, > 273 | let @x=substitute(@x,'^<\|>$','','') 274 | 275 | " remove spaces. 276 | let @x=substitute(@x,'/\s*','/', '') 277 | let @x=substitute(@x,'^\s*','', '') 278 | 279 | " Swap @x and b:xreg 280 | let temp = @x 281 | let @x = b:xreg 282 | let b:xreg = temp 283 | endfunction 284 | endif 285 | 286 | " TagMatch1 -> First step in tag matching. {{{1 287 | " Brad Phelan: First step in tag matching. 288 | if !exists("*s:TagMatch1") 289 | function s:TagMatch1() 290 | " Save registers 291 | let old_reg_save = @" 292 | 293 | "Drop a marker here just in case we have a mismatched tag and 294 | "wish to return (:mark looses column position) 295 | normal! mz 296 | 297 | call BuildTagName() 298 | 299 | "Check to see if it is an end tag. If it is place a 1 in endtag 300 | if match(b:xreg, '^/')==-1 301 | let endtag = 0 302 | else 303 | let endtag = 1 304 | endif 305 | 306 | " Extract the tag from the whole tag block 307 | " eg if the block = 308 | " tag attrib1=blah attrib2=blah 309 | " we will end up with 310 | " tag 311 | " with no trailing or leading spaces 312 | let b:xreg=substitute(b:xreg,'^/','','g') 313 | 314 | " Make sure the tag is valid. 315 | " Malformed tags could be , , etc. 316 | if match(b:xreg,'^[[:alnum:]_:\-]') != -1 317 | " Pass the tag to the matching 318 | " routine 319 | call TagMatch2(b:xreg, endtag) 320 | endif 321 | " Restore registers 322 | let @" = old_reg_save 323 | endfunction 324 | endif 325 | 326 | 327 | " TagMatch2 -> Second step in tag matching. {{{1 328 | " Brad Phelan: Second step in tag matching. 329 | if !exists("*s:TagMatch2") 330 | function s:TagMatch2(tag,endtag) 331 | let match_type='' 332 | 333 | " Build the pattern for searching for XML tags based 334 | " on the 'tag' type passed into the function. 335 | " Note we search forwards for end tags and 336 | " backwards for start tags 337 | if a:endtag==0 338 | "let nextMatch='normal /\(<\s*' . a:tag . '\(\s\+.\{-}\)*>\)\|\(<\/' . a:tag . '\s*>\)' 339 | let match_type = '/' 340 | else 341 | "let nextMatch='normal ?\(<\s*' . a:tag . '\(\s\+.\{-}\)*>\)\|\(<\/' . a:tag . '\s*>\)' 342 | let match_type = '?' 343 | endif 344 | 345 | if a:endtag==0 346 | let stk = 1 347 | else 348 | let stk = 1 349 | end 350 | 351 | " wrapscan must be turned on. We'll recored the value and reset it afterward. 352 | " We have it on because if we don't we'll get a nasty error if the search hits 353 | " BOF or EOF. 354 | let wrapval = &wrapscan 355 | let &wrapscan = 1 356 | 357 | "Get the current location of the cursor so we can 358 | "detect if we wrap on ourselves 359 | let lpos = line(".") 360 | let cpos = col(".") 361 | 362 | if a:endtag==0 363 | " If we are trying to find a start tag 364 | " then decrement when we find a start tag 365 | let iter = 1 366 | else 367 | " If we are trying to find an end tag 368 | " then increment when we find a start tag 369 | let iter = -1 370 | endif 371 | 372 | "Loop until stk == 0. 373 | while 1 374 | " exec search. 375 | " Make sure to avoid />$/ as well as /\s$/ and /$/. 376 | exec "normal! " . match_type . '<\s*\/*\s*' . a:tag . '\([[:blank:]>]\|$\)' . "\" 377 | 378 | " Check to see if our match makes sence. 379 | if a:endtag == 0 380 | if line(".") < lpos 381 | call MisMatchedTag (0, a:tag) 382 | break 383 | elseif line(".") == lpos && col(".") <= cpos 384 | call MisMatchedTag (1, a:tag) 385 | break 386 | endif 387 | else 388 | if line(".") > lpos 389 | call MisMatchedTag (2, '/'.a:tag) 390 | break 391 | elseif line(".") == lpos && col(".") >= cpos 392 | call MisMatchedTag (3, '/'.a:tag) 393 | break 394 | endif 395 | endif 396 | 397 | call BuildTagName() 398 | 399 | if match(b:xreg,'^/')==-1 400 | " Found start tag 401 | let stk = stk + iter 402 | else 403 | " Found end tag 404 | let stk = stk - iter 405 | endif 406 | 407 | if stk == 0 408 | break 409 | endif 410 | endwhile 411 | 412 | let &wrapscan = wrapval 413 | endfunction 414 | endif 415 | 416 | " MisMatchedTag -> What to do if a tag is mismatched. {{{1 417 | if !exists("*s:MisMatchedTag") 418 | function s:MisMatchedTag( id, tag ) 419 | "Jump back to our formor spot 420 | normal! `z 421 | normal zz 422 | echohl WarningMsg 423 | " For debugging 424 | "echo "Mismatched tag " . a:id . ": <" . a:tag . ">" 425 | " For release 426 | echo "Mismatched tag <" . a:tag . ">" 427 | echohl None 428 | endfunction 429 | endif 430 | 431 | " DeleteTag -> Deletes surrounding tags from cursor. {{{1 432 | " Modifies mark z 433 | if !exists("*s:DeleteTag") 434 | function s:DeleteTag( ) 435 | if strpart (getline ("."), col (".") - 1, 1) == "<" 436 | normal! l 437 | endif 438 | if search ("<[^\/]", "bW") == 0 439 | return 440 | endif 441 | normal! mz 442 | normal \5 443 | normal! d%`zd% 444 | endfunction 445 | endif 446 | 447 | " VisualTag -> Selects Tag body in a visual selection. {{{1 448 | " Modifies mark z 449 | if !exists("*s:VisualTag") 450 | function s:VisualTag( ) 451 | if strpart (getline ("."), col (".") - 1, 1) == "<" 452 | normal! l 453 | endif 454 | if search ("<[^\/]", "bW") == 0 455 | return 456 | endif 457 | normal! mz 458 | normal \5 459 | normal! % 460 | exe "normal! " . visualmode() 461 | normal! `z 462 | endfunction 463 | endif 464 | 465 | " InsertGt -> close tags only if the cursor is in a HTML or XML context {{{1 466 | " Else continue editing 467 | if !exists("*s:InsertGt") 468 | function s:InsertGt( ) 469 | let save_matchpairs = &matchpairs 470 | set matchpairs-=<:> 471 | execute "normal! a>" 472 | execute "set matchpairs=" . save_matchpairs 473 | " When the current char is text within a tag it will not proccess as a 474 | " syntax'ed element and return nothing below. Since the multi line wrap 475 | " feture relies on using the '>' char as text within a tag we must use the 476 | " char prior to establish if it is valid html/xml 477 | if (getline('.')[col('.') - 1] == '>') 478 | let char_syn=synIDattr(synID(line("."), col(".") - 1, 1), "name") 479 | endif 480 | if !exists("g:xml_tag_syntax_prefixes") 481 | let tag_syn_patt = 'html\|xml\|docbk' 482 | else 483 | let tag_syn_patt = g:xml_tag_syntax_prefixes 484 | endif 485 | if -1 == match(char_syn, "xmlProcessing") && 0 == match(char_syn, tag_syn_patt) 486 | call ParseTag() 487 | else 488 | if col(".") == col("$") - 1 489 | startinsert! 490 | else 491 | execute "normal! l" 492 | startinsert 493 | endif 494 | endif 495 | endfunction 496 | endif 497 | 498 | " InitEditFromJump -> Set some needed autocommands and syntax highlights for EditFromJump. {{{1 499 | if !exists("*s:InitEditFromJump") 500 | function s:InitEditFromJump( ) 501 | " Add a syntax highlight for the xml_jump_string. 502 | execute "syntax match Error /\\V" . g:xml_jump_string . "/" 503 | endfunction 504 | endif 505 | 506 | " ClearJumpMarks -> Clean out extranious left over xml_jump_string garbage. {{{1 507 | if !exists("*s:ClearJumpMarks") 508 | function s:ClearJumpMarks( ) 509 | if exists("g:xml_jump_string") 510 | if g:xml_jump_string != "" 511 | execute ":%s/" . g:xml_jump_string . "//ge" 512 | endif 513 | endif 514 | endfunction 515 | endif 516 | 517 | " EditFromJump -> Jump to the end of the tag and continue editing. {{{1 518 | " g:xml_jump_string must be set. 519 | if !exists("*s:EditFromJump") 520 | function s:EditFromJump( ) 521 | if exists("g:xml_jump_string") 522 | if g:xml_jump_string != "" 523 | let foo = search(g:xml_jump_string, 'csW') " Moves cursor by default 524 | execute "normal! " . strlen(g:xml_jump_string) . "x" 525 | if col(".") == col("$") - 1 526 | startinsert! 527 | else 528 | startinsert 529 | endif 530 | endif 531 | else 532 | echohl WarningMsg 533 | echo "Function disabled. xml_jump_string not defined." 534 | echohl None 535 | endif 536 | endfunction 537 | endif 538 | 539 | " Mappings and Settings. {{{1 540 | " This makes the '%' jump between the start and end of a single tag. 541 | setlocal matchpairs+=<:> 542 | setlocal commentstring= 543 | 544 | " Have this as an escape incase you want a literal '>' not to run the 545 | " ParseTag function. 546 | if !exists("g:xml_tag_completion_map") 547 | inoremap . > 548 | inoremap > > 549 | endif 550 | 551 | " Jump between the beggining and end tags. 552 | nnoremap 5 :call TagMatch1() 553 | nnoremap % :call TagMatch1() 554 | vnoremap 5 :call VisualTag() 555 | vnoremap % :call VisualTag() 556 | 557 | " Wrap selection in XML tag 558 | vnoremap x "xx:call WrapTag(@x) 559 | nnoremap d :call DeleteTag() 560 | 561 | " Parse the tag after pressing the close '>'. 562 | if !exists("g:xml_tag_completion_map") 563 | " inoremap > >:call ParseTag() 564 | inoremap > :call InsertGt() 565 | else 566 | execute "inoremap " . g:xml_tag_completion_map . " :call InsertGt()" 567 | endif 568 | 569 | nnoremap :call EditFromJump() 570 | inoremap :call EditFromJump() 571 | " Clear out all left over xml_jump_string garbage 572 | nnoremap w :call ClearJumpMarks() 573 | " The syntax files clear out any predefined syntax definitions. Recreate 574 | " this when ever a xml_jump_string is created. (in ParseTag) 575 | 576 | augroup xml 577 | au! 578 | au BufNewFile * call NewFileXML() 579 | " Remove left over garbage from xml_jump_string on file save. 580 | au BufWritePre call ClearJumpMarks() 581 | augroup END 582 | "}}}1 583 | finish 584 | -------------------------------------------------------------------------------- /vim/.vim/ftplugin/xml.vim: -------------------------------------------------------------------------------- 1 | " Vim script file vim600:fdm=marker: 2 | " FileType: XML 3 | " Author: Devin Weaver 4 | " Maintainer: Devin Weaver 5 | " Last Change: Fri Sep 17 08:00:13 EDT 2010 6 | " Version: 1.9.4 7 | " Location: http://www.vim.org/scripts/script.php?script_id=301 8 | " Licence: This program is free software; you can redistribute it 9 | " and/or modify it under the terms of the GNU General Public 10 | " License. See http://www.gnu.org/copyleft/gpl.txt 11 | " GetLatestVimScripts: 301 1 :AutoInstall: xmledit.vba 12 | 13 | " This script provides some convenience when editing XML (and some SGML) 14 | " formated documents. 15 | 16 | " Section: Documentation 17 | " ---------------------- 18 | " 19 | " Documentation should be available by ":help xml-plugin" command, once the 20 | " script has been copied in you .vim/plugin directory. 21 | " 22 | " You still can read the documentation in the file "doc/xml-plugin.txt" 23 | 24 | " Note: If you used the 5.x version of this file (xmledit.vim) you'll need to 25 | " comment out the section where you called it since it is no longer used in 26 | " version 6.x. 27 | 28 | " TODO: Revamp ParseTag to pull appart a tag a rebuild it properly. 29 | " a tag like: < test nowrap testatt=foo > 30 | " should be fixed to: 31 | 32 | "============================================================================== 33 | 34 | " Only do this when not done yet for this buffer 35 | if exists("b:did_ftplugin") || exists("loaded_xmledit") 36 | finish 37 | endif 38 | " sboles, init these variables so vim doesn't complain on wrap cancel 39 | let b:last_wrap_tag_used = "" 40 | let b:last_wrap_atts_used = "" 41 | 42 | " WrapTag -> Places an XML tag around a visual selection. {{{1 43 | " Brad Phelan: Wrap the argument in an XML tag 44 | " Added nice GUI support to the dialogs. 45 | " Rewrote function to implement new algorythem that addresses several bugs. 46 | if !exists("*s:WrapTag") 47 | function s:WrapTag(text) 48 | if (line(".") < line("'<")) 49 | let insert_cmd = "o" 50 | elseif (col(".") < col("'<")) 51 | let insert_cmd = "a" 52 | else 53 | let insert_cmd = "i" 54 | endif 55 | if strlen(a:text) > 10 56 | let input_text = strpart(a:text, 0, 10) . '...' 57 | else 58 | let input_text = a:text 59 | endif 60 | if exists("b:last_wrap_tag_used") 61 | let default_tag = b:last_wrap_tag_used 62 | else 63 | let default_tag = "" 64 | endif 65 | let wraptag = inputdialog('Tag to wrap "' . input_text . '" : ', default_tag) 66 | if strlen(wraptag)==0 67 | undo 68 | return 69 | else 70 | if wraptag == default_tag && exists("b:last_wrap_atts_used") 71 | let default_atts = b:last_wrap_atts_used 72 | else 73 | let default_atts = "" 74 | endif 75 | let atts = inputdialog('Attributes in <' . wraptag . '> : ', default_atts) 76 | endif 77 | if (visualmode() ==# 'V') 78 | let text = strpart(a:text,0,strlen(a:text)-1) 79 | if (insert_cmd ==# "o") 80 | let eol_cmd = "" 81 | else 82 | let eol_cmd = "\" 83 | endif 84 | else 85 | let text = a:text 86 | let eol_cmd = "" 87 | endif 88 | if strlen(atts)==0 89 | let text = "<".wraptag.">".text."" 90 | let b:last_wrap_tag_used = wraptag 91 | let b:last_wrap_atts_used = "" 92 | else 93 | let text = "<".wraptag." ".atts.">".text."" 94 | let b:last_wrap_tag_used = wraptag 95 | let b:last_wrap_atts_used = atts 96 | endif 97 | execute "normal! ".insert_cmd.text.eol_cmd 98 | endfunction 99 | endif 100 | 101 | " NewFileXML -> Inserts at top of new file. {{{1 102 | if !exists("*s:NewFileXML") 103 | function s:NewFileXML( ) 104 | " Where is g:did_xhtmlcf_inits defined? 105 | if &filetype == 'docbk' || &filetype == 'xml' || (!exists ("g:did_xhtmlcf_inits") && exists ("g:xml_use_xhtml") && (&filetype == 'html' || &filetype == 'xhtml')) 106 | if append (0, '') 107 | normal! G 108 | endif 109 | endif 110 | endfunction 111 | endif 112 | 113 | 114 | " Callback -> Checks for tag callbacks and executes them. {{{1 115 | if !exists("*s:Callback") 116 | function s:Callback( xml_tag, isHtml ) 117 | let text = 0 118 | if a:isHtml == 1 && exists ("*HtmlAttribCallback") 119 | let text = HtmlAttribCallback (a:xml_tag) 120 | elseif exists ("*XmlAttribCallback") 121 | let text = XmlAttribCallback (a:xml_tag) 122 | endif 123 | if text != '0' 124 | execute "normal! i " . text ."\l" 125 | endif 126 | endfunction 127 | endif 128 | 129 | 130 | " IsParsableTag -> Check to see if the tag is a real tag. {{{1 131 | if !exists("*s:IsParsableTag") 132 | function s:IsParsableTag( tag ) 133 | " The "Should I parse?" flag. 134 | let parse = 1 135 | 136 | " make sure a:tag has a proper tag in it and is not a instruction or end tag. 137 | if a:tag !~ '^<[[:alnum:]_:\-].*>$' 138 | let parse = 0 139 | endif 140 | 141 | " make sure this tag isn't already closed. 142 | if strpart (a:tag, strlen (a:tag) - 2, 1) == '/' 143 | let parse = 0 144 | endif 145 | 146 | return parse 147 | endfunction 148 | endif 149 | 150 | 151 | " ParseTag -> The major work hourse for tag completion. {{{1 152 | if !exists("*s:ParseTag") 153 | function s:ParseTag( ) 154 | " Save registers 155 | let old_reg_save = @" 156 | let old_save_x = @x 157 | 158 | if (!exists("g:xml_no_auto_nesting") && strpart (getline ("."), col (".") - 2, 2) == '>>') 159 | let multi_line = 1 160 | execute "normal! \"xX" 161 | else 162 | let multi_line = 0 163 | endif 164 | 165 | let @" = "" 166 | execute "normal! \"xy%%" 167 | let ltag = @" 168 | if (&filetype == 'html' || &filetype == 'xhtml') && (!exists ("g:xml_no_html")) 169 | let html_mode = 1 170 | let ltag = substitute (ltag, '[^[:graph:]]\+', ' ', 'g') 171 | let ltag = substitute (ltag, '<\s*\([^[:alnum:]_:\-[:blank:]]\=\)\s*\([[:alnum:]_:\-]\+\)\>', '<\1\2', '') 172 | else 173 | let html_mode = 0 174 | endif 175 | 176 | if IsParsableTag (ltag) 177 | " find the break between tag name and atributes (or closing of tag) 178 | let index = matchend (ltag, '[[:alnum:]_:\.\-]\+') 179 | 180 | let tag_name = strpart (ltag, 1, index - 1) 181 | if strpart (ltag, index) =~ '[^/>[:blank:]]' 182 | let has_attrib = 1 183 | else 184 | let has_attrib = 0 185 | endif 186 | 187 | " That's (index - 1) + 2, 2 for the '' is ignored because puts the curser on top 189 | " of the '>' 190 | let index = index + 2 191 | 192 | " print out the end tag and place the cursor back were it left off 193 | if html_mode && tag_name =~? '^\(img\|input\|param\|frame\|br\|hr\|meta\|link\|base\|area\)$' 194 | if has_attrib == 0 195 | call Callback (tag_name, html_mode) 196 | endif 197 | if exists ("g:xml_use_xhtml") 198 | execute "normal! i /\l" 199 | endif 200 | else 201 | if multi_line 202 | " Can't use \ because that indents 'tabstop' not 'shiftwidth' 203 | " Also >> doesn't shift on an empty line hence the temporary char 'x' 204 | let com_save = &comments 205 | set comments-=n:> 206 | execute "normal! a\\\kAx\>>$\"xx" 207 | execute "set comments=" . substitute(com_save, " ", "\\\\ ", "g") 208 | else 209 | if has_attrib == 0 210 | call Callback (tag_name, html_mode) 211 | endif 212 | if exists("g:xml_jump_string") 213 | let index = index + strlen(g:xml_jump_string) 214 | let jump_char = g:xml_jump_string 215 | call InitEditFromJump() 216 | else 217 | let jump_char = "" 218 | endif 219 | execute "normal! a" . jump_char . "\" . index . "h" 220 | endif 221 | endif 222 | endif 223 | 224 | " restore registers 225 | let @" = old_reg_save 226 | let @x = old_save_x 227 | 228 | if multi_line 229 | startinsert! 230 | else 231 | execute "normal! l" 232 | startinsert 233 | endif 234 | endfunction 235 | endif 236 | 237 | 238 | " ParseTag2 -> Experimental function to replace ParseTag {{{1 239 | "if !exists("*s:ParseTag2") 240 | "function s:ParseTag2( ) 241 | " My thought is to pull the tag out and reformat it to a normalized tag 242 | " and put it back. 243 | "endfunction 244 | "endif 245 | 246 | 247 | " BuildTagName -> Grabs the tag's name for tag matching. {{{1 248 | if !exists("*s:BuildTagName") 249 | function s:BuildTagName( ) 250 | "First check to see if we Are allready on the end of the tag. The / search 251 | "forwards command will jump to the next tag otherwise 252 | 253 | " Store contents of register x in a variable 254 | let b:xreg = @x 255 | 256 | exec "normal! v\"xy" 257 | if @x=='>' 258 | " Don't do anything 259 | else 260 | exec "normal! />/\" 261 | endif 262 | 263 | " Now we head back to the < to reach the beginning. 264 | exec "normal! ?" 265 | 266 | " Capture the tag (a > will be catured by the /$/ match) 267 | exec "normal! v/\\s\\|$/\\"xy" 268 | 269 | " We need to strip off any junk at the end. 270 | let @x=strpart(@x, 0, match(@x, "[[:blank:]>\]")) 271 | 272 | "remove <, > 273 | let @x=substitute(@x,'^<\|>$','','') 274 | 275 | " remove spaces. 276 | let @x=substitute(@x,'/\s*','/', '') 277 | let @x=substitute(@x,'^\s*','', '') 278 | 279 | " Swap @x and b:xreg 280 | let temp = @x 281 | let @x = b:xreg 282 | let b:xreg = temp 283 | endfunction 284 | endif 285 | 286 | " TagMatch1 -> First step in tag matching. {{{1 287 | " Brad Phelan: First step in tag matching. 288 | if !exists("*s:TagMatch1") 289 | function s:TagMatch1() 290 | " Save registers 291 | let old_reg_save = @" 292 | 293 | "Drop a marker here just in case we have a mismatched tag and 294 | "wish to return (:mark looses column position) 295 | normal! mz 296 | 297 | call BuildTagName() 298 | 299 | "Check to see if it is an end tag. If it is place a 1 in endtag 300 | if match(b:xreg, '^/')==-1 301 | let endtag = 0 302 | else 303 | let endtag = 1 304 | endif 305 | 306 | " Extract the tag from the whole tag block 307 | " eg if the block = 308 | " tag attrib1=blah attrib2=blah 309 | " we will end up with 310 | " tag 311 | " with no trailing or leading spaces 312 | let b:xreg=substitute(b:xreg,'^/','','g') 313 | 314 | " Make sure the tag is valid. 315 | " Malformed tags could be , , etc. 316 | if match(b:xreg,'^[[:alnum:]_:\-]') != -1 317 | " Pass the tag to the matching 318 | " routine 319 | call TagMatch2(b:xreg, endtag) 320 | endif 321 | " Restore registers 322 | let @" = old_reg_save 323 | endfunction 324 | endif 325 | 326 | 327 | " TagMatch2 -> Second step in tag matching. {{{1 328 | " Brad Phelan: Second step in tag matching. 329 | if !exists("*s:TagMatch2") 330 | function s:TagMatch2(tag,endtag) 331 | let match_type='' 332 | 333 | " Build the pattern for searching for XML tags based 334 | " on the 'tag' type passed into the function. 335 | " Note we search forwards for end tags and 336 | " backwards for start tags 337 | if a:endtag==0 338 | "let nextMatch='normal /\(<\s*' . a:tag . '\(\s\+.\{-}\)*>\)\|\(<\/' . a:tag . '\s*>\)' 339 | let match_type = '/' 340 | else 341 | "let nextMatch='normal ?\(<\s*' . a:tag . '\(\s\+.\{-}\)*>\)\|\(<\/' . a:tag . '\s*>\)' 342 | let match_type = '?' 343 | endif 344 | 345 | if a:endtag==0 346 | let stk = 1 347 | else 348 | let stk = 1 349 | end 350 | 351 | " wrapscan must be turned on. We'll recored the value and reset it afterward. 352 | " We have it on because if we don't we'll get a nasty error if the search hits 353 | " BOF or EOF. 354 | let wrapval = &wrapscan 355 | let &wrapscan = 1 356 | 357 | "Get the current location of the cursor so we can 358 | "detect if we wrap on ourselves 359 | let lpos = line(".") 360 | let cpos = col(".") 361 | 362 | if a:endtag==0 363 | " If we are trying to find a start tag 364 | " then decrement when we find a start tag 365 | let iter = 1 366 | else 367 | " If we are trying to find an end tag 368 | " then increment when we find a start tag 369 | let iter = -1 370 | endif 371 | 372 | "Loop until stk == 0. 373 | while 1 374 | " exec search. 375 | " Make sure to avoid />$/ as well as /\s$/ and /$/. 376 | exec "normal! " . match_type . '<\s*\/*\s*' . a:tag . '\([[:blank:]>]\|$\)' . "\" 377 | 378 | " Check to see if our match makes sence. 379 | if a:endtag == 0 380 | if line(".") < lpos 381 | call MisMatchedTag (0, a:tag) 382 | break 383 | elseif line(".") == lpos && col(".") <= cpos 384 | call MisMatchedTag (1, a:tag) 385 | break 386 | endif 387 | else 388 | if line(".") > lpos 389 | call MisMatchedTag (2, '/'.a:tag) 390 | break 391 | elseif line(".") == lpos && col(".") >= cpos 392 | call MisMatchedTag (3, '/'.a:tag) 393 | break 394 | endif 395 | endif 396 | 397 | call BuildTagName() 398 | 399 | if match(b:xreg,'^/')==-1 400 | " Found start tag 401 | let stk = stk + iter 402 | else 403 | " Found end tag 404 | let stk = stk - iter 405 | endif 406 | 407 | if stk == 0 408 | break 409 | endif 410 | endwhile 411 | 412 | let &wrapscan = wrapval 413 | endfunction 414 | endif 415 | 416 | " MisMatchedTag -> What to do if a tag is mismatched. {{{1 417 | if !exists("*s:MisMatchedTag") 418 | function s:MisMatchedTag( id, tag ) 419 | "Jump back to our formor spot 420 | normal! `z 421 | normal zz 422 | echohl WarningMsg 423 | " For debugging 424 | "echo "Mismatched tag " . a:id . ": <" . a:tag . ">" 425 | " For release 426 | echo "Mismatched tag <" . a:tag . ">" 427 | echohl None 428 | endfunction 429 | endif 430 | 431 | " DeleteTag -> Deletes surrounding tags from cursor. {{{1 432 | " Modifies mark z 433 | if !exists("*s:DeleteTag") 434 | function s:DeleteTag( ) 435 | if strpart (getline ("."), col (".") - 1, 1) == "<" 436 | normal! l 437 | endif 438 | if search ("<[^\/]", "bW") == 0 439 | return 440 | endif 441 | normal! mz 442 | normal \5 443 | normal! d%`zd% 444 | endfunction 445 | endif 446 | 447 | " VisualTag -> Selects Tag body in a visual selection. {{{1 448 | " Modifies mark z 449 | if !exists("*s:VisualTag") 450 | function s:VisualTag( ) 451 | if strpart (getline ("."), col (".") - 1, 1) == "<" 452 | normal! l 453 | endif 454 | if search ("<[^\/]", "bW") == 0 455 | return 456 | endif 457 | normal! mz 458 | normal \5 459 | normal! % 460 | exe "normal! " . visualmode() 461 | normal! `z 462 | endfunction 463 | endif 464 | 465 | " InsertGt -> close tags only if the cursor is in a HTML or XML context {{{1 466 | " Else continue editing 467 | if !exists("*s:InsertGt") 468 | function s:InsertGt( ) 469 | let save_matchpairs = &matchpairs 470 | set matchpairs-=<:> 471 | execute "normal! a>" 472 | execute "set matchpairs=" . save_matchpairs 473 | " When the current char is text within a tag it will not proccess as a 474 | " syntax'ed element and return nothing below. Since the multi line wrap 475 | " feture relies on using the '>' char as text within a tag we must use the 476 | " char prior to establish if it is valid html/xml 477 | if (getline('.')[col('.') - 1] == '>') 478 | let char_syn=synIDattr(synID(line("."), col(".") - 1, 1), "name") 479 | endif 480 | if !exists("g:xml_tag_syntax_prefixes") 481 | let tag_syn_patt = 'html\|xml\|docbk' 482 | else 483 | let tag_syn_patt = g:xml_tag_syntax_prefixes 484 | endif 485 | if -1 == match(char_syn, "xmlProcessing") && 0 == match(char_syn, tag_syn_patt) 486 | call ParseTag() 487 | else 488 | if col(".") == col("$") - 1 489 | startinsert! 490 | else 491 | execute "normal! l" 492 | startinsert 493 | endif 494 | endif 495 | endfunction 496 | endif 497 | 498 | " InitEditFromJump -> Set some needed autocommands and syntax highlights for EditFromJump. {{{1 499 | if !exists("*s:InitEditFromJump") 500 | function s:InitEditFromJump( ) 501 | " Add a syntax highlight for the xml_jump_string. 502 | execute "syntax match Error /\\V" . g:xml_jump_string . "/" 503 | endfunction 504 | endif 505 | 506 | " ClearJumpMarks -> Clean out extranious left over xml_jump_string garbage. {{{1 507 | if !exists("*s:ClearJumpMarks") 508 | function s:ClearJumpMarks( ) 509 | if exists("g:xml_jump_string") 510 | if g:xml_jump_string != "" 511 | execute ":%s/" . g:xml_jump_string . "//ge" 512 | endif 513 | endif 514 | endfunction 515 | endif 516 | 517 | " EditFromJump -> Jump to the end of the tag and continue editing. {{{1 518 | " g:xml_jump_string must be set. 519 | if !exists("*s:EditFromJump") 520 | function s:EditFromJump( ) 521 | if exists("g:xml_jump_string") 522 | if g:xml_jump_string != "" 523 | let foo = search(g:xml_jump_string, 'csW') " Moves cursor by default 524 | execute "normal! " . strlen(g:xml_jump_string) . "x" 525 | if col(".") == col("$") - 1 526 | startinsert! 527 | else 528 | startinsert 529 | endif 530 | endif 531 | else 532 | echohl WarningMsg 533 | echo "Function disabled. xml_jump_string not defined." 534 | echohl None 535 | endif 536 | endfunction 537 | endif 538 | 539 | " Mappings and Settings. {{{1 540 | " This makes the '%' jump between the start and end of a single tag. 541 | setlocal matchpairs+=<:> 542 | setlocal commentstring= 543 | 544 | " Have this as an escape incase you want a literal '>' not to run the 545 | " ParseTag function. 546 | if !exists("g:xml_tag_completion_map") 547 | inoremap . > 548 | inoremap > > 549 | endif 550 | 551 | " Jump between the beggining and end tags. 552 | nnoremap 5 :call TagMatch1() 553 | nnoremap % :call TagMatch1() 554 | vnoremap 5 :call VisualTag() 555 | vnoremap % :call VisualTag() 556 | 557 | " Wrap selection in XML tag 558 | vnoremap x "xx:call WrapTag(@x) 559 | nnoremap d :call DeleteTag() 560 | 561 | " Parse the tag after pressing the close '>'. 562 | if !exists("g:xml_tag_completion_map") 563 | " inoremap > >:call ParseTag() 564 | inoremap > :call InsertGt() 565 | else 566 | execute "inoremap " . g:xml_tag_completion_map . " :call InsertGt()" 567 | endif 568 | 569 | nnoremap :call EditFromJump() 570 | inoremap :call EditFromJump() 571 | " Clear out all left over xml_jump_string garbage 572 | nnoremap w :call ClearJumpMarks() 573 | " The syntax files clear out any predefined syntax definitions. Recreate 574 | " this when ever a xml_jump_string is created. (in ParseTag) 575 | 576 | augroup xml 577 | au! 578 | au BufNewFile * call NewFileXML() 579 | " Remove left over garbage from xml_jump_string on file save. 580 | au BufWritePre call ClearJumpMarks() 581 | augroup END 582 | "}}}1 583 | finish 584 | -------------------------------------------------------------------------------- /vim/.vimrc: -------------------------------------------------------------------------------- 1 | " vim: fdm=marker foldenable sw=4 ts=4 sts=4 2 | " Max Cantor's .vimrc File 3 | " "zo" to open folds, "zc" to close, "zn" to disable. 4 | 5 | " {{{ Clear all autocommands 6 | 7 | " TODO: It might be more honest to put this in my ,v auto-source-vimrc binding 8 | au! 9 | 10 | " }}} 11 | 12 | " {{{ Plugins and Settings 13 | 14 | " Vundle is used to handle plugins. 15 | " https://github.com/gmarik/Vundle.vim 16 | 17 | " {{{ VUNDLE SETUP 18 | 19 | set nocompatible 20 | filetype off 21 | set rtp+=$HOME/.vim/bundle/Vundle.vim 22 | call vundle#begin() 23 | 24 | Plugin 'gmarik/Vundle.vim' 25 | 26 | " }}} 27 | 28 | " 29 | 30 | " {{{ vim-scala 31 | " ========= 32 | 33 | " Plugin 'derekwyatt/vim-scala' 34 | 35 | " }}} 36 | 37 | " {{{ vim-qml 38 | " ========= 39 | 40 | Plugin 'peterhoeg/vim-qml' 41 | 42 | " }}} 43 | 44 | " {{{ ack.vim 45 | " ======= 46 | 47 | Plugin 'mileszs/ack.vim' 48 | 49 | " }}} 50 | 51 | " {{{ vim-swift 52 | " ========== 53 | 54 | Plugin 'toyamarinyon/vim-swift' 55 | 56 | " }}} 57 | 58 | " {{{ vim-elixir 59 | " ========== 60 | 61 | " Plugin 'elixir-lang/vim-elixir' 62 | 63 | " }}} 64 | 65 | " {{{ vim-tmux 66 | " ======== 67 | 68 | Plugin 'tmux-plugins/vim-tmux' 69 | 70 | " }}} 71 | 72 | " {{{ JS development 73 | " ============== 74 | 75 | Plugin 'mustache/vim-mustache-handlebars' 76 | Plugin 'kchmck/vim-coffee-script' 77 | Plugin 'mtscout6/vim-cjsx' 78 | Plugin 'digitaltoad/vim-jade' 79 | 80 | " }}} 81 | 82 | " {{{ vim-ruby-heredoc-syntax 83 | " ======================= 84 | 85 | Plugin 'joker1007/vim-ruby-heredoc-syntax' 86 | 87 | let g:ruby_heredoc_syntax_filetypes = { 88 | \ "haml" : { 89 | \ "start" : "HAML", 90 | \}, 91 | \ "sass" : { 92 | \ "start" : "SASS", 93 | \}, 94 | \ "yaml" : { 95 | \ "start" : "YAML", 96 | \}, 97 | \ "eruby" : { 98 | \ "start" : "ERB", 99 | \} 100 | \} 101 | 102 | " }}} 103 | 104 | " {{{ writable_search 105 | " =============== 106 | 107 | " Plugin 'AndrewRadev/writable_search.vim' 108 | 109 | " }}} 110 | 111 | " {{{ vim-instant-markdown 112 | " ==================== 113 | 114 | " Plugin 'suan/vim-instant-markdown' 115 | 116 | " }}} 117 | 118 | " {{{ editorconfig-vim 119 | " ================ 120 | 121 | Plugin 'editorconfig/editorconfig-vim' 122 | 123 | " }}} 124 | 125 | " {{{ vim-localvimrc: Project-specific vimrc's 126 | " ======================================== 127 | " 128 | " The 'exrc' option almost achieves this, but it only checks the *current* 129 | " directory; if you have a local .vimrc in your project root but open vim 130 | " in a subfolder, 'exrc' will miss it. 131 | " 132 | " The local .vimrc will be the very last file loaded (as indicated by 133 | " :scriptnames), so instead of setting things like filetypes using 134 | " autocommands (which are prohibited in the sandbox anyway), you just write 135 | " some vim script in the .lvimrc that is executed every time a buffer is 136 | " entered in that folder hierarchy. 137 | 138 | Plugin 'embear/vim-localvimrc' 139 | 140 | " OPTIONS: 141 | 142 | " This is a potential security leak, but I want local .vimrc's specifically 143 | " to set up autocommands that do stuff with filetypes, so what can ya do. 144 | " 145 | " DEFAULT: 1 146 | let g:localvimrc_sandbox=0 147 | 148 | " Keep the default, but set it explicitly here for self-documentation. 149 | " 150 | " DEFAULT: '.lvimrc' 151 | let g:localvimrc_name='.lvimrc' 152 | 153 | " Remember when I accept local .vimrc's until they are changed. 154 | " 155 | " DEFAULT: 0 156 | let g:localvimrc_persistent=2 157 | 158 | " For some reason, if you are in a buffer whose filetype has been set by a 159 | " local vimrc like so... 160 | " 161 | " if &ft == 'html' 162 | " setl ft=liquid 163 | " endif 164 | " 165 | " ... the filetype will be reset to 'html' as soon as you run :Vexplore, 166 | " so adding 'BufLeave' to the trigger list causes the plugin to source the 167 | " .lvimrc immediately after the netrw pane is opened, re-re-setting the 168 | " filetype to 'liquid' (or whatever). 169 | " 170 | " DEFAULT: ['BufWinEnter'] 171 | let g:localvimrc_event=['BufWinEnter', 'BufLeave'] 172 | 173 | " }}} 174 | 175 | " {{{ His Home-Row-ness the Pope of Tim 176 | " ================================= 177 | 178 | " vim-surround: s is a text-object for delimiters; ss linewise 179 | " ys to add surround 180 | Plugin 'tpope/vim-surround' 181 | 182 | " vim-commentary: gc is an operator to toggle comments; gcc linewise 183 | Plugin 'tpope/vim-commentary' 184 | 185 | " vim-repeat: make vim-commentary and vim-surround work with . 186 | Plugin 'tpope/vim-repeat' 187 | 188 | " vim-liquid: syntax stuff 189 | Plugin 'tpope/vim-liquid' 190 | 191 | " vim-markdown: some stuff for fenced language highlighting 192 | Plugin 'tpope/vim-markdown' 193 | let g:markdown_fenced_languages = ['html', 'python', 'ruby', 'yaml', 'haml', 'bash=sh'] 194 | 195 | Plugin 'tpope/vim-fugitive' 196 | Plugin 'tpope/vim-git' 197 | Plugin 'tpope/vim-rails' 198 | Plugin 'tpope/vim-vinegar' 199 | Plugin 'tpope/vim-haml' 200 | Plugin 'tpope/vim-eunuch' 201 | 202 | " }}} 203 | 204 | " {{{ NERDTree 205 | " ======== 206 | 207 | Plugin 'scrooloose/nerdtree' 208 | 209 | " OPTIONS: 210 | 211 | " Get rid of objects in C projects 212 | let NERDTreeIgnore=['\~$', '.o$', 'bower_components', 'node_modules', '__pycache__'] 213 | let NERDTreeWinSize=20 214 | 215 | " }}} 216 | 217 | " {{{ netrw: Configuration 218 | " ==================== 219 | 220 | let g:netrw_banner=0 " disable banner 221 | let g:netrw_browse_split=4 " open in prior window 222 | let g:netrw_altv=1 " open splits to the right 223 | let g:netrw_liststyle=3 " tree view 224 | " hide gitignore'd files 225 | let g:netrw_list_hide=netrw_gitignore#Hide() 226 | " hide dotfiles by default (this is the string toggled by netrw-gh) 227 | let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' 228 | 229 | " }}} 230 | 231 | " 232 | 233 | " {{{ VUNDLE TEARDOWN 234 | 235 | call vundle#end() 236 | filetype plugin indent on 237 | 238 | " }}} 239 | 240 | " }}} 241 | 242 | " {{{ Basic Settings 243 | 244 | " Modelines 245 | set modelines=2 246 | set modeline 247 | 248 | " For clever completion with the :find command 249 | set path+=** 250 | 251 | " Always use bash syntax for sh filetype 252 | let g:is_bash=1 253 | 254 | " Color scheme 255 | color hhdgray 256 | 257 | " Search 258 | set ignorecase smartcase 259 | set grepprg=grep\ -IrsnH 260 | 261 | " Window display 262 | set showcmd ruler laststatus=2 263 | 264 | " Splits 265 | set splitright 266 | 267 | " Buffers 268 | set history=500 269 | set hidden 270 | if exists("&undofile") 271 | set undofile 272 | endif 273 | 274 | " Spelling 275 | set dictionary+=/usr/share/dict/words thesaurus+=$HOME/.thesaurus 276 | 277 | " Text display 278 | set listchars=trail:.,tab:>-,extends:>,precedes:<,nbsp:¬ 279 | set list 280 | 281 | " Typing behavior 282 | set backspace=indent,eol,start 283 | set showmatch 284 | set wildmode=full 285 | set wildmenu 286 | set complete-=i 287 | 288 | " Formatting 289 | set nowrap 290 | set tabstop=2 shiftwidth=2 softtabstop=2 291 | set foldlevelstart=2 292 | 293 | " Status line 294 | set statusline=%!MyStatusLine() 295 | 296 | " Session saving 297 | set sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize,localoptions 298 | 299 | " Word splitting 300 | set iskeyword+=- 301 | 302 | " }}} 303 | 304 | " {{{ Autocommands 305 | 306 | " Make the modification indicator [+] white on red background 307 | au ColorScheme * hi User1 gui=bold term=bold cterm=bold guifg=white guibg=red ctermfg=white ctermbg=red 308 | 309 | " Tweak the color of the fold display column 310 | au ColorScheme * hi FoldColumn cterm=bold ctermbg=233 ctermfg=146 311 | 312 | if has('mac') 313 | au BufEnter *.md exe 'noremap :!open -a "Google Chrome" %:p' 314 | au BufEnter *.md exe 'noremap :!open -a "Mou" %:p' 315 | endif 316 | 317 | " create two empty side buffers to make the diary text width more readable, 318 | " without actually setting a hard textwidth which requires inserting CR's 319 | au VimEnter */diary/*.txt vsplit | vsplit | enew | vertical resize 50 | wincmd t | enew | vertical resize 50 | wincmd l 320 | 321 | " Task update 322 | au BufNewFile,BufRead tasksheet_* set ft=tasksheet | call UpdateTaskDisplay() 323 | au BufWritePost * call UpdateTaskDisplay() 324 | 325 | " Spaces Only 326 | au FileType swift,mustache,markdown,cpp,hpp,vim,sh,html,htmldjango,css,sass,scss,javascript,coffee,python,ruby,eruby setl expandtab list 327 | 328 | " Tabs Only 329 | au FileType c,h,make setl foldmethod=syntax noexpandtab nolist 330 | au FileType gitconfig,apache,sql setl noexpandtab nolist 331 | 332 | " Folding 333 | au FileType html,htmldjango,css,sass,javascript,coffee,python,ruby,eruby setl foldmethod=indent foldenable 334 | au FileType json setl foldmethod=indent foldenable shiftwidth=4 softtabstop=4 tabstop=4 expandtab 335 | 336 | " Tabstop/Shiftwidth 337 | au FileType mustache,ruby,eruby,javascript,coffee,sass,scss setl softtabstop=2 shiftwidth=2 tabstop=2 338 | au FileType rst setl softtabstop=3 shiftwidth=3 tabstop=3 339 | 340 | " Other 341 | au FileType python let b:python_highlight_all=1 342 | au FileType diary setl wrap linebreak nolist 343 | au FileType markdown setl linebreak 344 | 345 | " }}} 346 | 347 | " {{{ Syntax Hilighting 348 | 349 | " This has to happen AFTER autocommands are defined, because I run au! when, 350 | " defining them, and syntax hilighting is done with autocommands. 351 | 352 | " Syntax hilighting 353 | syntax enable 354 | 355 | " }}} 356 | 357 | " Backups & .vimrc Editing {{{ 358 | 359 | if has('win32') 360 | " Windows filesystem 361 | set directory=$HOME\VimBackups\swaps,$HOME\VimBackups,C:\VimBackups,. 362 | set backupdir=$HOME\VimBackups\backups,$HOME\VimBackups,C:\VimBackups,. 363 | if exists("&undodir") 364 | set undodir=$HOME\VimBackups\undofiles,$HOME\VimBackups,C:\VimBackups,. 365 | endif 366 | if has("gui_running") 367 | set guifont=Inconsolata:h12:cANSI 368 | endif 369 | else 370 | " POSIX filesystem 371 | set directory=$HOME/.backups/swaps,$HOME/.backups,$HOME/tmp,. 372 | set backupdir=$HOME/.backups/backups,$HOME/.backups,$HOME/tmp,. 373 | if exists("&undodir") 374 | set undodir=$HOME/.backups/undofiles,$HOME/.backups,$HOME/tmp,. 375 | endif 376 | endif 377 | 378 | " }}} 379 | 380 | " Key Mappings {{{ 381 | 382 | " Run shell command 383 | " ... and print output 384 | nnoremap :.w !bash 385 | " ... and append output 386 | nnoremap yyp!!bash 387 | 388 | " Easy quickfix navigation 389 | nnoremap :cn 390 | nnoremap :cp 391 | 392 | " Newlines 393 | nnoremap ok 394 | nnoremap Oj 395 | 396 | " Easy header/source swap 397 | nnoremap [f :call SourceHeaderSwap() 398 | 399 | " Usual ^^ behavior re-adds to the buffer list; this leaves it hidden 400 | nnoremap :b# 401 | 402 | " Yank all top-level Python methods into register m 403 | nnoremap ,m let @m="" \| g/def /exe "normal 0f l\"Myt(" \| let @m.="," 404 | 405 | " Select the stuff I just pasted 406 | nnoremap gV `[V`] 407 | 408 | " Easy saving 409 | inoremap :w 410 | 411 | " Create a new HTML document. 412 | nnoremap ,html :-1read $HOME/.vim/.skeleton.html3jwf>a 413 | 414 | " Open in Deckset. 415 | nnoremap ,d :silent !reattach-to-user-namespace -l open -a Deckset.app %:redraw! 416 | 417 | " Sane pasting 418 | command! Paste call SmartPaste() 419 | 420 | " De-fuckify whitespace 421 | nnoremap :retab:%s/\s\+$//e 422 | 423 | " De-fuckify syntax hilighting 424 | nnoremap :syn sync fromstart 425 | 426 | " Editing vimrc 427 | nnoremap ,v :source $MYVIMRC 428 | nnoremap ,e :edit $MYVIMRC 429 | 430 | " Quickly change search hilighting 431 | nnoremap ; :set invhlsearch 432 | 433 | " Change indent continuously 434 | vmap < >gv 436 | 437 | " Tabs 438 | if exists( '*tabpagenr' ) && tabpagenr('$') != 1 439 | nnoremap ,V :tabdo source $MYVIMRC 440 | else 441 | nnoremap ,V :bufdo source $MYVIMRC 442 | endif 443 | 444 | " camelCase => camel_case 445 | vnoremap ,case :s/\v\C(([a-z]+)([A-Z]))/\2_\l\3/g 446 | 447 | " Session mappings 448 | nnoremap ,s :mksession! Session.vim 449 | 450 | " Instant Python constructors 451 | nnoremap ,c 0f(3wyt)opV:s/\([a-z_]\+\),\?/self.\1 = \1/gddV?defj 452 | 453 | " Diff Mode 454 | nnoremap ,j :if &diff \| exec 'normal ]czz' \| endif 455 | nnoremap ,k :if &diff \| exec 'normal [czz' \| endif 456 | nnoremap ,p :if &diff \| exec 'normal dp' \| endif 457 | nnoremap ,o :if &diff \| exec 'normal do' \| endif 458 | nnoremap ZD :if &diff \| exec ':qall' \| endif 459 | 460 | " Clean up Sass source 461 | vnoremap ,S :call CleanupSassSource() 462 | 463 | " Movement between tabs OR buffers 464 | " 465 | nnoremap L :call MyNext() 466 | nnoremap H :call MyPrev() 467 | 468 | " Resizing split windows 469 | nnoremap ,w :call SwapSplitResizeShortcuts() 470 | 471 | " Easy changing for scrolloff 472 | nnoremap ,b :call SwapBrowseMode() 473 | 474 | " Wraps visual selection in an HTML tag 475 | vnoremap ,w :call VisualHTMLTagWrap() 476 | 477 | " Word processing 478 | nnoremap ,N :call WordProcessingToggle() 479 | 480 | " For Notepad-like handling of wrapped lines 481 | nnoremap ,n :call NotepadLineToggle() 482 | 483 | " Quick function prototype 484 | nnoremap ,f :call QuickFunctionPrototype() 485 | 486 | " Syntax group introspection 487 | nnoremap g :echo GetSynInfo() 488 | 489 | " Yank current visual selection into screen paste buffer 490 | vnoremap \y "zy:call ScreenGet($SCREENSWAP, @z) 491 | 492 | " Yank current full filename into screen paste buffer 493 | nnoremap \f :call ScreenGet($SCREENFILE, expand('%:p')) 494 | 495 | " Quick modeline insert 496 | nnoremap \m ggOvim: et nolist sw=4 ts=4 sts=4 497 | 498 | " Directory of current file (not pwd) 499 | cnoremap %% =expand('%:h').'/' 500 | 501 | " Redo last Ex command with bang 502 | nnoremap ,! q:k0ea! 503 | 504 | " Swap order of Python function arguments 505 | nnoremap ,- :%s/\(self\.\)\?(\(self, \)\?\([a-zA-Z]\+\), \?\([a-zA-Z]\+\))/\1(\2\4, \3)/g 506 | 507 | " RST headers 508 | nnoremap :let chr=nr2char(getchar()) \| call RSTHeader(chr) 509 | inoremap 1 :call RSTHeader("=")o 510 | inoremap 2 :call RSTHeader("-")o 511 | inoremap 3 :call RSTHeader("^")o 512 | 513 | " Swap tab/space mode 514 | nnoremap , :set et! list! 515 | 516 | " Quick Ruby execute wrapper 517 | nnoremap \rex oif __FILE__ == $0 endO 518 | 519 | " Insert timestamp 520 | nnoremap "=strftime("%-l:%M%p")P 521 | inoremap =strftime("%-l:%M%p") 522 | 523 | " }}} 524 | 525 | " Custom Functions {{{ 526 | 527 | " MySessionSave() {{{ 528 | function! MySessionSave() 529 | tabdo NERDTreeClose 530 | mksession! .session.vim 531 | qall! 532 | endfunction 533 | " }}} 534 | 535 | " MyStatusLine() {{{ 536 | 537 | function! MyStatusLine() 538 | let statusline = "" 539 | " Filename (F -> full, f -> relative) 540 | let statusline .= "%f" 541 | " Buffer flags 542 | let statusline .= "%( %h%1*%m%*%r%w%) " 543 | " File format and type 544 | let statusline .= "(%{&ff}%(\/%Y%))" 545 | " Left/right separator 546 | let statusline .= "%=" 547 | " Line & column 548 | let statusline .= "(%l,%c%V) " 549 | " Character under cursor (decimal) 550 | let statusline .= "%03.3b " 551 | " Character under cursor (hexadecimal) 552 | let statusline .= "0x%02.2B " 553 | " File progress 554 | let statusline .= "| %P/%L" 555 | return statusline 556 | endfunction 557 | 558 | " }}} 559 | 560 | " CleanupSassSource() {{{ 561 | 562 | function! CleanupSassSource() 563 | " All comma delimiters should have a following space 564 | silent '<,'>s/,\([^\s]\)/, \1/ge 565 | " All comma delimiters should have 1 and only 1 space 566 | silent '<,'>s/,\s\{2,\}/, /ge 567 | endfunction 568 | 569 | " }}} 570 | 571 | " Miscellaneous {{{ 572 | function! RSTHeader(chr) 573 | " inserts an RST header without clobbering any registers 574 | put =substitute(getline('.'), '.', a:chr, 'g') 575 | endfunction 576 | 577 | function! CurrLineLength() 578 | return len(getline(line("."))) 579 | endfunction 580 | 581 | function! LineLength(row) 582 | return len(getline(a:row)) 583 | endfunction 584 | " }}} 585 | 586 | " Source/Header Swap {{{ 587 | function! SourceHeaderSwap() 588 | if expand('%:h') == 'content/ui' 589 | execute ":edit mods/base/ui/".expand('%:t:r').".py" 590 | elseif expand('%:h') == 'mods/base/ui' 591 | execute ":edit content/ui/".expand('%:t:r').".html" 592 | elseif expand('%:e') == 'h' 593 | if filereadable(expand('%:r').".cpp") 594 | execute ":edit ".expand('%:r').".cpp" 595 | else 596 | execute ":edit ".expand('%:r').".c" 597 | endif 598 | else 599 | edit %<.h 600 | endif 601 | endfunction 602 | " }}} 603 | 604 | " Syntax Info {{{ 605 | function! GetSynInfo() 606 | let stack = synstack(line("."), col(".")) 607 | 608 | let info = "" 609 | 610 | for synid in reverse(stack) 611 | if strlen(info) 612 | let info .= " < " 613 | endif 614 | 615 | let syn = GetSynDict(synid) 616 | let info .= GetSynInfoString(syn) 617 | endfor 618 | 619 | return info 620 | endfunction 621 | 622 | function! GetSynInfoString(syndict) 623 | if a:syndict["syn"] != a:syndict["hi"] 624 | let add_hi = a:syndict["hi"]." " 625 | else 626 | let add_hi = "" 627 | endif 628 | 629 | return a:syndict["syn"]." (".add_hi."fg=".a:syndict["fg"]." bg=".a:syndict["bg"].")" 630 | endfunction 631 | 632 | function! GetHereSynId(trans) 633 | return synID(line("."), col("."), a:trans) 634 | endfunction 635 | 636 | function! GetSynDict(synid) 637 | let hiid = synIDtrans(a:synid) 638 | 639 | let syn = synIDattr(a:synid, "name") 640 | let hi = synIDattr(hiid, "name") 641 | let fg = synIDattr(hiid, "fg") 642 | let bg = synIDattr(hiid, "bg") 643 | 644 | return {"syn":syn, "hi":hi, "fg":fg, "bg":bg} 645 | endfunction 646 | " }}} 647 | 648 | " Screen Functions {{{ 649 | let $SCREENSWAP = $HOME."/.screenquickswap" 650 | let $SCREENFILE = $HOME."/.screenquickfile" 651 | 652 | function! ScreenGet(targetpath, contents) 653 | " XXX TODO follow symlinks on contents for files 654 | call WriteTo(a:targetpath, a:contents) 655 | call StripEmptyLines(a:targetpath) " this is necessary because the redir in WriteTo ALWAYS inserts a newline 656 | call StripSubversionBupkus(a:targetpath) " this is necessary because the redir in WriteTo ALWAYS inserts a newline 657 | call ScreenYank(a:targetpath) 658 | redraw! 659 | endfunction 660 | 661 | function! WriteTo(targetpath, contents) 662 | silent exec "redir! > ".a:targetpath."\|silent echo \"".escape(a:contents,'"')."\"\|redir END" 663 | endfunction 664 | 665 | function! StripEmptyLines(filepath) 666 | " XXX TODO modify this to only strip the FIRST newline 667 | silent exec "!sed -i '/^$/d' ".a:filepath 668 | endfunction 669 | 670 | function! StripSubversionBupkus(filepath) 671 | silent exec "!sed -ri 's_(\.svn/text-base/|\.svn-base$)__g' ".a:filepath 672 | endfunction 673 | 674 | function! ScreenYank(filepath) 675 | silent exec "!screen -S $STY -X readbuf '".a:filepath."'" 676 | endfunction 677 | " }}} 678 | 679 | " MyNext() and MyPrev(): Movement between tabs OR buffers {{{ 680 | function! MyNext() 681 | if exists( '*tabpagenr' ) && tabpagenr('$') != 1 682 | " Tab support && tabs open 683 | normal gt 684 | else 685 | " No tab support, or no tabs open 686 | execute ":bnext" 687 | endif 688 | endfunction 689 | function! MyPrev() 690 | if exists( '*tabpagenr' ) && tabpagenr('$') != '1' 691 | " Tab support && tabs open 692 | normal gT 693 | else 694 | " No tab support, or no tabs open 695 | execute ":bprev" 696 | endif 697 | endfunction 698 | " }}} 699 | 700 | " SwapSplitResizeShortcuts(): Resizing split windows {{{ 701 | if !exists( 'g:resizeshortcuts' ) 702 | let g:resizeshortcuts = 'horizontal' 703 | nnoremap _ - 704 | nnoremap + + 705 | endif 706 | 707 | function! SwapSplitResizeShortcuts() 708 | if g:resizeshortcuts == 'horizontal' 709 | let g:resizeshortcuts = 'vertical' 710 | nnoremap _ < 711 | nnoremap + > 712 | echo "Vertical split-resizing shortcut mode." 713 | else 714 | let g:resizeshortcuts = 'horizontal' 715 | nnoremap _ - 716 | nnoremap + + 717 | echo "Horizontal split-resizing shortcut mode." 718 | endif 719 | endfunction 720 | " }}} 721 | 722 | " SwapBrowseMode(): Easy changing for scrolloff {{{ 723 | if !exists( 'g:browsemode' ) 724 | let g:browsemode = 'nobrowse' 725 | set sidescrolloff=0 726 | set scrolloff=0 727 | endif 728 | 729 | function! SwapBrowseMode() 730 | if g:browsemode == 'nobrowse' 731 | let g:browsemode = 'browse' 732 | set sidescrolloff=999 733 | set scrolloff=999 734 | echo "Browse mode enabled." 735 | else 736 | let g:browsemode = 'nobrowse' 737 | set sidescrolloff=0 738 | set scrolloff=0 739 | echo "Browse mode disabled." 740 | endif 741 | endfunction 742 | " }}} 743 | 744 | " VisualHTMLTagWrap(): Wraps visual selection in an HTML tag {{{ 745 | function! VisualHTMLTagWrap() 746 | let html_tag = input( "html_tag to wrap block: ") 747 | let jumpright = 2 + strlen( html_tag ) 748 | normal `< 749 | let init_line = line( "." ) 750 | exe "normal i<".html_tag.">" 751 | normal `> 752 | let end_line = line( "." ) 753 | " Don't jump if we're on a new line 754 | if( init_line == end_line ) 755 | " Jump right to compensate for the characters we've added 756 | exe "normal ".jumpright."l" 757 | endif 758 | exe "normal a" 759 | endfunction 760 | " }}} 761 | 762 | " QuickFunctionPrototype(): Quickly generate a function prototype. {{{ 763 | function! QuickFunctionPrototype() 764 | let function_name = input( "function name: ") 765 | if &ft == "php" 766 | " The extra a\ startinsert! is because this function drops 767 | " out of insert mode when it finishes running, and startinsert 768 | " ignores auto-indenting. 769 | exe "normal ofunction ".function_name."(){\}\Oa\" 770 | startinsert! 771 | else 772 | echo "Filetype not supported." 773 | endif 774 | endfunction 775 | " }}} 776 | 777 | " WordProcessingToggle() {{{ 778 | function! WordProcessingToggle() 779 | if !exists('b:wordprocessing') || b:wordprocessing 780 | let b:wordprocessing = 'true' 781 | setlocal wrap linebreak nolist 782 | setlocal textwidth=0 783 | echo "Word processing mode enabled." 784 | else 785 | let b:wordprocessing = 'false' 786 | setlocal nowrap nolinebreak list 787 | setlocal textwidth=80 788 | echo "Word processing mode disabled." 789 | endif 790 | endfunction 791 | " }}} 792 | 793 | " NotepadLineToggle(): For Notepad-like handling of wrapped lines {{{ 794 | function! NotepadLineToggle() 795 | if !exists('b:notepadlines') || b:notepadlines 796 | nnoremap j gj 797 | nnoremap k gk 798 | let b:notepadlines = 'true' 799 | setlocal wrap 800 | echo "Notepad wrapped lines enabled." 801 | else 802 | unmap j 803 | unmap k 804 | let b:notepadlines = 'false' 805 | setlocal nowrap 806 | echo "Notepad wrapped lines disabled." 807 | endif 808 | endfunction 809 | " }}} 810 | 811 | " Tasksheets {{{ 812 | 813 | function! UpdateTaskRemain(line_no, remain, hours_worked) 814 | let l:check_line = a:line_no 815 | let l:last_line = line('$') 816 | let l:already_has_summary = 0 817 | 818 | " echo "update " . a:line_no . " remaining: " . string(a:remain) . " with worked: " . string(a:hours_worked) 819 | 820 | while l:check_line <= l:last_line 821 | if getline(l:check_line + 1) == "" 822 | " last line before empty (end of task clause) 823 | break 824 | endif 825 | let l:check_line += 1 826 | endwhile 827 | 828 | let l:line = getline(l:check_line) 829 | 830 | if l:line =~ "^REMAIN" || l:line =~ "^TOTAL" 831 | let l:already_has_summary = 1 832 | endif 833 | 834 | let l:total = "TOTAL: " . string(a:hours_worked) 835 | 836 | if a:remain > 0.0 837 | let l:new_summary = "REMAIN: " . string(a:remain) . " (" . l:total . ")" 838 | else 839 | let l:new_summary = l:total 840 | endif 841 | 842 | if l:already_has_summary 843 | call setline(l:check_line, l:new_summary) 844 | else 845 | call append(l:check_line, l:new_summary) 846 | endif 847 | endfunction 848 | 849 | function! UpdateTaskDisplay() 850 | if &ft != 'tasksheet' | return | endif 851 | let l:default_project = substitute(system("python custom_calc_timesheet.py " . expand("%") . " default_project"), '\n', '', '') 852 | let l:tasks = split(system("python custom_calc_timesheet.py " . expand("%") . " exhaust"), '\n') 853 | 854 | exe "normal mz" 855 | 856 | syn clear taskBudgetExceeded 857 | syn clear taskBudgetExhausted 858 | 859 | for l:task in l:tasks 860 | let [l:task_id, l:project, l:remain, l:hours_worked] = split(l:task, " ") 861 | 862 | if str2float(l:remain) < 0.0 863 | exe "syn match taskBudgetExceeded /" . l:task_id . "/ contained" 864 | elseif str2float(l:remain) == 0.0 865 | exe "syn match taskBudgetExhausted /" . l:task_id . "/ contained" 866 | endif 867 | 868 | if l:project == l:default_project 869 | let l:default_project_pattern = "\\[" . l:project . "\\]" 870 | let l:anything_else_pattern = "[^\\[]" 871 | let l:project_pattern = "\\(" . l:default_project_pattern . "\\|" . l:anything_else_pattern . "\\)" 872 | else 873 | let l:project_pattern = "\\[" . l:project . "\\]" 874 | endif 875 | 876 | exe "g/^" . l:task_id . " " . l:project_pattern . "/call UpdateTaskRemain(line('.'), " . l:remain . ", " . l:hours_worked . ")" 877 | endfor 878 | 879 | exe "normal `z" 880 | endfunction 881 | 882 | " do this so it's called after everything is cleared by `syntax enable` when 883 | " re-sourcing .vimrc 884 | call UpdateTaskDisplay() 885 | 886 | " }}} 887 | 888 | " {{{ Sane Pasting 889 | 890 | function! SmartPaste() 891 | setl paste 892 | normal "+p 893 | setl nopaste 894 | endfunction 895 | 896 | " }}} 897 | 898 | function! ExtendRight() 899 | let l:start=winnr() 900 | exe "normal \l" 901 | let l:shrink=bufnr('%') 902 | close 903 | exe "normal " . l:start . "\w" 904 | exe "normal \k" 905 | vsplit 906 | exe "b " . l:shrink 907 | endfunction 908 | 909 | " }}} 910 | 911 | " Local Settings {{{ 912 | 913 | if filereadable($HOME."/.local/vim/.vimrc") 914 | source $HOME/.local/vim/.vimrc 915 | endif 916 | 917 | set exrc 918 | set secure 919 | 920 | " }}} 921 | 922 | " copy current filename to system clipboard 923 | " let @+ = expand("%") 924 | 925 | " {{{ Just for vim talk 926 | au VimEnter no_plugins.vim setl window=66 927 | au VimEnter no_plugins.vim normal 8Gzz 928 | au VimEnter no_plugins.vim command! GO normal M17jzzH 929 | au VimEnter no_plugins.vim command! BACK normal M17kzzH 930 | au VimEnter no_plugins.vim command! RUN execute getline(".") 931 | au VimEnter no_plugins.vim unmap H 932 | au VimEnter no_plugins.vim unmap L 933 | " why dont these work :( 934 | " au VimEnter no_plugins.vim nnoremap ^f :GO 935 | " au VimEnter no_plugins.vim nnoremap ^b :BACK 936 | " }}} 937 | --------------------------------------------------------------------------------