├── .gitignore ├── bin ├── rb ├── trb ├── check_json ├── tags ├── gemdoc ├── pycat ├── e ├── btc ├── build_status_fmt ├── pgpkey ├── emotiv-dump ├── battery ├── minitest ├── backup ├── run-command-on-git-revisions └── cloudapp ├── emacs.d ├── projectile-bookmarks.eld ├── custom │ ├── 04_rainbow_delimiters.el │ ├── 01_smartparens.el │ ├── 00_autocomplete.el │ ├── 02_projectile.el │ ├── 03_evil.el │ ├── 07_ruby.el │ ├── 06_badwolf.el │ └── 05_rainbow_mode.el ├── ac-comphist.dat ├── Cask └── init.el ├── agignore ├── zshrc ├── gemrc ├── .jslintrc ├── jslintrc ├── gitignore ├── githelpers ├── zsh ├── env ├── functions ├── config ├── func │ ├── run-command-on-git-revisions │ ├── zgitinit │ ├── prompt_wunjo_setup │ └── prompt_grb_setup └── aliases ├── emacs ├── gitconfig.erb ├── Readme.rdoc ├── Rakefile ├── osx-fix.sh ├── tmux.conf ├── irbrc ├── screenrc └── railsrc /.gitignore: -------------------------------------------------------------------------------- 1 | emacs.d/.cask 2 | emacs.d/ac-comphist.dat -------------------------------------------------------------------------------- /bin/rb: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | $MY_RUBY_HOME/bin/ruby $@ 6 | -------------------------------------------------------------------------------- /emacs.d/projectile-bookmarks.eld: -------------------------------------------------------------------------------- 1 | ("~/Code/wimdu/wimdu/" "~/.dotfiles/") -------------------------------------------------------------------------------- /bin/trb: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | $MY_RUBY_HOME/bin/testrb $@ 6 | -------------------------------------------------------------------------------- /emacs.d/custom/04_rainbow_delimiters.el: -------------------------------------------------------------------------------- 1 | (global-rainbow-delimiters-mode) 2 | -------------------------------------------------------------------------------- /agignore: -------------------------------------------------------------------------------- 1 | *.log 2 | /tmp/* 3 | tmp/* 4 | tmp 5 | .DS_Store 6 | .bundle 7 | doc 8 | coverage 9 | -------------------------------------------------------------------------------- /bin/check_json: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'json' 4 | 5 | p JSON.parse(File.read(ARGV[0])) 6 | -------------------------------------------------------------------------------- /bin/tags: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | /usr/local/bin/ctags -R --languages=ruby --exclude=spec,test,features . `rvm gemdir`/gems 6 | -------------------------------------------------------------------------------- /zshrc: -------------------------------------------------------------------------------- 1 | source ~/.dotfiles/zsh/env 2 | source ~/.dotfiles/zsh/functions 3 | source ~/.dotfiles/zsh/aliases 4 | source ~/.dotfiles/zsh/config 5 | 6 | source ~/.zshrc.local 7 | -------------------------------------------------------------------------------- /emacs.d/ac-comphist.dat: -------------------------------------------------------------------------------- 1 | ((("exit-splash-screen" . 2 | [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) 3 | ("line-number-mode" . 4 | [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) 5 | ("linum-mode" . 6 | [1 0 0 0 0 0 0 0 0 0]))) 7 | -------------------------------------------------------------------------------- /gemrc: -------------------------------------------------------------------------------- 1 | --- 2 | :verbose: true 3 | :sources: 4 | - http://rubygems.org/ 5 | :update_sources: true 6 | :sources: 7 | - http://rubygems.org/ 8 | :backtrace: false 9 | :bulk_threshold: 1000 10 | :benchmark: false 11 | -------------------------------------------------------------------------------- /bin/gemdoc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export GEMDIR=`gem env gemdir` 3 | 4 | gemdoc() { 5 | local gems=($GEMDIR/doc/$1*/rdoc/index.html) 6 | echo ${gems[@]:-1} 7 | open ${gems[@]:-1} 8 | } 9 | 10 | complete -W '$(`which ls` $GEMDIR/doc)' gemdoc 11 | -------------------------------------------------------------------------------- /emacs.d/custom/01_smartparens.el: -------------------------------------------------------------------------------- 1 | (require 'smartparens-config) 2 | (require 'smartparens-ruby) 3 | (smartparens-global-mode) 4 | (show-smartparens-global-mode t) 5 | (sp-with-modes '(rhtml-mode) 6 | (sp-local-pair "<" ">") 7 | (sp-local-pair "<%" "%>")) 8 | -------------------------------------------------------------------------------- /bin/pycat: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ ! -t 0 ];then 3 | file=/dev/stdin 4 | elif [ -f $1 ];then 5 | file=$1 6 | else 7 | echo "Usage: $0 code.c" 8 | echo "or e.g. head code.c|$0" 9 | exit 1 10 | fi 11 | pygmentize -f terminal -g $file -------------------------------------------------------------------------------- /.jslintrc: -------------------------------------------------------------------------------- 1 | /*jslint white: true, forin: true, onevar: true, undef: true, eqeqeq: true, bitwise: true, immed: true, indent: 2, maxlen: 120 */ 2 | /*global jQuery, $, module, require, GLOBAL, __dirname, console, Buffer, process, exports, JSON */ 3 | /* vim: set ft=javascript: */ 4 | -------------------------------------------------------------------------------- /jslintrc: -------------------------------------------------------------------------------- 1 | /*jslint white: true, onevar: true, undef: true, nomen: false, regexp: true, plusplus: true, bitwise: true, devel: true, node: true, maxerr: 50, indent: 2 */ 2 | /*global jQuery, $, _, Backbone, window, module, require, GLOBAL, console, Buffer, process, exports, JSON */ 3 | /* vim: set ft=javascript: */ 4 | -------------------------------------------------------------------------------- /emacs.d/custom/00_autocomplete.el: -------------------------------------------------------------------------------- 1 | (require 'auto-complete-config) 2 | (add-to-list 'ac-dictionary-directories 3 | "~/.emacs.d/.cask/24.3.50.1/elpa/auto-complete-20130724.1750/dict") 4 | (ac-config-default) 5 | (setq ac-ignore-case nil) 6 | ; (add-to-list 'ac-modes 'enh-ruby-mode) 7 | ; (add-to-list 'ac-modes 'web-mode) 8 | -------------------------------------------------------------------------------- /gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .svn 3 | *~ 4 | .*.swp 5 | .rbx 6 | tags 7 | TAGS 8 | .powenv 9 | .powrc 10 | .rvmrc.local 11 | *.json.erb 12 | h.rb 13 | .ruby-version 14 | .bundle 15 | run_tests.sh 16 | .sass-cache 17 | .pygments-cache 18 | .#* 19 | exe 20 | doit 21 | *.trace 22 | .console_history 23 | *.dSYM 24 | vendor/bundle 25 | dump.rdb 26 | -------------------------------------------------------------------------------- /emacs.d/custom/02_projectile.el: -------------------------------------------------------------------------------- 1 | (require 'grizzl) 2 | (projectile-global-mode) 3 | (setq projectile-enable-caching t) 4 | (setq projectile-completion-system 'grizzl) 5 | ;; Press Command-p for fuzzy find in project 6 | (global-set-key (kbd "s-p") 'projectile-find-file) 7 | ;; Press Command-b for fuzzy switch buffer 8 | (global-set-key (kbd "s-b") 'projectile-switch-to-buffer) 9 | -------------------------------------------------------------------------------- /githelpers: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HASH="%C(yellow)%h%C(reset)" 4 | RELATIVE_TIME="%C(green)%ar%C(reset)" 5 | AUTHOR="%C(bold blue)%an%C(reset)" 6 | REFS="%C(red)%d%C(reset)" 7 | SUBJECT="%s" 8 | 9 | FORMAT="$HASH{$RELATIVE_TIME{$AUTHOR{$REFS $SUBJECT" 10 | 11 | function pretty_git_log() { 12 | git log --graph --pretty="tformat:$FORMAT" $* | 13 | column -t -s '{' | 14 | less -FXRS 15 | } -------------------------------------------------------------------------------- /zsh/env: -------------------------------------------------------------------------------- 1 | # Enviroment Variables 2 | export EDITOR="vim" 3 | export LC_CTYPE=en_US.UTF-8 4 | export LANG=en_US.UTF-8 5 | export TERM=xterm-256color 6 | export HISTSIZE=500 7 | export HISTFILESIZE=1500 8 | export HISTCONTROL=erasedups 9 | export PROMPT_COMMAND='history -a' # write previous line as prompt is displayed 10 | export CLICOLOR=1 11 | export PATH=/usr/local/bin:$PATH:$HOME/.dotfiles/bin 12 | -------------------------------------------------------------------------------- /bin/e: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Quick shortcut to an editor. 4 | # 5 | # This means that as I travel back and forth between editors, hey, I don't have 6 | # to re-learn any arcane commands. Neat. 7 | # 8 | # USAGE: 9 | # 10 | # $ e 11 | # # => opens the current directory in your editor 12 | # 13 | # $ e . 14 | # $ e /usr/local 15 | # # => opens the specified directory in your editor 16 | 17 | if test "$1" == "" 18 | then 19 | $($EDITOR .) 20 | else 21 | $($EDITOR $1) 22 | fi -------------------------------------------------------------------------------- /emacs.d/custom/03_evil.el: -------------------------------------------------------------------------------- 1 | (global-evil-leader-mode) 2 | (evil-mode 1) 3 | 4 | (define-key evil-normal-state-map (kbd "C-u") 'evil-scroll-up) 5 | 6 | (key-chord-mode 1) 7 | (key-chord-define evil-insert-state-map "jk" 'evil-normal-state) 8 | 9 | (setq evil-leader/leader ",") 10 | (evil-leader/set-key 11 | "w" 'save-buffer 12 | "d" 'dash-at-point 13 | "q" 'save-buffers-kill-terminal 14 | "o" 'projectile-find-file 15 | "gs" 'magit-status 16 | "gb" 'magit-blame-mode 17 | "a" 'ag) 18 | -------------------------------------------------------------------------------- /emacs: -------------------------------------------------------------------------------- 1 | (load "~/.emacs.d/init.el") 2 | (custom-set-variables 3 | ;; custom-set-variables was added by Custom. 4 | ;; If you edit it by hand, you could mess it up, so be careful. 5 | ;; Your init file should contain only one such instance. 6 | ;; If there is more than one, they won't work right. 7 | '(safe-local-variable-values (quote ((encoding . utf-8))))) 8 | (custom-set-faces 9 | ;; custom-set-faces was added by Custom. 10 | ;; If you edit it by hand, you could mess it up, so be careful. 11 | ;; Your init file should contain only one such instance. 12 | ;; If there is more than one, they won't work right. 13 | ) 14 | -------------------------------------------------------------------------------- /bin/btc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | blockchain = 0 4 | wallet = 0 5 | kraken = 2.612340 6 | cash = 0 7 | 8 | total = wallet + blockchain + kraken 9 | 10 | eur_rate = `curl --silent http://data.mtgox.com/api/2/BTCEUR/money/ticker_fast | jq '.data .last_local .value | tonumber'`.to_i 11 | 12 | invested = 150 + 170 + 50 + 430 13 | spent = 220 + 30 + 15 14 | 15 | total_value = (total * eur_rate) + cash 16 | 17 | puts "BTC: #{total}. Rate: #{eur_rate} EUR. Total value: #{total_value} (from which #{cash} EUR is cash), invested #{invested} (but after spending #{spent}, it would be #{invested - spent}), profit: #{total_value - invested}, profit after spending: #{total_value - invested + spent}" -------------------------------------------------------------------------------- /zsh/functions: -------------------------------------------------------------------------------- 1 | # Returns a definition from wikipedia. 2 | wiki() { 3 | dig +short txt $1.wp.dg.cx 4 | } 5 | 6 | profile() { 7 | CPUPROFILE=/tmp/my_app_profile \ 8 | RUBYOPT="-r`gem which perftools | tail -1`" \ 9 | $1 $2 $3 $4 $5 && env ruby -S pprof.rb --gif /tmp/my_app_profile > profile.gif && open profile.gif 10 | } 11 | 12 | dns_zone_transfer() { 13 | dig @$(host $1 | grep '[0-9]' | awk '{print $4}') $1 -t AXFR 14 | } 15 | 16 | ip() { 17 | ifconfig en1 | grep '192' | awk '{print $2}' 18 | } 19 | 20 | external_ip() { 21 | curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g' 22 | } 23 | 24 | prune_branches() { 25 | git branch --merged master | grep -v 'master$' | xargs git branch -d 26 | } 27 | -------------------------------------------------------------------------------- /gitconfig.erb: -------------------------------------------------------------------------------- 1 | [user] 2 | name = <%= print("Your Name: "); STDOUT.flush; STDIN.gets.chomp %> 3 | email = <%= print("Your Email: "); STDOUT.flush; STDIN.gets.chomp %> 4 | [alias] 5 | co = checkout 6 | l = "!source ~/.githelpers && pretty_git_log" 7 | la = !git l --all 8 | r = !git l -30 9 | ra = !git r --all 10 | [color] 11 | diff = auto 12 | status = auto 13 | branch = auto 14 | ui = auto 15 | [merge] 16 | tool = vimdiff 17 | [core] 18 | excludesfile = <%= ENV['HOME'] %>/.gitignore 19 | editor = <%= print("Preferred git editor (vim?): "); STDOUT.flush; STDIN.gets.chomp %> 20 | autocrlf = input 21 | [apply] 22 | whitespace = nowarn 23 | [format] 24 | pretty = %C(yellow)%h%Creset %s %C(red)(%cr)%Creset 25 | [push] 26 | default = current 27 | -------------------------------------------------------------------------------- /emacs.d/Cask: -------------------------------------------------------------------------------- 1 | (source "melpa" "http://melpa.milkbox.net/packages/") 2 | 3 | (depends-on "ag") 4 | (depends-on "auto-complete") 5 | (depends-on "bundler") 6 | (depends-on "cask") 7 | (depends-on "dash") 8 | (depends-on "dash-at-point") 9 | (depends-on "enh-ruby-mode") 10 | (depends-on "epl") 11 | (depends-on "evil") 12 | (depends-on "evil-leader") 13 | (depends-on "evil-paredit") 14 | (depends-on "f") 15 | (depends-on "gist") 16 | (depends-on "git-gutter") 17 | (depends-on "git-gutter-fringe") 18 | (depends-on "grizzl") 19 | (depends-on "key-chord") 20 | (depends-on "magit") 21 | (depends-on "pallet") 22 | (depends-on "popup") 23 | (depends-on "projectile") 24 | (depends-on "rainbow-delimiters") 25 | (depends-on "smartparens") 26 | (depends-on "web-mode") 27 | (depends-on "yaml-mode") -------------------------------------------------------------------------------- /bin/build_status_fmt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'json' 3 | 4 | class String 5 | def colorize(color_code) 6 | "\e[#{color_code}m#{self}\e[0m" 7 | end 8 | 9 | def red 10 | colorize(31) 11 | end 12 | 13 | def green 14 | colorize(32) 15 | end 16 | 17 | def yellow 18 | colorize(33) 19 | end 20 | end 21 | 22 | if __FILE__ == $0 23 | results = JSON.parse(ARGF.read.gsub("=>", ":").gsub(":nil", ":\"\"")) 24 | 25 | results.values.fetch(0, []).each do |job, status| 26 | status = status && status.size > 0 ? status : "UNKNOWN" 27 | color = if status == "SUCCESS" 28 | :green 29 | elsif status == "FAILURE" 30 | :red 31 | else 32 | :yellow 33 | end 34 | puts "#{job} => #{status.public_send(color)}" 35 | end 36 | end -------------------------------------------------------------------------------- /bin/pgpkey: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'open-uri' 3 | 4 | abort("Usage: pgpkey [my.friend@gmail.com|emails.txt]") unless ARGV.first 5 | 6 | emails = if File.exist?(ARGV.first) 7 | File.readlines(ARGV.first).map(&:chomp) 8 | elsif ARGV.first =~ /@/ 9 | [ARGV.first] 10 | end 11 | 12 | emails.each do |email| 13 | begin 14 | lines = open("http://pgp.mit.edu:11371/pks/lookup?search=#{URI.encode(email)}&op=index").readlines 15 | 16 | p lines 17 | id = lines.reject { |line| 18 | line =~ /REVOKED/ 19 | }.select { |line| 20 | line =~ /pks\/lookup/ 21 | }.each { |l| 22 | p l 23 | }.first.scan(/([A-Z0-9]+)<\/a>/).flatten.first 24 | 25 | puts "Found key #{id} for #{ARGV.first}." 26 | 27 | `gpg --recv-keys #{id}` 28 | rescue 29 | puts "Didn't find any key for #{ARGV.first}." 30 | end 31 | end -------------------------------------------------------------------------------- /bin/emotiv-dump: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pg' 3 | require 'csv' 4 | 5 | FIELDS = %w(af3 af3_quality af4 af4_quality f3 f3_quality f4 f4_quality f7 f7_quality f8 f8_quality fc5 fc5_quality fc6 fc6_quality o1 o1_quality o2 o2_quality p7 p7_quality p8 p8_quality t7 t7_quality t8 t8_quality timestamp) 6 | 7 | def banner 8 | abort "Usage: #{$PROGRAM_NAME} session_name output_file.csv" 9 | end 10 | 11 | session = ARGV[0] || banner 12 | output = ARGV[1] || banner 13 | 14 | conn = PG.connect( dbname: 'zoku' ) 15 | result = conn.exec(<<-QUERY) 16 | SELECT emotivdatum.* FROM emotivdatum 17 | INNER JOIN emotivsession ON emotivdatum.session_id = emotivsession.id AND emotivsession.name = '#{session}'; 18 | QUERY 19 | 20 | CSV.open(output, "wb") do |csv| 21 | csv << FIELDS 22 | result.each do |row| 23 | csv << row.values_at(*FIELDS) 24 | end 25 | csv 26 | end -------------------------------------------------------------------------------- /emacs.d/init.el: -------------------------------------------------------------------------------- 1 | (require 'cask "/usr/local/Cellar/cask/0.7.1/share/emacs/site-lisp/cask.el") 2 | (cask-initialize) 3 | (require 'pallet) 4 | (add-to-list 'load-path "~/.emacs.d/custom") 5 | 6 | (load "00_autocomplete.el") 7 | (load "01_smartparens.el") 8 | (load "02_projectile.el") 9 | (load "03_evil.el") 10 | (load "04_rainbow_delimiters.el") 11 | (load "05_rainbow_mode.el") 12 | (load "06_badwolf.el") 13 | (load "07_ruby.el") 14 | 15 | (menu-bar-mode -1) 16 | 17 | ;; Navigate between windows using Alt-1, Alt-2, Shift-left, shift-up, shift-right 18 | (windmove-default-keybindings) 19 | 20 | ;; Enable copy and pasting from clipboard 21 | (setq x-select-enable-clipboard t) 22 | 23 | ;; Disable backups 24 | (setq backup-inhibited t) 25 | ;;disable auto save 26 | (setq auto-save-default nil) 27 | (setq inhibit-startup-message t) 28 | 29 | (global-linum-mode 1) 30 | (setq linum-format "%3d ") 31 | -------------------------------------------------------------------------------- /bin/battery: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # MacBook battery level formatted for tmux status bar 3 | # Adapted from: https://github.com/Goles/Battery 4 | 5 | battery_charge() { 6 | ioreg -c AppleSmartBattery -w0 | \ 7 | grep -o '"[^"]*" = [^ ]*' | \ 8 | sed -e 's/= //g' -e 's/"//g' | \ 9 | sort | \ 10 | while read key value; do 11 | case $key in 12 | "MaxCapacity") 13 | export maxcap=$value;; 14 | "CurrentCapacity") 15 | export curcap=$value;; 16 | esac 17 | if [[ -n "$maxcap" && -n $curcap ]]; then 18 | CAPACITY=$(( 100 * curcap / maxcap)) 19 | printf "%d" $CAPACITY 20 | break 21 | fi 22 | done 23 | } 24 | 25 | BATTERY_STATUS=`battery_charge` 26 | [ -z "$BATTERY_STATUS" ] && exit 1 27 | 28 | if [ $BATTERY_STATUS -lt 25 ]; then 29 | fg=colour210 30 | bg=colour88 31 | elif [ $BATTERY_STATUS -lt 75 ]; then 32 | fg=colour228 33 | bg=colour94 34 | else 35 | fg=colour8 36 | bg=colour234 37 | fi 38 | 39 | printf "#[fg=${fg},bg=${bg}] %2d%%" $BATTERY_STATUS 40 | -------------------------------------------------------------------------------- /bin/minitest: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | shopt -s globstar 4 | 5 | # Public: Resolves files to be run by the test runner. 6 | # 7 | # path - Can be either a test file, or a directory that contains tests at any 8 | # depth. 9 | # 10 | # Returns a glob expression. 11 | resolve_files () 12 | { 13 | if [[ $1 =~ .rb$ ]] ; then 14 | # if provided a file ending in .rb execute a single test 15 | echo $1 16 | elif [[ -n "$1" ]] ; then 17 | # if provided any other argument execute all tests under one folder 18 | for file in $1/**/*_test.rb 19 | do 20 | echo " -r./$file" 21 | done 22 | else 23 | # run all tests by default 24 | for file in test/**/*_test.rb 25 | do 26 | echo " -r./$file" 27 | done 28 | fi 29 | } 30 | 31 | # Handle -h argument and show usage banner 32 | while getopts :h o 33 | do 34 | case "$o" in 35 | h) echo "Usage: $0 file_or_path" 36 | exit 1; 37 | esac 38 | done 39 | 40 | # Run the tests! 41 | path=$(resolve_files $1) 42 | 43 | echo $path 44 | ruby -e\"nil\" -Ilib:test -rminitest/autorun $path -------------------------------------------------------------------------------- /bin/backup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | IFS=$'\n' 3 | 4 | # Copies a few key files to a mounted partition. 5 | # 6 | # I use Time Machine for backups, but I also wanted to build out an 7 | # offsite backup with my critical nonreplaceable data (photos, documents, 8 | # etc). Since it's mobile, encryption is a plus (which Time Machine 9 | # doesn't easily do). I create an encrypted sparsebundle on a tiny USB 10 | # drive and do it to it. 11 | 12 | 13 | # Your sparsebundle. 14 | sparsebundle="/Volumes/Data/backup.sparsebundle" 15 | 16 | # Your destination. My sparsebundle mounts to "backup". 17 | backup_location="/Volumes/Backup" 18 | 19 | # Directories to backup. Recursive, implied home (~) location. 20 | directories=( 21 | Documents 22 | "Library/Application Support/Adium 2.0" 23 | Movies 24 | Music 25 | Pictures 26 | ) 27 | 28 | 29 | 30 | hdiutil attach -noverify $sparsebundle 31 | 32 | for directory in ${directories[@]} 33 | do 34 | rsync -avh --progress --delete ~/$directory $backup_location 35 | done 36 | 37 | hdiutil detach $backup_location 38 | diskutil eject Data 39 | -------------------------------------------------------------------------------- /zsh/config: -------------------------------------------------------------------------------- 1 | # Colors from http://wiki.archlinux.org/index.php/Color_Bash_Prompt 2 | # Misc 3 | NO_COLOR='\e[0m' #disable any colors 4 | # Regular colors 5 | BLACK='\e[0;30m' 6 | RED='\e[0;31m' 7 | GREEN='\e[0;32m' 8 | YELLOW='\e[0;33m' 9 | BLUE='\e[0;34m' 10 | MAGENTA='\e[0;35m' 11 | CYAN='\e[0;36m' 12 | WHITE='\e[0;37m' 13 | # Emphasized (bolded) colors 14 | EBLACK='\e[1;30m' 15 | ERED='\e[1;31m' 16 | EGREEN='\e[1;32m' 17 | EYELLOW='\e[1;33m' 18 | EBLUE='\e[1;34m' 19 | EMAGENTA='\e[1;35m' 20 | ECYAN='\e[1;36m' 21 | EWHITE='\e[1;37m' 22 | # Underlined colors 23 | UBLACK='\e[4;30m' 24 | URED='\e[4;31m' 25 | UGREEN='\e[4;32m' 26 | UYELLOW='\e[4;33m' 27 | UBLUE='\e[4;34m' 28 | UMAGENTA='\e[4;35m' 29 | UCYAN='\e[4;36m' 30 | UWHITE='\e[4;37m' 31 | # Background colors 32 | BBLACK='\e[40m' 33 | BRED='\e[41m' 34 | BGREEN='\e[42m' 35 | BYELLOW='\e[43m' 36 | BBLUE='\e[44m' 37 | BMAGENTA='\e[45m' 38 | BCYAN='\e[46m' 39 | BWHITE='\e[47m' 40 | 41 | # Use vi-like bindings instead of emac ones 42 | bindkey -v 43 | 44 | # Use ^R for incremental search 45 | bindkey '^R' history-incremental-search-backward 46 | -------------------------------------------------------------------------------- /zsh/func/run-command-on-git-revisions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script runs a given command over a range of Git revisions. Note that it 4 | # will check past revisions out! Exercise caution if there are important 5 | # untracked files in your working tree. 6 | # 7 | # This came from Gary Bernhardt's dotfiles: 8 | # https://github.com/garybernhardt/dotfiles 9 | # 10 | # Example usage: 11 | # $ run-command-on-git-revisions origin/master master 'python runtests.py' 12 | 13 | set -e 14 | 15 | start_ref=$1 16 | end_ref=$2 17 | test_command=$3 18 | 19 | main() { 20 | enforce_usage 21 | run_tests 22 | } 23 | 24 | enforce_usage() { 25 | if [ -z "$test_command" ]; then 26 | usage 27 | exit $E_BADARGS 28 | fi 29 | } 30 | 31 | usage() { 32 | echo "usage: `basename $0` start_ref end_ref test_command" 33 | } 34 | 35 | run_tests() { 36 | revs=`log_command git rev-list --reverse ${start_ref}..${end_ref}` 37 | 38 | for rev in $revs; do 39 | echo "Checking out: $(git log --oneline -1 $rev)" 40 | log_command git checkout --quiet $rev 41 | log_command $test_command 42 | done 43 | log_command git checkout $end_ref 44 | echo "OK for all revisions!" 45 | } 46 | 47 | log_command() { 48 | echo "=> $*" >&2 49 | eval $* 50 | } 51 | 52 | main 53 | -------------------------------------------------------------------------------- /Readme.rdoc: -------------------------------------------------------------------------------- 1 | = Codegram dotfiles 2 | 3 | These are the dotfiles we use at Codegram! The repo is heavily inspired on Ryan 4 | Bates' dotfiles, with the nice Rakefile and stuff. 5 | 6 | == Installation 7 | 8 | git clone git://github.com/codegram/dotfiles ~/.dotfiles 9 | cd ~/.dotfiles 10 | rake install 11 | 12 | == Using your own config along 13 | 14 | These dotfiles require this file: 15 | 16 | ~/.zshrc.local 17 | 18 | Here you can add your own mapping without risking to lose them when updating the repo :) 19 | 20 | == Emacs 21 | 22 | If you want to use emacs, you'll have to install Cask and pallet: 23 | 24 | brew install cask 25 | 26 | And now go to: 27 | 28 | https://github.com/rdallasgray/pallet 29 | 30 | == Tmux 31 | 32 | Go to your project directory and type this: 33 | 34 | $ tmux 35 | 36 | Keys to move around tmux: 37 | 38 | * `\`o` (backtick and the letter o): Switch the current pane (split). 39 | * `\`k`: Kill the current window. 40 | * `\`c`: Create a new window (tab). 41 | * `\`n`: Switch windows (tabs). 42 | 43 | == Looking for our vimfiles as well? 44 | 45 | git clone http://github.com/codegram/vimfiles.git ~/.vim 46 | sh ~/.vim/install.sh 47 | 48 | Read about our vim configuration, custom mappings and plugins on the repo 49 | readme! 50 | 51 | http://github.com/codegram/vimfiles 52 | 53 | Have fun! :) 54 | -------------------------------------------------------------------------------- /zsh/aliases: -------------------------------------------------------------------------------- 1 | # PostgreSQL 2 | alias start_postgres="launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist" 3 | alias stop_postgres="launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist" 4 | 5 | # MySQL 6 | alias start_mysql="launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist" 7 | alias stop_mysql="launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist" 8 | 9 | # Git 10 | alias g="git status" 11 | alias ga="git add" 12 | alias gaa="git add --all" 13 | alias gc="git commit -m" 14 | alias gca="git commit -am" 15 | alias gb="git branch" 16 | alias gba="git branch -a" 17 | alias gbd="git branch -d" 18 | alias gco="git checkout" 19 | alias gcob="git checkout -b" 20 | alias gf="git fetch" 21 | alias gm="git merge" 22 | alias gr="git rebase" 23 | alias gl="git log" 24 | alias gs="git show" 25 | alias gd="git diff" 26 | alias gbl="git blame" 27 | alias gps="git push" 28 | alias gpl="git pull" 29 | 30 | # TMUX 31 | alias ta="tmux attach" 32 | alias tls="tmux list-sessions" 33 | alias tk="tmux kill-server" 34 | # alias t="tmux start && TERM=screen-256color-bce tmux attach" 35 | 36 | # Ruby 37 | alias r="ruby" 38 | alias i="pry --simple-prompt" 39 | alias b="bundle" 40 | alias be="bundle exec" 41 | alias bi="bundle install" 42 | alias bu="bundle update" 43 | 44 | # Rails console 45 | alias sc="pry --simple-prompt -r config/environment" 46 | 47 | alias vi=vim 48 | alias gss="git status -sb" 49 | -------------------------------------------------------------------------------- /bin/run-command-on-git-revisions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script runs a given command over a range of Git revisions. Note that it 4 | # will check past revisions out! Exercise caution if there are important 5 | # untracked files in your working tree. 6 | # 7 | # This came from Gary Bernhardt's dotfiles: 8 | # https://github.com/garybernhardt/dotfiles 9 | # 10 | # Example usage: 11 | # $ run-command-on-git-revisions origin/master master 'python runtests.py' 12 | 13 | set -e 14 | 15 | if [[ $1 == -v ]]; then 16 | verbose=1 17 | shift 18 | fi 19 | start_ref=$1 20 | end_ref=$2 21 | test_command=$3 22 | 23 | main() { 24 | enforce_usage 25 | run_tests 26 | } 27 | 28 | enforce_usage() { 29 | if [ -z "$test_command" ]; then 30 | usage 31 | exit $E_BADARGS 32 | fi 33 | } 34 | 35 | usage() { 36 | echo "usage: `basename $0` start_ref end_ref test_command" 37 | } 38 | 39 | run_tests() { 40 | revs=`log_command git rev-list --reverse ${start_ref}..${end_ref}` 41 | 42 | for rev in $revs; do 43 | debug "Checking out: $(git log --oneline -1 $rev)" 44 | log_command git checkout --quiet $rev 45 | log_command $test_command 46 | log_command git reset --hard 47 | done 48 | log_command git checkout --quiet $end_ref 49 | debug "OK for all revisions!" 50 | } 51 | 52 | log_command() { 53 | debug "=> $*" 54 | eval $* 55 | } 56 | 57 | debug() { 58 | if [ $verbose ]; then 59 | echo $* >&2 60 | fi 61 | } 62 | 63 | main 64 | 65 | -------------------------------------------------------------------------------- /bin/cloudapp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | # cloudapp 4 | # Zach Holman / @holman 5 | # 6 | # Uploads a file from the command line to CloudApp, drops it into your 7 | # clipboard (on a Mac, at least). 8 | # 9 | # Example: 10 | # 11 | # cloudapp drunk-blake.png 12 | # 13 | # This requires Aaron Russell's cloudapp_api gem: 14 | # 15 | # gem install cloudapp_api 16 | # 17 | # Requires you set your CloudApp credentials in ~/.cloudapp as a simple file of: 18 | # 19 | # email 20 | # password 21 | 22 | require 'rubygems' 23 | 24 | ['json', 'cloudapp_api'].each do |gem| 25 | begin 26 | require gem 27 | rescue LoadError 28 | puts "You need to install #{gem}: gem install #{gem}" 29 | exit!(1) 30 | end 31 | end 32 | 33 | config_file = "#{ENV['HOME']}/.cloudapp" 34 | unless File.exist?(config_file) 35 | puts "You need to type your email and password (one per line) into "+ 36 | "`~/.cloudapp`" 37 | exit!(1) 38 | end 39 | 40 | email,password = File.read(config_file).split("\n") 41 | 42 | if ARGV[0].nil? 43 | puts "You need to specify a file to upload." 44 | exit!(1) 45 | end 46 | 47 | urls = [] 48 | ARGV.each do |x| 49 | CloudApp.authenticate(email,password) 50 | puts "Attempting to upload #{x}" 51 | url = CloudApp::Item.create(:upload, {:file => x}).url 52 | 53 | # Say it for good measure. 54 | puts "Uploaded #{x} to #{url}" 55 | 56 | # Get the embed link. 57 | url = "#{url}/#{ARGV[0].split('/').last}" 58 | urls << url 59 | end 60 | 61 | # Copy it to your (Mac's) clipboard. 62 | `echo '#{urls.join(',')}' | tr -d "\n" | pbcopy` 63 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'erb' 3 | 4 | desc "install the dot files into user's home directory" 5 | task :install do 6 | replace_all = false 7 | Dir['*'].each do |file| 8 | next if %w[Rakefile README.rdoc Readme.rdoc LICENSE zsh zshrc].include? file 9 | 10 | if File.exist?(File.join(ENV['HOME'], ".#{file.sub('.erb', '')}")) 11 | if File.identical? file, File.join(ENV['HOME'], ".#{file.sub('.erb', '')}") 12 | puts "identical ~/.#{file.sub('.erb', '')}" 13 | elsif replace_all 14 | replace_file(file) 15 | else 16 | print "overwrite ~/.#{file.sub('.erb', '')}? [ynaq] " 17 | case $stdin.gets.chomp 18 | when 'a' 19 | replace_all = true 20 | replace_file(file) 21 | when 'y' 22 | replace_file(file) 23 | when 'q' 24 | exit 25 | else 26 | puts "skipping ~/.#{file.sub('.erb', '')}" 27 | end 28 | end 29 | else 30 | link_file(file) 31 | end 32 | end 33 | 34 | system('cat zshrc >> ~/.zshrc') 35 | end 36 | 37 | def replace_file(file) 38 | system %Q{rm -rf "$HOME/.#{file.sub('.erb', '')}"} 39 | link_file(file) 40 | end 41 | 42 | def link_file(file) 43 | if file =~ /.erb$/ 44 | puts "generating ~/.#{file.sub('.erb', '')}" 45 | File.open(File.join(ENV['HOME'], ".#{file.sub('.erb', '')}"), 'w') do |new_file| 46 | new_file.write ERB.new(File.read(file)).result(binding) 47 | end 48 | else 49 | puts "linking ~/.#{file}" 50 | system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"} 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /emacs.d/custom/07_ruby.el: -------------------------------------------------------------------------------- 1 | (add-to-list 'auto-mode-alist '("\\.rb$" . enh-ruby-mode)) 2 | (add-to-list 'auto-mode-alist '("Gemfile$" . enh-ruby-mode)) 3 | (add-to-list 'auto-mode-alist '("Rakefile$" . enh-ruby-mode)) 4 | (add-to-list 'auto-mode-alist '("\\.rake$" . enh-ruby-mode)) 5 | 6 | (setq enh-ruby-program "~/.rubies/2.0.0-p247/bin/ruby") 7 | 8 | (add-hook 'enh-ruby-mode-hook 'ruby-end-mode) 9 | 10 | (evil-define-key 'insert enh-ruby-mode-map (kbd "RET") 'evil-ret-and-indent) 11 | 12 | (remove-hook 'enh-ruby-mode-hook 'erm-define-faces) 13 | 14 | (defun toggle-ruby-block-style () 15 | (interactive) 16 | (enh-ruby-beginning-of-block) 17 | (if (looking-at-p "{") 18 | (let ((beg (point))) 19 | (delete-char 1) 20 | (insert (if (looking-back "[^ ]") " do" "do")) 21 | (when (looking-at "[ ]*|.*|") 22 | (search-forward-regexp "[ ]*|.*|" (line-end-position))) 23 | (insert "\n") 24 | (goto-char (- (line-end-position) 1)) 25 | (delete-char 1) 26 | (insert "\nend") 27 | (evil-indent beg (point)) 28 | ) 29 | (progn 30 | (ruby-end-of-block) 31 | (save-excursion ;; join lines if block is 1 line of code long 32 | (let ((end (line-end-position))) 33 | (enh-ruby-beginning-of-block) 34 | (if (= 2 (- (line-number-at-pos end) (line-number-at-pos))) 35 | (evil-join (point) end))) 36 | (kill-line) 37 | (insert " }") 38 | (enh-ruby-beginning-of-block) 39 | (delete-char 2) 40 | (insert "{" ))))) 41 | 42 | (setq ruby-indent-level 2) 43 | -------------------------------------------------------------------------------- /osx-fix.sh: -------------------------------------------------------------------------------- 1 | #Fix fonth smoothing 2 | defaults -currentHost write -globalDomain AppleFontSmoothing -int 0 3 | 4 | #Disable window animations 5 | defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false 6 | 7 | #Disable webkit homepage 8 | defaults write org.webkit.nightly.WebKit StartPageDisabled -bool true 9 | 10 | #Use current directory as default search scope in Finder 11 | defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" 12 | 13 | #Show Path bar in Finder 14 | defaults write com.apple.finder ShowPathbar -bool true 15 | 16 | #Show Status bar in Finder 17 | defaults write com.apple.finder ShowStatusBar -bool true 18 | 19 | #Enable AirDrop over Ethernet and on unsupported Macs running Lion 20 | defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true 21 | 22 | #Disable disk image verification 23 | defaults write com.apple.frameworks.diskimages skip-verify -bool true && 24 | defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true && 25 | defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true 26 | 27 | #Disable Safari’s thumbnail cache for History and Top Sites 28 | defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2 29 | 30 | #Enable Safari’s debug menu 31 | defaults write com.apple.Safari IncludeInternalDebugMenu -bool true 32 | 33 | #Disable the Ping sidebar in iTunes 34 | defaults write com.apple.iTunes disablePingSidebar -bool true 35 | 36 | #Add a context menu item for showing the Web Inspector in web views 37 | defaults write NSGlobalDomain WebKitDeveloperExtras -bool true 38 | 39 | #Show the ~/Library folder 40 | chflags nohidden ~/Library 41 | 42 | #Disable ping dropdowns 43 | defaults write com.apple.iTunes hide-ping-dropdown true 44 | -------------------------------------------------------------------------------- /tmux.conf: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------- 2 | # file: ~/.tmux.conf 3 | # author: jason ryan - http://jasonwryan.com/ 4 | # vim:nu:ai:si:et:ts=4:sw=4:fdm=indent:fdn=1:ft=conf: 5 | #--------------------------------------------------------------- 6 | 7 | #~/.tmux.conf - tmux terminal multiplexer config 8 | # Based heavily on Thayer Wiliams' (http://cinderwick.ca) 9 | 10 | 11 | # set prefix key to ctrl+t 12 | set-option -g default-command "reattach-to-user-namespace -l zsh" 13 | unbind C-b 14 | # set -g prefix C-a 15 | set -g prefix ` 16 | set -g default-terminal "screen-256color" 17 | set -g mode-mouse on 18 | set -g mouse-select-pane on 19 | 20 | # reload config without killing server 21 | bind r source-file ~/.tmux.conf 22 | 23 | # more intuitive keybindings for splitting 24 | unbind % 25 | bind h split-window -v 26 | unbind '"' 27 | bind v split-window -h 28 | 29 | # set vi keys 30 | unbind [ 31 | bind Escape copy-mode 32 | setw -g mode-keys vi 33 | unbind p 34 | bind p paste-buffer 35 | bind-key -t vi-copy 'v' begin-selection 36 | bind-key -t vi-copy 'y' copy-selection 37 | 38 | # Bind prefix-y to copy-selection, save selection to buffer, and then pipe 39 | # it's contents to pbcopy 40 | bind-key y send-keys y\;\ 41 | save-buffer /tmp/tmux-buffer\;\ 42 | run-shell "reattach-to-user-namespace -l bash -c 'cat /tmp/tmux-buffer|pbcopy'" 43 | 44 | # send the prefix to client inside window (ala nested sessions) 45 | # bind-key a send-prefix 46 | bind-key ` send-prefix 47 | 48 | # toggle last window like screen 49 | bind-key C-b last-window 50 | 51 | # confirm before killing a window or the server 52 | bind-key k confirm kill-window 53 | bind-key K confirm kill-server 54 | 55 | # toggle statusbar 56 | bind-key b set-option status 57 | 58 | # ctrl+left/right cycles thru windows 59 | bind-key -n C-right next 60 | bind-key -n C-left prev 61 | 62 | # open a man page in new window 63 | bind m command-prompt "split-window 'exec man %%'" 64 | 65 | # quick view of processes 66 | bind '~' split-window "exec htop" 67 | 68 | # scrollback buffer n lines 69 | set -g history-limit 5000 70 | 71 | # listen for activity on all windows 72 | set -g bell-action any 73 | 74 | # on-screen time for display-panes in ms 75 | set -g display-panes-time 2000 76 | 77 | # start window indexing at one instead of zero 78 | set -g base-index 1 79 | 80 | # enable wm window titles 81 | set -g set-titles on 82 | 83 | # disable auto renaming 84 | # setw -g automatic-rename off 85 | 86 | # border colours 87 | set -g pane-active-border-bg default 88 | 89 | # wm window title string (uses statusbar variables) 90 | set -g set-titles-string "tmux:#I [ #W ]" 91 | 92 | # statusbar -------------------------------------------------------------- 93 | 94 | 95 | #### COLOUR (Solarized dark) 96 | 97 | # default statusbar colors 98 | set-option -g status-bg colour235 #base02 99 | set-option -g status-fg yellow #yellow 100 | set-option -g status-attr default 101 | 102 | # default window title colors 103 | set-window-option -g window-status-fg brightblue #base0 104 | set-window-option -g window-status-bg default 105 | #set-window-option -g window-status-attr dim 106 | 107 | # active window title colors 108 | set-window-option -g window-status-current-fg brightred #orange 109 | set-window-option -g window-status-current-bg default 110 | #set-window-option -g window-status-current-attr bright 111 | 112 | # pane border 113 | set-option -g pane-border-fg black #base02 114 | set-option -g pane-active-border-fg brightgreen #base01 115 | 116 | # message text 117 | set-option -g message-bg colour27 #base02 118 | set-option -g message-fg brightred #orange 119 | 120 | # pane number display 121 | set-option -g display-panes-active-colour blue #blue 122 | set-option -g display-panes-colour brightred #orange 123 | 124 | # clock 125 | set-window-option -g clock-mode-colour green #green 126 | 127 | # status bar 128 | set -g status-utf8 on 129 | set -g status-fg colour8 130 | set -g status-bg colour234 131 | # current session 132 | set -g status-left ' #S ' 133 | set -g status-left-length 15 134 | set -g status-left-fg colour229 135 | set -g status-left-bg colour166 136 | # window list 137 | set -g window-status-format "#[fg=colour8] #I #[fg=colour231]#W#[fg=colour166]#F " 138 | set -g window-status-current-format "#[fg=colour117,bg=colour31] #I #[fg=colour231]#W#[fg=colour234]#F " 139 | set -g window-status-separator "" 140 | 141 | # battery and pomo status 142 | set -g status-right ' #(cat ~/.pomo_stat) #(battery) ' 143 | set -g status-interval 15 144 | 145 | set -s escape-time 50 146 | -------------------------------------------------------------------------------- /emacs.d/custom/06_badwolf.el: -------------------------------------------------------------------------------- 1 | (deftheme badwolf "Badwolf color Theme") 2 | 3 | (let ((class '((class color) (min-colors 89))) 4 | ;;Badwolf pallete 5 | (bwc-plain "#f8f6f2") 6 | (bwc-snow "#ffffff") 7 | (bwc-coal "#000000") 8 | 9 | (bwc-brightgravel "#d9cec3") 10 | (bwc-lightgravel "#998f84") 11 | (bwc-gravel "#857f78") 12 | (bwc-mediumgravel "#666462") 13 | (bwc-deepgravel "#45413b") 14 | (bwc-deepergravel "#35322d") 15 | (bwc-darkgravel "#242321") 16 | (bwc-blackgravel "#1c1b1a") 17 | (bwc-blackestgravel "#141413") 18 | 19 | (bwc-dalespale "#fade3e") 20 | (bwc-dirtyblonde "#f4cf86") 21 | ; (bwc-taffy "#ff2c4b") 22 | (bwc-taffy "#ff0208") 23 | (bwc-saltwatertaffy "#8cffba") 24 | (bwc-tardis "#0a9dff") 25 | (bwc-orange "#ffa724") 26 | (bwc-lime "#aeee00") 27 | (bwc-dress "#ff9eb8") 28 | (bwc-toffee "#b88853") 29 | (bwc-coffee "#c7915b") 30 | (bwc-darkroast "#88633f") 31 | ) 32 | 33 | ;; theme faces 34 | (custom-theme-set-faces 35 | 'badwolf 36 | `(default ((t (:inherit nil :foreground ,bwc-plain :background ,bwc-blackestgravel)))) 37 | `(cursor ((t (:background ,bwc-tardis)))) 38 | `(region ((t (:foreground nil :background ,bwc-mediumgravel )))) 39 | `(fringe ((t (:background ,bwc-blackestgravel)))) 40 | 41 | `(minibuffer-prompt ((t (:foreground ,bwc-lime)))) 42 | `(link ((t (:foreground ,bwc-lightgravel :underline t)))) 43 | `(link-visited ((t (:inherit link :foreground ,bwc-orange)))) 44 | 45 | `(highlight ((t (:foreground ,bwc-coal :background ,bwc-dalespale)))) 46 | `(hl-line ((t (:inherit nil :background ,bwc-darkgravel)))) 47 | 48 | `(linum ((t (:foreground ,bwc-mediumgravel)))) 49 | 50 | `(isearch ((t (:foreground ,bwc-coal :background ,bwc-dalespale :weight bold)))) 51 | `(lazy-highlight ((t (:foreground ,bwc-coal :background, bwc-dalespale :weight bold)))) 52 | 53 | `(mode-line ((t (:box (:line-width -1 :style released-button) :foreground ,bwc-brightgravel :background ,bwc-darkgravel)))) 54 | `(mode-line-inactive ((t (:box (:line-width -1 :style released-button) :foreground ,bwc-snow :background ,bwc-deepgravel)))) 55 | 56 | 57 | `(font-lock-comment-face ((t (:foreground ,bwc-lightgravel)))) 58 | `(font-lock-comment-delimiter-face ((t (:foreground ,bwc-lightgravel)))) 59 | `(font-lock-doc-face ((t (:foreground ,bwc-snow)))) 60 | `(font-lock-string-face ((t (:foreground ,bwc-dirtyblonde)))) 61 | `(font-lock-function-name-face ((t (:foreground ,bwc-orange)))) 62 | `(font-lock-variable-name-face ((t (:foreground ,bwc-dress)))) 63 | `(font-lock-builtin-face ((t (:foreground ,bwc-taffy :weight bold)))) 64 | `(font-lock-keyword-face ((t (:foreground ,bwc-taffy :weight bold)))) 65 | `(font-lock-type-face ((t (:foreground ,bwc-dress)))) 66 | `(font-lock-constant-face ((t (:foreground ,bwc-orange)))) 67 | `(font-lock-warning-face ((t (:foreground ,bwc-dress :weight bold)))) 68 | 69 | `(show-paren-match ((t (:background ,bwc-tardis :weight bold)))) 70 | `(show-paren-mismatch ((t (:background ,bwc-taffy :weight bold)))) 71 | 72 | ;; rainbow-delimiters 73 | `(rainbow-delimiters-depth-1-face ((t (:foreground ,bwc-lightgravel)))) 74 | `(rainbow-delimiters-depth-2-face ((t (:foreground ,bwc-orange)))) 75 | `(rainbow-delimiters-depth-3-face ((t (:foreground ,bwc-saltwatertaffy)))) 76 | `(rainbow-delimiters-depth-4-face ((t (:foreground ,bwc-dress)))) 77 | `(rainbow-delimiters-depth-5-face ((t (:foreground ,bwc-coffee)))) 78 | `(rainbow-delimiters-depth-6-face ((t (:foreground ,bwc-dirtyblonde)))) 79 | `(rainbow-delimiters-depth-7-face ((t (:foreground ,bwc-orange)))) 80 | `(rainbow-delimiters-depth-8-face ((t (:foreground ,bwc-saltwatertaffy))) 81 | `(rainbow-delimiters-depth-9-face ((t (:foreground ,bwc-dress)))) 82 | `(rainbow-delimiters-depth-10-face ((t (:foreground ,bwc-coffee)))) 83 | `(rainbow-delimiters-depth-11-face ((t (:foreground ,bwc-dirtyblonde)))) 84 | `(rainbow-delimiters-unmatched-face ((t (:foreground "red")))) 85 | 86 | 87 | 88 | 89 | )) 90 | 91 | (custom-set-faces 92 | `(ein:cell-input-area ((t (:background ,bwc-blackestgravel :inherit nil)))) 93 | `(ein:cell-input-prompt ((t (:foreground ,bwc-orange :background nil :inherit nil)))) 94 | `(ein:cell-output-prompt ((t (:foreground ,bwc-taffy :background nil :inherit nil)))) 95 | '(mumamo-background-chunk-major ((((class color) (min-colors 88) (background dark)) nil))) 96 | 97 | `(ac-candidate-face ((t (:background ,bwc-lightgravel)))) 98 | `(ac-selection-face ((t (:foreground ,bwc-coal :background ,bwc-orange)))) 99 | 100 | `(flymake-errline ((t (:background nil :underline ,bwc-taffy )))) 101 | `(flymake-warnline ((t (:background nil :underline ,bwc-dress )))) 102 | ) 103 | 104 | 105 | (font-lock-add-keywords 'python-mode `(("\\<\\(import\\||from\\|except\\|finally\\|try\\|from\\|\\)\\>" 1 '(:foreground ,bwc-lime ) t))) 106 | ) 107 | 108 | (provide-theme 'badwolf) 109 | -------------------------------------------------------------------------------- /irbrc: -------------------------------------------------------------------------------- 1 | # IRBRC file by Iain Hecker, http://iain.nl 2 | # put all this in your ~/.irbrc 3 | require 'rubygems' 4 | require 'yaml' 5 | 6 | alias q exit 7 | 8 | class Object 9 | def local_methods 10 | (methods - Object.instance_methods).sort 11 | end 12 | def do(&block) 13 | block.call self 14 | end 15 | end 16 | 17 | ANSI = {} 18 | ANSI[:RESET] = "\e[0m" 19 | ANSI[:BOLD] = "\e[1m" 20 | ANSI[:UNDERLINE] = "\e[4m" 21 | ANSI[:LGRAY] = "\e[0;37m" 22 | ANSI[:GRAY] = "\e[1;30m" 23 | ANSI[:RED] = "\e[31m" 24 | ANSI[:GREEN] = "\e[32m" 25 | ANSI[:YELLOW] = "\e[33m" 26 | ANSI[:BLUE] = "\e[34m" 27 | ANSI[:MAGENTA] = "\e[35m" 28 | ANSI[:CYAN] = "\e[36m" 29 | ANSI[:WHITE] = "\e[37m" 30 | 31 | # Build a simple colorful IRB prompt 32 | # IRB.conf[:PROMPT][:SIMPLE_COLOR] = { 33 | # :PROMPT_I => "#{ANSI[:BLUE]}>>#{ANSI[:RESET]} ", 34 | # :PROMPT_N => "#{ANSI[:BLUE]}>>#{ANSI[:RESET]} ", 35 | # :PROMPT_C => "#{ANSI[:RED]}?>#{ANSI[:RESET]} ", 36 | # :PROMPT_S => "#{ANSI[:YELLOW]}?>#{ANSI[:RESET]} ", 37 | # :RETURN => "#{ANSI[:GREEN]}=>#{ANSI[:RESET]} %s\\n", 38 | # :AUTO_INDENT => true } 39 | # IRB.conf[:PROMPT_MODE] = :SIMPLE_COLOR 40 | 41 | # Loading extensions of the console. This is wrapped 42 | # because some might not be included in your Gemfile 43 | # and errors will be raised 44 | def extend_console(name, care = true, required = true) 45 | if care 46 | require name if required 47 | yield if block_given? 48 | $console_extensions << "#{ANSI[:GREEN]}#{name}#{ANSI[:RESET]}" 49 | else 50 | $console_extensions << "#{ANSI[:GRAY]}#{name}#{ANSI[:RESET]}" 51 | end 52 | rescue LoadError 53 | $console_extensions << "#{ANSI[:RED]}#{name}#{ANSI[:RESET]}" 54 | end 55 | $console_extensions = [] 56 | 57 | # Wirble is a gem that handles coloring the IRB 58 | # output and history 59 | extend_console 'wirble' do 60 | Wirble.init 61 | Wirble.colorize 62 | end 63 | 64 | # Hirb makes tables easy. 65 | extend_console 'hirb' do 66 | Hirb.enable 67 | extend Hirb::Console 68 | end 69 | 70 | # awesome_print is prints prettier than pretty_print 71 | extend_console 'ap' do 72 | alias pp ap 73 | end 74 | 75 | # When you're using Rails 2 console, show queries in the console 76 | extend_console 'rails2', (ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')), false do 77 | require 'logger' 78 | RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) 79 | end 80 | 81 | # When you're using Rails 3 console, show queries in the console 82 | extend_console 'rails3', defined?(ActiveSupport::Notifications), false do 83 | $odd_or_even_queries = false 84 | ActiveSupport::Notifications.subscribe('sql.active_record') do |*args| 85 | $odd_or_even_queries = !$odd_or_even_queries 86 | color = $odd_or_even_queries ? ANSI[:CYAN] : ANSI[:MAGENTA] 87 | event = ActiveSupport::Notifications::Event.new(*args) 88 | time = "%.1fms" % event.duration 89 | name = event.payload[:name] 90 | sql = event.payload[:sql].gsub("\n", " ").squeeze(" ") 91 | puts " #{ANSI[:UNDERLINE]}#{color}#{name} (#{time})#{ANSI[:RESET]} #{sql}" 92 | end 93 | end 94 | 95 | # Add a method pm that shows every method on an object 96 | # Pass a regex to filter these 97 | extend_console 'pm', true, false do 98 | def pm(obj, *options) # Print methods 99 | methods = obj.methods 100 | methods -= Object.methods unless options.include? :more 101 | filter = options.select {|opt| opt.kind_of? Regexp}.first 102 | methods = methods.select {|name| name =~ filter} if filter 103 | 104 | data = methods.sort.collect do |name| 105 | method = obj.method(name) 106 | if method.arity == 0 107 | args = "()" 108 | elsif method.arity > 0 109 | n = method.arity 110 | args = "(#{(1..n).collect {|i| "arg#{i}"}.join(", ")})" 111 | elsif method.arity < 0 112 | n = -method.arity 113 | args = "(#{(1..n).collect {|i| "arg#{i}"}.join(", ")}, ...)" 114 | end 115 | klass = $1 if method.inspect =~ /Method: (.*?)#/ 116 | [name.to_s, args, klass] 117 | end 118 | max_name = data.collect {|item| item[0].size}.max 119 | max_args = data.collect {|item| item[1].size}.max 120 | data.each do |item| 121 | print " #{ANSI[:YELLOW]}#{item[0].to_s.rjust(max_name)}#{ANSI[:RESET]}" 122 | print "#{ANSI[:BLUE]}#{item[1].ljust(max_args)}#{ANSI[:RESET]}" 123 | print " #{ANSI[:GRAY]}#{item[2]}#{ANSI[:RESET]}\n" 124 | end 125 | data.size 126 | end 127 | end 128 | 129 | extend_console 'interactive_editor' do 130 | # no configuration needed 131 | end 132 | 133 | extend_console 'blueprints', (defined?(Rails) && !Rails.env.production? && File.exists?(Rails.root + 'test/blueprints.rb')), false do 134 | require Rails.root + 'test/blueprints' 135 | end 136 | 137 | # Load railsrc file 138 | railsrc_path = File.expand_path('~/.railsrc') 139 | if ( ENV['RAILS_ENV'] || defined? Rails ) && File.exist?( railsrc_path ) 140 | begin 141 | load railsrc_path 142 | rescue Exception 143 | warn "Could not load: #{ railsrc_path } because of #{$!.message}" 144 | end 145 | end 146 | 147 | # Show results of all extension-loading 148 | puts "#{ANSI[:GRAY]}~> Console extensions:#{ANSI[:RESET]} #{$console_extensions.join(' ')}#{ANSI[:RESET]}" 149 | -------------------------------------------------------------------------------- /zsh/func/zgitinit: -------------------------------------------------------------------------------- 1 | ## 2 | ## Load with `autoload -U zgitinit; zgitinit' 3 | ## 4 | 5 | typeset -gA zgit_info 6 | zgit_info=() 7 | 8 | zgit_chpwd_hook() { 9 | zgit_info_update 10 | } 11 | 12 | zgit_preexec_hook() { 13 | if [[ $2 == git\ * ]] || [[ $2 == *\ git\ * ]]; then 14 | zgit_precmd_do_update=1 15 | fi 16 | } 17 | 18 | zgit_precmd_hook() { 19 | if [ $zgit_precmd_do_update ]; then 20 | unset zgit_precmd_do_update 21 | zgit_info_update 22 | fi 23 | } 24 | 25 | zgit_info_update() { 26 | zgit_info=() 27 | 28 | local gitdir="$(git rev-parse --git-dir 2>/dev/null)" 29 | if [ $? -ne 0 ] || [ -z "$gitdir" ]; then 30 | return 31 | fi 32 | 33 | zgit_info[dir]=$gitdir 34 | zgit_info[bare]=$(git rev-parse --is-bare-repository) 35 | zgit_info[inwork]=$(git rev-parse --is-inside-work-tree) 36 | } 37 | 38 | zgit_isgit() { 39 | if [ -z "$zgit_info[dir]" ]; then 40 | return 1 41 | else 42 | return 0 43 | fi 44 | } 45 | 46 | zgit_inworktree() { 47 | zgit_isgit || return 48 | if [ "$zgit_info[inwork]" = "true" ]; then 49 | return 0 50 | else 51 | return 1 52 | fi 53 | } 54 | 55 | zgit_isbare() { 56 | zgit_isgit || return 57 | if [ "$zgit_info[bare]" = "true" ]; then 58 | return 0 59 | else 60 | return 1 61 | fi 62 | } 63 | 64 | zgit_head() { 65 | zgit_isgit || return 1 66 | 67 | if [ -z "$zgit_info[head]" ]; then 68 | local name='' 69 | name=$(git symbolic-ref -q HEAD) 70 | if [ $? -eq 0 ]; then 71 | if [[ $name == refs/(heads|tags)/* ]]; then 72 | name=${name#refs/(heads|tags)/} 73 | fi 74 | else 75 | name=$(git name-rev --name-only --no-undefined --always HEAD) 76 | if [ $? -ne 0 ]; then 77 | return 1 78 | elif [[ $name == remotes/* ]]; then 79 | name=${name#remotes/} 80 | fi 81 | fi 82 | zgit_info[head]=$name 83 | fi 84 | 85 | echo $zgit_info[head] 86 | } 87 | 88 | zgit_branch() { 89 | zgit_isgit || return 1 90 | zgit_isbare && return 1 91 | 92 | if [ -z "$zgit_info[branch]" ]; then 93 | local branch=$(git symbolic-ref HEAD 2>/dev/null) 94 | if [ $? -eq 0 ]; then 95 | branch=${branch##*/} 96 | else 97 | branch=$(git name-rev --name-only --always HEAD) 98 | fi 99 | zgit_info[branch]=$branch 100 | fi 101 | 102 | echo $zgit_info[branch] 103 | return 0 104 | } 105 | 106 | zgit_tracking_remote() { 107 | zgit_isgit || return 1 108 | zgit_isbare && return 1 109 | 110 | local branch 111 | if [ -n "$1" ]; then 112 | branch=$1 113 | elif [ -z "$zgit_info[branch]" ]; then 114 | branch=$(zgit_branch) 115 | [ $? -ne 0 ] && return 1 116 | else 117 | branch=$zgit_info[branch] 118 | fi 119 | 120 | local k="tracking_$branch" 121 | local remote 122 | if [ -z "$zgit_info[$k]" ]; then 123 | remote=$(git config branch.$branch.remote) 124 | zgit_info[$k]=$remote 125 | fi 126 | 127 | echo $zgit_info[$k] 128 | return 0 129 | } 130 | 131 | zgit_tracking_merge() { 132 | zgit_isgit || return 1 133 | zgit_isbare && return 1 134 | 135 | local branch 136 | if [ -z "$zgit_info[branch]" ]; then 137 | branch=$(zgit_branch) 138 | [ $? -ne 0 ] && return 1 139 | else 140 | branch=$zgit_info[branch] 141 | fi 142 | 143 | local remote=$(zgit_tracking_remote $branch) 144 | [ $? -ne 0 ] && return 1 145 | if [ -n "$remote" ]; then # tracking branch 146 | local merge=$(git config branch.$branch.merge) 147 | if [ $remote != "." ]; then 148 | merge=$remote/$(basename $merge) 149 | fi 150 | echo $merge 151 | return 0 152 | else 153 | return 1 154 | fi 155 | } 156 | 157 | zgit_isindexclean() { 158 | zgit_isgit || return 1 159 | if git diff --quiet --cached 2>/dev/null; then 160 | return 0 161 | else 162 | return 1 163 | fi 164 | } 165 | 166 | zgit_isworktreeclean() { 167 | zgit_isgit || return 1 168 | if git diff --quiet 2>/dev/null; then 169 | return 0 170 | else 171 | return 1 172 | fi 173 | } 174 | 175 | zgit_hasuntracked() { 176 | zgit_isgit || return 1 177 | local -a flist 178 | flist=($(git ls-files --others --exclude-standard)) 179 | if [ $#flist -gt 0 ]; then 180 | return 0 181 | else 182 | return 1 183 | fi 184 | } 185 | 186 | zgit_hasunmerged() { 187 | zgit_isgit || return 1 188 | local -a flist 189 | flist=($(git ls-files -u)) 190 | if [ $#flist -gt 0 ]; then 191 | return 0 192 | else 193 | return 1 194 | fi 195 | } 196 | 197 | zgit_svnhead() { 198 | zgit_isgit || return 1 199 | 200 | local commit=$1 201 | if [ -z "$commit" ]; then 202 | commit='HEAD' 203 | fi 204 | 205 | git show --raw $commit | \ 206 | grep git-svn-id | \ 207 | sed -re 's/^\s*git-svn-id: .*@([0-9]+).*$/\1/' 208 | } 209 | 210 | zgit_rebaseinfo() { 211 | zgit_isgit || return 1 212 | if [ -d $zgit_info[dir]/rebase-merge ]; then 213 | dotest=$zgit_info[dir]/rebase-merge 214 | elif [ -d $zgit_info[dir]/.dotest-merge ]; then 215 | dotest=$zgit_info[dir]/.dotest-merge 216 | elif [ -d .dotest ]; then 217 | dotest=.dotest 218 | else 219 | return 1 220 | fi 221 | 222 | zgit_info[dotest]=$dotest 223 | 224 | zgit_info[rb_onto]=$(cat "$dotest/onto") 225 | zgit_info[rb_upstream]=$(cat "$dotest/upstream") 226 | if [ -f "$dotest/orig-head" ]; then 227 | zgit_info[rb_head]=$(cat "$dotest/orig-head") 228 | elif [ -f "$dotest/head" ]; then 229 | zgit_info[rb_head]=$(cat "$dotest/head") 230 | fi 231 | zgit_info[rb_head_name]=$(cat "$dotest/head-name") 232 | 233 | return 0 234 | } 235 | 236 | zgitinit() { 237 | typeset -ga chpwd_functions 238 | typeset -ga preexec_functions 239 | typeset -ga precmd_functions 240 | chpwd_functions+='zgit_chpwd_hook' 241 | preexec_functions+='zgit_preexec_hook' 242 | precmd_functions+='zgit_precmd_hook' 243 | } 244 | 245 | zgitinit 246 | zgit_info_update 247 | 248 | # vim:set ft=zsh: 249 | -------------------------------------------------------------------------------- /screenrc: -------------------------------------------------------------------------------- 1 | # For a complete list of available commands, see http://bit.ly/jLtj 2 | 3 | # Set the leader key to ` 4 | escape `` 5 | 6 | # Message to display in the status line when activity is detected in a 7 | # monitored window. 8 | activity "activity in %n (%t) [%w:%s]~" 9 | 10 | # Detach session on hangup instead of terminating screen completely. 11 | autodetach on # default: on 12 | 13 | # don't display the copyright page 14 | startup_message off 15 | 16 | # When a bell character is sent to a background window, screen displays a 17 | # notification in the message line. The notification message can be re-defined 18 | # by this command. 19 | bell_msg "bell in %n (%t) [%w:%s]~" 20 | 21 | # This command controls the display of the window captions. Normally a caption 22 | # is only used if more than one window is shown on the display. 23 | #caption always "%{= kw}%?%-Lw%?%{+b kw}%n*%t%f %?(%u)%?%{= kw}%?%+Lw%?" 24 | 25 | # Select line break behavior for copying. 26 | crlf off # default: off 27 | 28 | # Select default utmp logging behavior. 29 | #deflogin off # default: on 30 | 31 | # Set default lines of scrollback. 32 | defscrollback 3000 # default: 100 33 | 34 | # If set to 'on', screen will append to the 'hardcopy.n' files created by the 35 | # command hardcopy; otherwise, these files are overwritten each time. 36 | hardcopy_append on # default: off 37 | 38 | # This command configures the use and emulation of the terminal's hardstatus 39 | # line. The type 'lastline' will reserve the last line of the display for the 40 | # hardstatus. Prepending the word 'always' will force screen to use the type 41 | # even if the terminal supports a hardstatus line. 42 | altscreen on 43 | term screen-256color 44 | bind ',' prev 45 | bind '.' next 46 | 47 | #change the hardstatus settings to give an window list at the bottom of the 48 | #screen, with the time and date and with the current window highlighted 49 | hardstatus alwayslastline 50 | #hardstatus string '%{= kG}%-Lw%{= kW}%50> %n%f* %t%{= kG}%+Lw%< %{= kG}%-=%c:%s%{-}' 51 | hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]' 52 | #hardstatus alwayslastline '%{= kG}[ %{y}%H %{g}][%15= %>%-Lw%40>%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{g}%+Lw%-22< ][%{c} %Y-%m-%d %c %{g}]' 53 | # 54 | #hardstatus alwayslastline "%{+b kr}[ %H ] %{ky} Load: %l %-=%{kb} %c %Y.%m.%d" 55 | msgwait 15 56 | 57 | # Set message displayed on pow_detach (when HUP is sent to screen's parent 58 | # process). 59 | pow_detach_msg "BYE" 60 | 61 | # Set the default program for new windows. 62 | shell zsh 63 | 64 | # Default timeout to trigger an inactivity notify. 65 | silencewait 20 # default: 30 66 | 67 | # Change text highlighting. See http://bit.ly/11RDGZ 68 | sorendition gK 69 | 70 | # Do NOT display copyright notice on startup. 71 | startup_message off # default: on 72 | 73 | # Set $TERM for new windows. I have more luck with 'linux' than Terminal's 74 | # default 'xterm-color' (^H problems). Comment out to use the default. 75 | #term linux 76 | 77 | # Tweak termcap, terminfo, and termcapinfo entries for best performance. 78 | # termcap linux 'AF=\\E[3%dm:AB=\\E[4%dm' 79 | # termcap xterm-color 'AF=\\E[3%dm:AB=\\E[4%dm' 80 | # terminfo linux 'AF=\\E[3%p1%dm:AB=\\E[4%p1%dm' 81 | # terminfo xterm-color 'AF=\\E[3%p1%dm:AB=\\E[4%p1%dm' 82 | 83 | # Allow xterm / Terminal scrollbars to access the scrollback buffer. This 84 | # enables the behavior you'd expect, instead of losing the content that scrolls 85 | # out of the window. 86 | termcapinfo linux ti@:te@ 87 | termcapinfo xterm-color ti@:te@ 88 | termcapinfo xterm-256color ti@:te@ 89 | 90 | ################ 91 | # 92 | # xterm tweaks 93 | # 94 | 95 | #xterm understands both im/ic and doesn't have a status line. 96 | #Note: Do not specify im and ic in the real termcap/info file as 97 | #some programs (e.g. vi) will not work anymore. 98 | termcap xterm hs@:cs=\E[%i%d;%dr:im=\E[4h:ei=\E[4l 99 | terminfo xterm hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l 100 | 101 | #80/132 column switching must be enabled for ^AW to work 102 | #change init sequence to not switch width 103 | termcapinfo xterm Z0=\E[?3h:Z1=\E[?3l:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l 104 | 105 | # Make the output buffer large for (fast) xterms. 106 | #termcapinfo xterm* OL=10000 107 | termcapinfo xterm* OL=100 108 | 109 | # tell screen that xterm can switch to dark background and has function 110 | # keys. 111 | termcapinfo xterm 'VR=\E[?5h:VN=\E[?5l' 112 | termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~' 113 | termcapinfo xterm 'kh=\EOH:kI=\E[2~:kD=\E[3~:kH=\EOF:kP=\E[5~:kN=\E[6~' 114 | 115 | # special xterm hardstatus: use the window title. 116 | termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007' 117 | 118 | #terminfo xterm 'vb=\E[?5h$<200/>\E[?5l' 119 | termcapinfo xterm 'vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l' 120 | 121 | # emulate part of the 'K' charset 122 | termcapinfo xterm 'XC=K%,%\E(B,[\304,\\\\\326,]\334,{\344,|\366,}\374,~\337' 123 | 124 | # xterm-52 tweaks: 125 | # - uses background color for delete operations 126 | termcapinfo xterm* be 127 | 128 | 129 | 130 | # Use visual bell instead of audio bell. 131 | vbell on # default: ??? 132 | 133 | # Message to be displayed when the visual bell is triggered. 134 | vbell_msg " *beep* " 135 | 136 | #terminfo and termcap for nice 256 color terminal 137 | ## allow bold colors - necessary for some reason 138 | attrcolor b ".I" 139 | ## tell screen how to set colors. AB = background, AF=foreground 140 | termcapinfo xterm "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm" 141 | termcapinfo xterm-color "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm" 142 | termcapinfo xterm-256color "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm" 143 | ## erase background with current bg color 144 | defbce "on"]]"]]" 145 | 146 | 147 | ################ 148 | # 149 | # keybindings 150 | # 151 | 152 | #remove some stupid / dangerous key bindings 153 | bind k 154 | bind ^k 155 | bind ^\ 156 | bind \\ 157 | bind ^h 158 | bind h 159 | #make them better 160 | bind 'K' kill 161 | bind 'I' login on 162 | bind 'O' login off 163 | bind '}' history 164 | 165 | # Yet another hack: 166 | # Prepend/append register [/] to the paste if ^a^] is pressed. 167 | # This lets me have autoindent mode in vi. 168 | register [ "\033:se noai\015a" 169 | register ] "\033:se ai\015a" 170 | bind ^] paste [.] 171 | 172 | ################ 173 | # 174 | # default windows 175 | # 176 | 177 | # screen -t local 0 178 | # screen -t mail 1 mutt 179 | # screen -t 40 2 rlogin server 180 | 181 | # caption always "%3n %t%? @%u%?%? [%h]%?%=%c" 182 | # hardstatus alwaysignore 183 | # hardstatus alwayslastline "%Lw" 184 | 185 | # bind = resize = 186 | # bind + resize +1 187 | # bind - resize -1 188 | # bind _ resize max 189 | # 190 | # defnonblock 1 191 | # blankerprg rain -d 100 192 | # idle 30 blanker 193 | -------------------------------------------------------------------------------- /zsh/func/prompt_wunjo_setup: -------------------------------------------------------------------------------- 1 | # wunjo prompt theme 2 | 3 | autoload -U zgitinit 4 | zgitinit 5 | 6 | prompt_wunjo_help () { 7 | cat <<'EOF' 8 | 9 | prompt wunjo 10 | 11 | EOF 12 | } 13 | 14 | revstring() { 15 | git describe --always $1 2>/dev/null || 16 | git rev-parse --short $1 2>/dev/null 17 | } 18 | 19 | coloratom() { 20 | local off=$1 atom=$2 21 | if [[ $atom[1] == [[:upper:]] ]]; then 22 | off=$(( $off + 60 )) 23 | fi 24 | echo $(( $off + $colorcode[${(L)atom}] )) 25 | } 26 | colorword() { 27 | local fg=$1 bg=$2 att=$3 28 | local -a s 29 | 30 | if [ -n "$fg" ]; then 31 | s+=$(coloratom 30 $fg) 32 | fi 33 | if [ -n "$bg" ]; then 34 | s+=$(coloratom 40 $bg) 35 | fi 36 | if [ -n "$att" ]; then 37 | s+=$attcode[$att] 38 | fi 39 | 40 | echo "%{"$'\e['${(j:;:)s}m"%}" 41 | } 42 | 43 | prompt_wunjo_setup() { 44 | local verbose 45 | if [[ $TERM == screen* ]] && [ -n "$STY" ]; then 46 | verbose= 47 | else 48 | verbose=1 49 | fi 50 | 51 | typeset -A colorcode 52 | colorcode[black]=0 53 | colorcode[red]=1 54 | colorcode[green]=2 55 | colorcode[yellow]=3 56 | colorcode[blue]=4 57 | colorcode[magenta]=5 58 | colorcode[cyan]=6 59 | colorcode[white]=7 60 | colorcode[default]=9 61 | colorcode[k]=$colorcode[black] 62 | colorcode[r]=$colorcode[red] 63 | colorcode[g]=$colorcode[green] 64 | colorcode[y]=$colorcode[yellow] 65 | colorcode[b]=$colorcode[blue] 66 | colorcode[m]=$colorcode[magenta] 67 | colorcode[c]=$colorcode[cyan] 68 | colorcode[w]=$colorcode[white] 69 | colorcode[.]=$colorcode[default] 70 | 71 | typeset -A attcode 72 | attcode[none]=00 73 | attcode[bold]=01 74 | attcode[faint]=02 75 | attcode[standout]=03 76 | attcode[underline]=04 77 | attcode[blink]=05 78 | attcode[reverse]=07 79 | attcode[conceal]=08 80 | attcode[normal]=22 81 | attcode[no-standout]=23 82 | attcode[no-underline]=24 83 | attcode[no-blink]=25 84 | attcode[no-reverse]=27 85 | attcode[no-conceal]=28 86 | 87 | local -A pc 88 | pc[default]='default' 89 | pc[date]='cyan' 90 | pc[time]='Blue' 91 | pc[host]='Green' 92 | pc[user]='cyan' 93 | pc[punc]='yellow' 94 | pc[line]='magenta' 95 | pc[hist]='green' 96 | pc[path]='Cyan' 97 | pc[shortpath]='default' 98 | pc[rc]='red' 99 | pc[scm_branch]='Cyan' 100 | pc[scm_commitid]='Yellow' 101 | pc[scm_status_dirty]='Red' 102 | pc[scm_status_staged]='Green' 103 | pc[#]='Yellow' 104 | for cn in ${(k)pc}; do 105 | pc[${cn}]=$(colorword $pc[$cn]) 106 | done 107 | pc[reset]=$(colorword . . 00) 108 | 109 | typeset -Ag wunjo_prompt_colors 110 | wunjo_prompt_colors=(${(kv)pc}) 111 | 112 | local p_date p_line p_rc 113 | 114 | p_date="$pc[date]%D{%Y-%m-%d} $pc[time]%D{%T}$pc[reset]" 115 | 116 | p_line="$pc[line]%y$pc[reset]" 117 | 118 | PROMPT= 119 | if [ $verbose ]; then 120 | PROMPT+="$pc[host]%m$pc[reset] " 121 | fi 122 | PROMPT+="$pc[path]%(2~.%~.%/)$pc[reset]" 123 | PROMPT+="\$(prompt_wunjo_scm_status)" 124 | PROMPT+="%(?.. $pc[rc]exited %1v$pc[reset])" 125 | PROMPT+=" 126 | " 127 | PROMPT+="$pc[hist]%h$pc[reset] " 128 | PROMPT+="$pc[shortpath]%1~$pc[reset]" 129 | PROMPT+="\$(prompt_wunjo_scm_branch)" 130 | PROMPT+=" $pc[#]%#$pc[reset] " 131 | 132 | RPROMPT= 133 | if [ $verbose ]; then 134 | RPROMPT+="$p_date " 135 | fi 136 | RPROMPT+="$pc[user]%n$pc[reset]" 137 | RPROMPT+=" $p_line" 138 | 139 | export PROMPT RPROMPT 140 | precmd_functions+='prompt_wunjo_precmd' 141 | } 142 | 143 | prompt_wunjo_precmd() { 144 | local ex=$? 145 | psvar=() 146 | 147 | if [[ $ex -ge 128 ]]; then 148 | sig=$signals[$ex-127] 149 | psvar[1]="sig${(L)sig}" 150 | else 151 | psvar[1]="$ex" 152 | fi 153 | } 154 | 155 | prompt_wunjo_scm_status() { 156 | zgit_isgit || return 157 | local -A pc 158 | pc=(${(kv)wunjo_prompt_colors}) 159 | 160 | head=$(zgit_head) 161 | gitcommit=$(revstring $head) 162 | 163 | local -a commits 164 | 165 | if zgit_rebaseinfo; then 166 | orig_commit=$(revstring $zgit_info[rb_head]) 167 | orig_name=$(git name-rev --name-only $zgit_info[rb_head]) 168 | orig="$pc[scm_branch]$orig_name$pc[punc]($pc[scm_commitid]$orig_commit$pc[punc])" 169 | onto_commit=$(revstring $zgit_info[rb_onto]) 170 | onto_name=$(git name-rev --name-only $zgit_info[rb_onto]) 171 | onto="$pc[scm_branch]$onto_name$pc[punc]($pc[scm_commitid]$onto_commit$pc[punc])" 172 | 173 | if [ -n "$zgit_info[rb_upstream]" ] && [ $zgit_info[rb_upstream] != $zgit_info[rb_onto] ]; then 174 | upstream_commit=$(revstring $zgit_info[rb_upstream]) 175 | upstream_name=$(git name-rev --name-only $zgit_info[rb_upstream]) 176 | upstream="$pc[scm_branch]$upstream_name$pc[punc]($pc[scm_commitid]$upstream_commit$pc[punc])" 177 | commits+="rebasing $upstream$pc[reset]..$orig$pc[reset] onto $onto$pc[reset]" 178 | else 179 | commits+="rebasing $onto$pc[reset]..$orig$pc[reset]" 180 | fi 181 | 182 | local -a revs 183 | revs=($(git rev-list $zgit_info[rb_onto]..HEAD)) 184 | if [ $#revs -gt 0 ]; then 185 | commits+="\n$#revs commits in" 186 | fi 187 | 188 | if [ -f $zgit_info[dotest]/message ]; then 189 | mess=$(head -n1 $zgit_info[dotest]/message) 190 | commits+="on $mess" 191 | fi 192 | elif [ -n "$gitcommit" ]; then 193 | commits+="on $pc[scm_branch]$head$pc[punc]($pc[scm_commitid]$gitcommit$pc[punc])$pc[reset]" 194 | local track_merge=$(zgit_tracking_merge) 195 | if [ -n "$track_merge" ]; then 196 | if git rev-parse --verify -q $track_merge >/dev/null; then 197 | local track_remote=$(zgit_tracking_remote) 198 | local tracked=$(revstring $track_merge 2>/dev/null) 199 | 200 | local -a revs 201 | revs=($(git rev-list --reverse $track_merge..HEAD)) 202 | if [ $#revs -gt 0 ]; then 203 | local base=$(revstring $revs[1]~1) 204 | local base_name=$(git name-rev --name-only $base) 205 | local base_short=$(revstring $base) 206 | local word_commits 207 | if [ $#revs -gt 1 ]; then 208 | word_commits='commits' 209 | else 210 | word_commits='commit' 211 | fi 212 | 213 | local conj="since" 214 | if [[ "$base" == "$tracked" ]]; then 215 | conj+=" tracked" 216 | tracked= 217 | fi 218 | commits+="$#revs $word_commits $conj $pc[scm_branch]$base_name$pc[punc]($pc[scm_commitid]$base_short$pc[punc])$pc[reset]" 219 | fi 220 | 221 | if [ -n "$tracked" ]; then 222 | local track_name=$track_merge 223 | if [[ $track_remote == "." ]]; then 224 | track_name=${track_name##*/} 225 | fi 226 | tracked=$(revstring $tracked) 227 | commits+="tracking $pc[scm_branch]$track_name$pc[punc]" 228 | if [[ "$tracked" != "$gitcommit" ]]; then 229 | commits[$#commits]+="($pc[scm_commitid]$tracked$pc[punc])" 230 | fi 231 | commits[$#commits]+="$pc[reset]" 232 | fi 233 | fi 234 | fi 235 | fi 236 | 237 | gitsvn=$(git rev-parse --verify -q --short git-svn) 238 | if [ $? -eq 0 ]; then 239 | gitsvnrev=$(zgit_svnhead $gitsvn) 240 | gitsvn=$(revstring $gitsvn) 241 | if [ -n "$gitsvnrev" ]; then 242 | local svninfo='' 243 | local -a revs 244 | svninfo+="$pc[default]svn$pc[punc]:$pc[scm_branch]r$gitsvnrev" 245 | revs=($(git rev-list git-svn..HEAD)) 246 | if [ $#revs -gt 0 ]; then 247 | svninfo+="$pc[punc]@$pc[default]HEAD~$#revs" 248 | svninfo+="$pc[punc]($pc[scm_commitid]$gitsvn$pc[punc])" 249 | fi 250 | commits+=$svninfo 251 | fi 252 | fi 253 | 254 | if [ $#commits -gt 0 ]; then 255 | echo -n " ${(j: :)commits}" 256 | fi 257 | } 258 | 259 | prompt_wunjo_scm_branch() { 260 | zgit_isgit || return 261 | local -A pc 262 | pc=(${(kv)wunjo_prompt_colors}) 263 | 264 | echo -n "$pc[punc]:$pc[scm_branch]$(zgit_head)" 265 | 266 | if zgit_inworktree; then 267 | if ! zgit_isindexclean; then 268 | echo -n "$pc[scm_status_staged]+" 269 | fi 270 | 271 | local -a dirty 272 | if ! zgit_isworktreeclean; then 273 | dirty+='!' 274 | fi 275 | 276 | if zgit_hasunmerged; then 277 | dirty+='*' 278 | fi 279 | 280 | if zgit_hasuntracked; then 281 | dirty+='?' 282 | fi 283 | 284 | if [ $#dirty -gt 0 ]; then 285 | echo -n "$pc[scm_status_dirty]${(j::)dirty}" 286 | fi 287 | fi 288 | 289 | echo $pc[reset] 290 | } 291 | 292 | prompt_wunjo_setup "$@" 293 | 294 | # vim:set ft=zsh: 295 | -------------------------------------------------------------------------------- /railsrc: -------------------------------------------------------------------------------- 1 | # .railsrc for Rails 3, encoding: utf-8 2 | # see http://rbjl.net/49-railsrc-rails-console-snippets 3 | 4 | if !Rails.application then warn "Rails isn't loaded, yet... skipping .railsrc" else 5 | # # # 6 | 7 | def ripl?; defined?(Ripl) && Ripl.instance_variable_get(:@shell); end 8 | 9 | # # # 10 | # loggers 11 | ActiveRecord::Base.logger = Logger.new STDOUT 12 | ActiveRecord::Base.clear_reloadable_connections! 13 | 14 | ActionController::Base.logger = Logger.new STDOUT 15 | 16 | # # # 17 | # named routes and helpers 18 | include Rails.application.routes.url_helpers 19 | default_url_options[:host] = Rails.application.class.parent_name.downcase 20 | 21 | #include ActionView::Helpers # All Rails helpers 22 | include ApplicationController._helpers # Your own helpers 23 | # 24 | # unfortunately that breaks some functionality (e.g. the named route helpers above) 25 | # so, look at actionpack/lib/action_view/helpers.rb and choose the helpers you need 26 | # (and which don't break anything), e.g. 27 | include ActionView::Helpers::DebugHelper 28 | include ActionView::Helpers::NumberHelper 29 | include ActionView::Helpers::SanitizeHelper 30 | include ActionView::Helpers::TagHelper 31 | include ActionView::Helpers::TextHelper 32 | include ActionView::Helpers::TranslationHelper 33 | 34 | if defined?(Hirb) 35 | # # # 36 | # route list view helpers (requires hirb) 37 | 38 | # hirb view for a route 39 | class Hirb::Helpers::Route < Hirb::Helpers::AutoTable 40 | def self.render(output, options = {}) 41 | super( output.requirements.map{ |k,v| 42 | [k, v.inspect] 43 | }, options.merge({ 44 | :headers => [output.name || '', "#{ output.verb || 'ANY' } #{ output.path }"], 45 | :unicode => true, 46 | :description => nil, 47 | }) ) 48 | end 49 | end 50 | Hirb.add_view ActionDispatch::Routing::Route, :class => Hirb::Helpers::Route 51 | 52 | # short and long route list 53 | def routes(long_output = false) 54 | if long_output 55 | Rails.application.routes.routes.each{ |e| 56 | puts Hirb::Helpers::Route.render(e) 57 | } 58 | true 59 | else 60 | Hirb::Console.render_output Rails.application.routes.routes.map{|e| 61 | [e.name || '', e.verb || 'ANY', e.path] 62 | },{ 63 | :class => Hirb::Helpers::AutoTable, 64 | :headers => %w, 65 | } 66 | end 67 | end 68 | 69 | # # # 70 | # misc db helpers (requires hirb) 71 | module DatabaseHelpers 72 | extend self 73 | 74 | def tables 75 | Hirb::Console.render_output ActiveRecord::Base.connection.tables.map{|e|[e]},{ 76 | :class => Hirb::Helpers::AutoTable, 77 | :headers => %w, 78 | } 79 | true 80 | end 81 | 82 | def table(which) 83 | Hirb::Console.render_output ActiveRecord::Base.connection.columns(which).map{ |e| 84 | [e.name, e.type, e.sql_type, e.limit, e.default, e.scale, e.precision, e.primary, e.null] 85 | },{ 86 | :class => Hirb::Helpers::AutoTable, 87 | :headers => %w, 88 | } 89 | true 90 | end 91 | 92 | def counts 93 | Hirb::Console.render_output ActiveRecord::Base.connection.tables.map{|e| 94 | [e, ActiveRecord::Base.connection.select_value("SELECT COUNT(*) FROM #{e}")] 95 | },{ 96 | :class => Hirb::Helpers::AutoTable, 97 | :headers => %w, 98 | } 99 | true 100 | end 101 | 102 | # ... 103 | end 104 | def db; DatabaseHelpers; end 105 | 106 | # # # 107 | # temp patches 108 | 109 | # hirb vs irb vs ripl 110 | # =begin 111 | # class << Hirb::View 112 | # def enable_output_method 113 | # if defined?(Ripl) && Ripl.instance_variable_get(:@shell) 114 | # @output_method = true 115 | # require 'ripl/hirb' 116 | # elsif defined? IRB 117 | # @output_method = true 118 | # ::IRB::Irb.class_eval do 119 | # alias_method :non_hirb_view_output, :output_value 120 | # def output_value #:nodoc: 121 | # Hirb::View.view_or_page_output(@context.last_value) || non_hirb_view_output 122 | # end 123 | # end 124 | # end 125 | # end 126 | # end 127 | # #Hirb::View.disable 128 | # #Hirb::View.enable 129 | # =end 130 | 131 | end 132 | 133 | # get a specific route via index or name 134 | def route(index_or_name) 135 | route = case index_or_name 136 | when Integer 137 | Rails.application.routes.routes[ index_or_name ] 138 | when Symbol # named route 139 | Rails.application.routes.named_routes.get index_or_name 140 | end 141 | end 142 | 143 | # access to routeset for easy recognize / generate 144 | def r 145 | Rails.application.reload_routes! 146 | all_routes = Rails.application.routes.routes 147 | 148 | require 'rails/application/route_inspector' 149 | inspector = Rails::Application::RouteInspector.new 150 | puts inspector.format(all_routes, ENV['CONTROLLER']).join "\n" 151 | end 152 | 153 | # # # 154 | # rails prompt 155 | if ripl? 156 | module Ripl::RailsPrompt 157 | def prompt 158 | @prompt = "#{ Rails.application.class.parent_name.downcase }(#{ Rails.env[0...3] })> " 159 | super 160 | end 161 | end 162 | Ripl::Shell.include Ripl::RailsPrompt 163 | else 164 | app_name = Rails.application.class.parent_name.downcase 165 | app_env = Rails.env[0...3] 166 | IRB.conf[:PROMPT] ||= {} 167 | IRB.conf[:PROMPT][:RAILS] = { 168 | :PROMPT_I => "#{ app_name }(#{ app_env })> ", 169 | :PROMPT_N => "#{ app_name }(#{ app_env })| ", 170 | :PROMPT_C => "#{ app_name }(#{ app_env })| ", 171 | :PROMPT_S => "#{ app_name }(#{ app_env })%l ", 172 | :RETURN => "=> %s\n", 173 | :AUTO_INDENT => true, 174 | } 175 | IRB.conf[:PROMPT_MODE] = :RAILS 176 | end 177 | 178 | # # # 179 | # per project histories 180 | history_file = File.join Dir.pwd, '.console_history' 181 | if ripl? 182 | Ripl.config[:history] = history_file 183 | else 184 | if !IRB.conf[:PROMPT][:RVM] 185 | IRB.conf[:HISTORY_FILE] = history_file 186 | else # RVM workaround, code from ~/.rvm/scripts/irbrc.rb 187 | # NOTE: messes up your ~/.irb-history 188 | # consider editing the rvm script directly 189 | if File.exists?(history_file) 190 | lines = IO.readlines(history_file).collect { |line| line.chomp } 191 | Readline::HISTORY.clear 192 | Readline::HISTORY.push(*lines) 193 | end 194 | 195 | Kernel::at_exit do 196 | maxhistsize = IRB.conf[:SAVE_HISTORY] || 100 197 | history_file = File.join Dir.pwd, ".console_history" 198 | lines = Readline::HISTORY.to_a.reverse.uniq.reverse 199 | lines = lines[-maxhistsize, maxhistsize] if lines.compact.length > maxhistsize 200 | File::open(history_file, "w+") { |io| io.puts lines.join("\n") } 201 | end 202 | end 203 | end 204 | 205 | # # # 206 | # plain sql 207 | def sql(query) 208 | ActiveRecord::Base.connection.select_all(query) 209 | end 210 | 211 | # # # 212 | # instead of User.find(...) you can do user(...) 213 | # without arguments it only returns the model class 214 | # based on http://www.clarkware.com/blog/2007/09/03/console-shortcut 215 | Dir.glob( File.join(Dir.pwd, *%w) ).map { |file_name| 216 | table_name = File.basename(file_name).split('.')[0..-2].join 217 | Object.instance_eval do 218 | define_method(table_name) do |*args| 219 | table_class = table_name.camelize.constantize 220 | if args.empty? 221 | table_class 222 | else 223 | table_class.send(:find, *args) 224 | end 225 | end 226 | end 227 | } 228 | 229 | # # # 230 | # edit records with vim, emacs... 231 | # class Url 232 | # can_console_update 233 | # end 234 | # Url.first.console_update 235 | # see https://github.com/cldwalker/console_update 236 | # require 'console_update' 237 | # ConsoleUpdate.editor = 'vim' # not necessary if env var $EDITOR is set 238 | 239 | # # # 240 | # gems & plugin initializers 241 | 242 | # initiate authlogic session 243 | if defined? Authlogic 244 | Authlogic::Session::Base.controller = 245 | Authlogic::ControllerAdapters::RailsAdapter.new(self) 246 | end 247 | 248 | # ... 249 | 250 | 251 | # # # 252 | end # if Rails.application 253 | # # # 254 | # 255 | # J-_-L 256 | -------------------------------------------------------------------------------- /zsh/func/prompt_grb_setup: -------------------------------------------------------------------------------- 1 | # grb prompt theme 2 | # copied from wunjo prompt theme and modified 3 | 4 | autoload -U zgitinit 5 | zgitinit 6 | 7 | prompt_grb_help () { 8 | cat <<'EOF' 9 | 10 | prompt grb 11 | 12 | EOF 13 | } 14 | 15 | revstring() { 16 | git describe --always $1 2>/dev/null || 17 | git rev-parse --short $1 2>/dev/null 18 | } 19 | 20 | coloratom() { 21 | local off=$1 atom=$2 22 | if [[ $atom[1] == [[:upper:]] ]]; then 23 | off=$(( $off + 60 )) 24 | fi 25 | echo $(( $off + $colorcode[${(L)atom}] )) 26 | } 27 | colorword() { 28 | local fg=$1 bg=$2 att=$3 29 | local -a s 30 | 31 | if [ -n "$fg" ]; then 32 | s+=$(coloratom 30 $fg) 33 | fi 34 | if [ -n "$bg" ]; then 35 | s+=$(coloratom 40 $bg) 36 | fi 37 | if [ -n "$att" ]; then 38 | s+=$attcode[$att] 39 | fi 40 | 41 | echo "%{"$'\e['${(j:;:)s}m"%}" 42 | } 43 | 44 | function minutes_since_last_commit { 45 | now=`date +%s` 46 | last_commit=`git log --pretty=format:'%at' -1 2>/dev/null` 47 | if $lastcommit ; then 48 | seconds_since_last_commit=$((now-last_commit)) 49 | minutes_since_last_commit=$((seconds_since_last_commit/60)) 50 | echo $minutes_since_last_commit 51 | else 52 | echo "-1" 53 | fi 54 | } 55 | 56 | function prompt_grb_scm_time_since_commit() { 57 | local -A pc 58 | pc=(${(kv)wunjo_prompt_colors}) 59 | 60 | if zgit_inworktree; then 61 | local MINUTES_SINCE_LAST_COMMIT=`minutes_since_last_commit` 62 | if [ "$MINUTES_SINCE_LAST_COMMIT" -eq -1 ]; then 63 | COLOR="$pc[scm_time_uncommitted]" 64 | local SINCE_LAST_COMMIT="${COLOR}uncommitted$pc[reset]" 65 | else 66 | if [ "$MINUTES_SINCE_LAST_COMMIT" -gt 30 ]; then 67 | COLOR="$pc[scm_time_long]" 68 | elif [ "$MINUTES_SINCE_LAST_COMMIT" -gt 10 ]; then 69 | COLOR="$pc[scm_time_medium]" 70 | else 71 | COLOR="$pc[scm_time_short]" 72 | fi 73 | local SINCE_LAST_COMMIT="${COLOR}$(minutes_since_last_commit)m$pc[reset]" 74 | fi 75 | echo $SINCE_LAST_COMMIT 76 | fi 77 | } 78 | 79 | function prompt_grb_scm_info() { 80 | if zgit_inworktree; then 81 | echo "($(prompt_grb_scm_time_since_commit)|$(prompt_wunjo_scm_branch))" 82 | fi 83 | } 84 | 85 | prompt_grb_setup() { 86 | local verbose 87 | if [[ $TERM == screen* ]] && [ -n "$STY" ]; then 88 | verbose= 89 | else 90 | verbose=1 91 | fi 92 | 93 | typeset -A colorcode 94 | colorcode[black]=0 95 | colorcode[red]=1 96 | colorcode[green]=2 97 | colorcode[yellow]=3 98 | colorcode[blue]=4 99 | colorcode[magenta]=5 100 | colorcode[cyan]=6 101 | colorcode[white]=7 102 | colorcode[default]=9 103 | colorcode[k]=$colorcode[black] 104 | colorcode[r]=$colorcode[red] 105 | colorcode[g]=$colorcode[green] 106 | colorcode[y]=$colorcode[yellow] 107 | colorcode[b]=$colorcode[blue] 108 | colorcode[m]=$colorcode[magenta] 109 | colorcode[c]=$colorcode[cyan] 110 | colorcode[w]=$colorcode[white] 111 | colorcode[.]=$colorcode[default] 112 | 113 | typeset -A attcode 114 | attcode[none]=00 115 | attcode[bold]=01 116 | attcode[faint]=02 117 | attcode[standout]=03 118 | attcode[underline]=04 119 | attcode[blink]=05 120 | attcode[reverse]=07 121 | attcode[conceal]=08 122 | attcode[normal]=22 123 | attcode[no-standout]=23 124 | attcode[no-underline]=24 125 | attcode[no-blink]=25 126 | attcode[no-reverse]=27 127 | attcode[no-conceal]=28 128 | 129 | local -A pc 130 | pc[default]='default' 131 | pc[date]='cyan' 132 | pc[time]='Blue' 133 | pc[host]='Green' 134 | pc[user]='cyan' 135 | pc[punc]='yellow' 136 | pc[line]='magenta' 137 | pc[hist]='green' 138 | pc[path]='Cyan' 139 | pc[shortpath]='default' 140 | pc[rc]='red' 141 | pc[scm_branch]='Cyan' 142 | pc[scm_commitid]='Yellow' 143 | pc[scm_status_dirty]='Red' 144 | pc[scm_status_staged]='Green' 145 | pc[scm_time_short]='green' 146 | pc[scm_time_medium]='yellow' 147 | pc[scm_time_long]='red' 148 | pc[scm_time_uncommitted]='Magenta' 149 | pc[#]='Yellow' 150 | for cn in ${(k)pc}; do 151 | pc[${cn}]=$(colorword $pc[$cn]) 152 | done 153 | pc[reset]=$(colorword . . 00) 154 | 155 | typeset -Ag wunjo_prompt_colors 156 | wunjo_prompt_colors=(${(kv)pc}) 157 | 158 | local p_date p_line p_rc 159 | 160 | p_date="$pc[date]%D{%Y-%m-%d} $pc[time]%D{%T}$pc[reset]" 161 | 162 | p_line="$pc[line]%y$pc[reset]" 163 | 164 | PROMPT= 165 | if [ $verbose ]; then 166 | PROMPT+="$pc[host]%m$pc[reset]" 167 | fi 168 | #PROMPT+="$pc[path]%(2~.%~.%/)$pc[reset]" 169 | #PROMPT+="\$(prompt_wunjo_scm_status)" 170 | #PROMPT+="%(?.. $pc[rc]exited %1v$pc[reset])" 171 | # PROMPT+=" 172 | #" 173 | #PROMPT+="($pc[hist]%h$pc[reset])" 174 | PROMPT+=":$pc[shortpath]%1~$pc[reset]" 175 | PROMPT+="\$(prompt_grb_scm_info)" 176 | PROMPT+=" $pc[#]\$$pc[reset] " 177 | 178 | #RPROMPT= 179 | #if [ $verbose ]; then 180 | # RPROMPT+="$p_date " 181 | #fi 182 | #RPROMPT+="$pc[user]%n$pc[reset]" 183 | #RPROMPT+=" $p_line" 184 | 185 | export PROMPT RPROMPT 186 | precmd_functions+='prompt_wunjo_precmd' 187 | } 188 | 189 | prompt_wunjo_precmd() { 190 | local ex=$? 191 | psvar=() 192 | 193 | if [[ $ex -ge 128 ]]; then 194 | sig=$signals[$ex-127] 195 | psvar[1]="sig${(L)sig}" 196 | else 197 | psvar[1]="$ex" 198 | fi 199 | } 200 | 201 | prompt_wunjo_scm_status() { 202 | zgit_isgit || return 203 | local -A pc 204 | pc=(${(kv)wunjo_prompt_colors}) 205 | 206 | head=$(zgit_head) 207 | gitcommit=$(revstring $head) 208 | 209 | local -a commits 210 | 211 | if zgit_rebaseinfo; then 212 | orig_commit=$(revstring $zgit_info[rb_head]) 213 | orig_name=$(git name-rev --name-only $zgit_info[rb_head]) 214 | orig="$pc[scm_branch]$orig_name$pc[punc]($pc[scm_commitid]$orig_commit$pc[punc])" 215 | onto_commit=$(revstring $zgit_info[rb_onto]) 216 | onto_name=$(git name-rev --name-only $zgit_info[rb_onto]) 217 | onto="$pc[scm_branch]$onto_name$pc[punc]($pc[scm_commitid]$onto_commit$pc[punc])" 218 | 219 | if [ -n "$zgit_info[rb_upstream]" ] && [ $zgit_info[rb_upstream] != $zgit_info[rb_onto] ]; then 220 | upstream_commit=$(revstring $zgit_info[rb_upstream]) 221 | upstream_name=$(git name-rev --name-only $zgit_info[rb_upstream]) 222 | upstream="$pc[scm_branch]$upstream_name$pc[punc]($pc[scm_commitid]$upstream_commit$pc[punc])" 223 | commits+="rebasing $upstream$pc[reset]..$orig$pc[reset] onto $onto$pc[reset]" 224 | else 225 | commits+="rebasing $onto$pc[reset]..$orig$pc[reset]" 226 | fi 227 | 228 | local -a revs 229 | revs=($(git rev-list $zgit_info[rb_onto]..HEAD)) 230 | if [ $#revs -gt 0 ]; then 231 | commits+="\n$#revs commits in" 232 | fi 233 | 234 | if [ -f $zgit_info[dotest]/message ]; then 235 | mess=$(head -n1 $zgit_info[dotest]/message) 236 | commits+="on $mess" 237 | fi 238 | elif [ -n "$gitcommit" ]; then 239 | commits+="on $pc[scm_branch]$head$pc[punc]($pc[scm_commitid]$gitcommit$pc[punc])$pc[reset]" 240 | local track_merge=$(zgit_tracking_merge) 241 | if [ -n "$track_merge" ]; then 242 | if git rev-parse --verify -q $track_merge >/dev/null; then 243 | local track_remote=$(zgit_tracking_remote) 244 | local tracked=$(revstring $track_merge 2>/dev/null) 245 | 246 | local -a revs 247 | revs=($(git rev-list --reverse $track_merge..HEAD)) 248 | if [ $#revs -gt 0 ]; then 249 | local base=$(revstring $revs[1]~1) 250 | local base_name=$(git name-rev --name-only $base) 251 | local base_short=$(revstring $base) 252 | local word_commits 253 | if [ $#revs -gt 1 ]; then 254 | word_commits='commits' 255 | else 256 | word_commits='commit' 257 | fi 258 | 259 | local conj="since" 260 | if [[ "$base" == "$tracked" ]]; then 261 | conj+=" tracked" 262 | tracked= 263 | fi 264 | commits+="$#revs $word_commits $conj $pc[scm_branch]$base_name$pc[punc]($pc[scm_commitid]$base_short$pc[punc])$pc[reset]" 265 | fi 266 | 267 | if [ -n "$tracked" ]; then 268 | local track_name=$track_merge 269 | if [[ $track_remote == "." ]]; then 270 | track_name=${track_name##*/} 271 | fi 272 | tracked=$(revstring $tracked) 273 | commits+="tracking $pc[scm_branch]$track_name$pc[punc]" 274 | if [[ "$tracked" != "$gitcommit" ]]; then 275 | commits[$#commits]+="($pc[scm_commitid]$tracked$pc[punc])" 276 | fi 277 | commits[$#commits]+="$pc[reset]" 278 | fi 279 | fi 280 | fi 281 | fi 282 | 283 | gitsvn=$(git rev-parse --verify -q --short git-svn) 284 | if [ $? -eq 0 ]; then 285 | gitsvnrev=$(zgit_svnhead $gitsvn) 286 | gitsvn=$(revstring $gitsvn) 287 | if [ -n "$gitsvnrev" ]; then 288 | local svninfo='' 289 | local -a revs 290 | svninfo+="$pc[default]svn$pc[punc]:$pc[scm_branch]r$gitsvnrev" 291 | revs=($(git rev-list git-svn..HEAD)) 292 | if [ $#revs -gt 0 ]; then 293 | svninfo+="$pc[punc]@$pc[default]HEAD~$#revs" 294 | svninfo+="$pc[punc]($pc[scm_commitid]$gitsvn$pc[punc])" 295 | fi 296 | commits+=$svninfo 297 | fi 298 | fi 299 | 300 | if [ $#commits -gt 0 ]; then 301 | echo -n " ${(j: :)commits}" 302 | fi 303 | } 304 | 305 | prompt_wunjo_scm_branch() { 306 | zgit_isgit || return 307 | local -A pc 308 | pc=(${(kv)wunjo_prompt_colors}) 309 | 310 | echo -n "$pc[punc]$pc[scm_branch]$(zgit_head)" 311 | 312 | if zgit_inworktree; then 313 | if ! zgit_isindexclean; then 314 | echo -n "$pc[scm_status_staged]+" 315 | fi 316 | 317 | local -a dirty 318 | if ! zgit_isworktreeclean; then 319 | dirty+='!' 320 | fi 321 | 322 | if zgit_hasunmerged; then 323 | dirty+='*' 324 | fi 325 | 326 | if zgit_hasuntracked; then 327 | dirty+='?' 328 | fi 329 | 330 | if [ $#dirty -gt 0 ]; then 331 | echo -n "$pc[scm_status_dirty]${(j::)dirty}" 332 | fi 333 | fi 334 | 335 | echo $pc[reset] 336 | } 337 | 338 | prompt_grb_setup "$@" 339 | 340 | # vim:set ft=zsh: 341 | -------------------------------------------------------------------------------- /emacs.d/custom/05_rainbow_mode.el: -------------------------------------------------------------------------------- 1 | ;;; rainbow-mode.el --- Colorize color names in buffers 2 | 3 | ;; Copyright (C) 2010-2012 Free Software Foundation, Inc 4 | 5 | ;; Author: Julien Danjou 6 | ;; Keywords: faces 7 | ;; Version: 0.8 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | ;; 26 | ;; This minor mode sets background color to strings that match color 27 | ;; names, e.g. #0000ff is displayed in white with a blue background. 28 | ;; 29 | 30 | ;;; Code: 31 | 32 | (eval-when-compile 33 | (require 'cl)) 34 | 35 | (require 'regexp-opt) 36 | (require 'faces) 37 | (require 'color) 38 | 39 | (unless (require 'xterm-color nil t) 40 | (require 'ansi-color)) 41 | 42 | (defgroup rainbow nil 43 | "Show color strings with a background color." 44 | :tag "Rainbow" 45 | :group 'help) 46 | 47 | ;; Hexadecimal colors 48 | (defvar rainbow-hexadecimal-colors-font-lock-keywords 49 | '(("[^&]\\(#\\(?:[0-9a-fA-F]\\{3\\}\\)+\\{1,4\\}\\)" 50 | (1 (rainbow-colorize-itself 1))) 51 | ("^\\(#\\(?:[0-9a-fA-F]\\{3\\}\\)+\\{1,4\\}\\)" 52 | (0 (rainbow-colorize-itself))) 53 | ("[Rr][Gg][Bb]:[0-9a-fA-F]\\{1,4\\}/[0-9a-fA-F]\\{1,4\\}/[0-9a-fA-F]\\{1,4\\}" 54 | (0 (rainbow-colorize-itself))) 55 | ("[Rr][Gg][Bb][Ii]:[0-9.]+/[0-9.]+/[0-9.]+" 56 | (0 (rainbow-colorize-itself))) 57 | ("\\(?:[Cc][Ii][Ee]\\(?:[Xx][Yy][Zz]\\|[Uu][Vv][Yy]\\|[Xx][Yy][Yy]\\|[Ll][Aa][Bb]\\|[Ll][Uu][Vv]\\)\\|[Tt][Ee][Kk][Hh][Vv][Cc]\\):[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?/[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?/[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?" 58 | (0 (rainbow-colorize-itself)))) 59 | "Font-lock keywords to add for hexadecimal colors.") 60 | 61 | ;; rgb() colors 62 | (defvar rainbow-html-rgb-colors-font-lock-keywords 63 | '(("rgb(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*)" 64 | (0 (rainbow-colorize-rgb))) 65 | ("rgba(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)" 66 | (0 (rainbow-colorize-rgb))) 67 | ("hsl(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*)" 68 | (0 (rainbow-colorize-hsl))) 69 | ("hsla(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)" 70 | (0 (rainbow-colorize-hsl)))) 71 | "Font-lock keywords to add for RGB colors.") 72 | 73 | ;; HTML colors name 74 | (defvar rainbow-html-colors-font-lock-keywords nil 75 | "Font-lock keywords to add for HTML colors.") 76 | (make-variable-buffer-local 'rainbow-html-colors-font-lock-keywords) 77 | 78 | (defcustom rainbow-html-colors-alist 79 | '(("AliceBlue" . "#F0F8FF") 80 | ("AntiqueWhite" . "#FAEBD7") 81 | ("Aqua" . "#00FFFF") 82 | ("Aquamarine" . "#7FFFD4") 83 | ("Azure" . "#F0FFFF") 84 | ("Beige" . "#F5F5DC") 85 | ("Bisque" . "#FFE4C4") 86 | ("Black" . "#000000") 87 | ("BlanchedAlmond" . "#FFEBCD") 88 | ("Blue" . "#0000FF") 89 | ("BlueViolet" . "#8A2BE2") 90 | ("Brown" . "#A52A2A") 91 | ("BurlyWood" . "#DEB887") 92 | ("CadetBlue" . "#5F9EA0") 93 | ("Chartreuse" . "#7FFF00") 94 | ("Chocolate" . "#D2691E") 95 | ("Coral" . "#FF7F50") 96 | ("CornflowerBlue" . "#6495ED") 97 | ("Cornsilk" . "#FFF8DC") 98 | ("Crimson" . "#DC143C") 99 | ("Cyan" . "#00FFFF") 100 | ("DarkBlue" . "#00008B") 101 | ("DarkCyan" . "#008B8B") 102 | ("DarkGoldenRod" . "#B8860B") 103 | ("DarkGray" . "#A9A9A9") 104 | ("DarkGrey" . "#A9A9A9") 105 | ("DarkGreen" . "#006400") 106 | ("DarkKhaki" . "#BDB76B") 107 | ("DarkMagenta" . "#8B008B") 108 | ("DarkOliveGreen" . "#556B2F") 109 | ("Darkorange" . "#FF8C00") 110 | ("DarkOrchid" . "#9932CC") 111 | ("DarkRed" . "#8B0000") 112 | ("DarkSalmon" . "#E9967A") 113 | ("DarkSeaGreen" . "#8FBC8F") 114 | ("DarkSlateBlue" . "#483D8B") 115 | ("DarkSlateGray" . "#2F4F4F") 116 | ("DarkSlateGrey" . "#2F4F4F") 117 | ("DarkTurquoise" . "#00CED1") 118 | ("DarkViolet" . "#9400D3") 119 | ("DeepPink" . "#FF1493") 120 | ("DeepSkyBlue" . "#00BFFF") 121 | ("DimGray" . "#696969") 122 | ("DimGrey" . "#696969") 123 | ("DodgerBlue" . "#1E90FF") 124 | ("FireBrick" . "#B22222") 125 | ("FloralWhite" . "#FFFAF0") 126 | ("ForestGreen" . "#228B22") 127 | ("Fuchsia" . "#FF00FF") 128 | ("Gainsboro" . "#DCDCDC") 129 | ("GhostWhite" . "#F8F8FF") 130 | ("Gold" . "#FFD700") 131 | ("GoldenRod" . "#DAA520") 132 | ("Gray" . "#808080") 133 | ("Grey" . "#808080") 134 | ("Green" . "#008000") 135 | ("GreenYellow" . "#ADFF2F") 136 | ("HoneyDew" . "#F0FFF0") 137 | ("HotPink" . "#FF69B4") 138 | ("IndianRed" . "#CD5C5C") 139 | ("Indigo" . "#4B0082") 140 | ("Ivory" . "#FFFFF0") 141 | ("Khaki" . "#F0E68C") 142 | ("Lavender" . "#E6E6FA") 143 | ("LavenderBlush" . "#FFF0F5") 144 | ("LawnGreen" . "#7CFC00") 145 | ("LemonChiffon" . "#FFFACD") 146 | ("LightBlue" . "#ADD8E6") 147 | ("LightCoral" . "#F08080") 148 | ("LightCyan" . "#E0FFFF") 149 | ("LightGoldenRodYellow" . "#FAFAD2") 150 | ("LightGray" . "#D3D3D3") 151 | ("LightGrey" . "#D3D3D3") 152 | ("LightGreen" . "#90EE90") 153 | ("LightPink" . "#FFB6C1") 154 | ("LightSalmon" . "#FFA07A") 155 | ("LightSeaGreen" . "#20B2AA") 156 | ("LightSkyBlue" . "#87CEFA") 157 | ("LightSlateGray" . "#778899") 158 | ("LightSlateGrey" . "#778899") 159 | ("LightSteelBlue" . "#B0C4DE") 160 | ("LightYellow" . "#FFFFE0") 161 | ("Lime" . "#00FF00") 162 | ("LimeGreen" . "#32CD32") 163 | ("Linen" . "#FAF0E6") 164 | ("Magenta" . "#FF00FF") 165 | ("Maroon" . "#800000") 166 | ("MediumAquaMarine" . "#66CDAA") 167 | ("MediumBlue" . "#0000CD") 168 | ("MediumOrchid" . "#BA55D3") 169 | ("MediumPurple" . "#9370D8") 170 | ("MediumSeaGreen" . "#3CB371") 171 | ("MediumSlateBlue" . "#7B68EE") 172 | ("MediumSpringGreen" . "#00FA9A") 173 | ("MediumTurquoise" . "#48D1CC") 174 | ("MediumVioletRed" . "#C71585") 175 | ("MidnightBlue" . "#191970") 176 | ("MintCream" . "#F5FFFA") 177 | ("MistyRose" . "#FFE4E1") 178 | ("Moccasin" . "#FFE4B5") 179 | ("NavajoWhite" . "#FFDEAD") 180 | ("Navy" . "#000080") 181 | ("OldLace" . "#FDF5E6") 182 | ("Olive" . "#808000") 183 | ("OliveDrab" . "#6B8E23") 184 | ("Orange" . "#FFA500") 185 | ("OrangeRed" . "#FF4500") 186 | ("Orchid" . "#DA70D6") 187 | ("PaleGoldenRod" . "#EEE8AA") 188 | ("PaleGreen" . "#98FB98") 189 | ("PaleTurquoise" . "#AFEEEE") 190 | ("PaleVioletRed" . "#D87093") 191 | ("PapayaWhip" . "#FFEFD5") 192 | ("PeachPuff" . "#FFDAB9") 193 | ("Peru" . "#CD853F") 194 | ("Pink" . "#FFC0CB") 195 | ("Plum" . "#DDA0DD") 196 | ("PowderBlue" . "#B0E0E6") 197 | ("Purple" . "#800080") 198 | ("Red" . "#FF0000") 199 | ("RosyBrown" . "#BC8F8F") 200 | ("RoyalBlue" . "#4169E1") 201 | ("SaddleBrown" . "#8B4513") 202 | ("Salmon" . "#FA8072") 203 | ("SandyBrown" . "#F4A460") 204 | ("SeaGreen" . "#2E8B57") 205 | ("SeaShell" . "#FFF5EE") 206 | ("Sienna" . "#A0522D") 207 | ("Silver" . "#C0C0C0") 208 | ("SkyBlue" . "#87CEEB") 209 | ("SlateBlue" . "#6A5ACD") 210 | ("SlateGray" . "#708090") 211 | ("SlateGrey" . "#708090") 212 | ("Snow" . "#FFFAFA") 213 | ("SpringGreen" . "#00FF7F") 214 | ("SteelBlue" . "#4682B4") 215 | ("Tan" . "#D2B48C") 216 | ("Teal" . "#008080") 217 | ("Thistle" . "#D8BFD8") 218 | ("Tomato" . "#FF6347") 219 | ("Turquoise" . "#40E0D0") 220 | ("Violet" . "#EE82EE") 221 | ("Wheat" . "#F5DEB3") 222 | ("White" . "#FFFFFF") 223 | ("WhiteSmoke" . "#F5F5F5") 224 | ("Yellow" . "#FFFF00") 225 | ("YellowGreen" . "#9ACD32")) 226 | "Alist of HTML colors. 227 | Each entry should have the form (COLOR-NAME . HEXADECIMAL-COLOR)." 228 | :group 'rainbow) 229 | 230 | (defcustom rainbow-html-colors-major-mode-list 231 | '(html-mode css-mode php-mode nxml-mode xml-mode) 232 | "List of major mode where HTML colors are enabled when 233 | `rainbow-html-colors' is set to auto." 234 | :group 'rainbow) 235 | 236 | (defcustom rainbow-html-colors 'auto 237 | "When to enable HTML colors. 238 | If set to t, the HTML colors will be enabled. If set to nil, the 239 | HTML colors will not be enabled. If set to auto, the HTML colors 240 | will be enabled if a major mode has been detected from the 241 | `rainbow-html-colors-major-mode-list'." 242 | :group 'rainbow) 243 | 244 | ;; X colors 245 | (defvar rainbow-x-colors-font-lock-keywords 246 | `((,(regexp-opt (x-defined-colors) 'words) 247 | (0 (rainbow-colorize-itself)))) 248 | "Font-lock keywords to add for X colors.") 249 | 250 | (defcustom rainbow-x-colors-major-mode-list 251 | '(emacs-lisp-mode lisp-interaction-mode c-mode c++-mode java-mode) 252 | "List of major mode where X colors are enabled when 253 | `rainbow-x-colors' is set to auto." 254 | :group 'rainbow) 255 | 256 | (defcustom rainbow-x-colors 'auto 257 | "When to enable X colors. 258 | If set to t, the X colors will be enabled. If set to nil, the 259 | X colors will not be enabled. If set to auto, the X colors 260 | will be enabled if a major mode has been detected from the 261 | `rainbow-x-colors-major-mode-list'." 262 | :group 'rainbow) 263 | 264 | ;; LaTeX colors 265 | (defvar rainbow-latex-rgb-colors-font-lock-keywords 266 | '(("{rgb}{\\([0-9.]+\\),\\([0-9.]+\\),\\([0-9.]+\\)}" 267 | (0 (rainbow-colorize-rgb-float))) 268 | ("{RGB}{\\([0-9]\\{1,3\\}\\),\\([0-9]\\{1,3\\}\\),\\([0-9]\\{1,3\\}\\)}" 269 | (0 (rainbow-colorize-rgb))) 270 | ("{HTML}{\\([0-9A-Fa-f]\\{6\\}\\)}" 271 | (0 (rainbow-colorize-hexadecimal-without-sharp)))) 272 | "Font-lock keywords to add for LaTeX colors.") 273 | 274 | (defcustom rainbow-latex-colors-major-mode-list 275 | '(latex-mode) 276 | "List of major mode where LaTeX colors are enabled when 277 | `rainbow-x-colors' is set to auto." 278 | :group 'rainbow) 279 | 280 | (defcustom rainbow-latex-colors 'auto 281 | "When to enable LaTeX colors. 282 | If set to t, the LaTeX colors will be enabled. If set to nil, the 283 | LaTeX colors will not be enabled. If set to auto, the LaTeX colors 284 | will be enabled if a major mode has been detected from the 285 | `rainbow-latex-colors-major-mode-list'." 286 | :group 'rainbow) 287 | 288 | ;; Shell colors 289 | (defvar rainbow-ansi-colors-font-lock-keywords 290 | '(("\\(\\\\[eE]\\|\\\\033\\|\\\\x1[bB]\\|\033\\)\\[\\([0-9;]*m\\)" 291 | (0 (rainbow-colorize-ansi)))) 292 | "Font-lock keywords to add for ANSI colors.") 293 | 294 | (defcustom rainbow-ansi-colors-major-mode-list 295 | '(sh-mode c-mode c++-mode) 296 | "List of major mode where ANSI colors are enabled when 297 | `rainbow-ansi-colors' is set to auto." 298 | :group 'rainbow) 299 | 300 | (defcustom rainbow-ansi-colors 'auto 301 | "When to enable ANSI colors. 302 | If set to t, the ANSI colors will be enabled. If set to nil, the 303 | ANSI colors will not be enabled. If set to auto, the ANSI colors 304 | will be enabled if a major mode has been detected from the 305 | `rainbow-ansi-colors-major-mode-list'." 306 | :group 'rainbow) 307 | 308 | ;; R colors 309 | 310 | ;; R colors name 311 | (defvar rainbow-r-colors-font-lock-keywords nil 312 | "Font-lock keywords to add for R colors.") 313 | (make-variable-buffer-local 'rainbow-r-colors-font-lock-keywords) 314 | 315 | ;; use the following code to generate the list in R 316 | ;; output_colors <- function(colors) {for(color in colors) {col <- col2rgb(color); cat(sprintf("(\"%s\" . \"#%02X%02X%02X\")\n",color,col[1],col[2],col[3]));}} 317 | ;; output_colors(colors()) 318 | (defcustom rainbow-r-colors-alist 319 | '(("white" . "#FFFFFF") 320 | ("aliceblue" . "#F0F8FF") 321 | ("antiquewhite" . "#FAEBD7") 322 | ("antiquewhite1" . "#FFEFDB") 323 | ("antiquewhite2" . "#EEDFCC") 324 | ("antiquewhite3" . "#CDC0B0") 325 | ("antiquewhite4" . "#8B8378") 326 | ("aquamarine" . "#7FFFD4") 327 | ("aquamarine1" . "#7FFFD4") 328 | ("aquamarine2" . "#76EEC6") 329 | ("aquamarine3" . "#66CDAA") 330 | ("aquamarine4" . "#458B74") 331 | ("azure" . "#F0FFFF") 332 | ("azure1" . "#F0FFFF") 333 | ("azure2" . "#E0EEEE") 334 | ("azure3" . "#C1CDCD") 335 | ("azure4" . "#838B8B") 336 | ("beige" . "#F5F5DC") 337 | ("bisque" . "#FFE4C4") 338 | ("bisque1" . "#FFE4C4") 339 | ("bisque2" . "#EED5B7") 340 | ("bisque3" . "#CDB79E") 341 | ("bisque4" . "#8B7D6B") 342 | ("black" . "#000000") 343 | ("blanchedalmond" . "#FFEBCD") 344 | ("blue" . "#0000FF") 345 | ("blue1" . "#0000FF") 346 | ("blue2" . "#0000EE") 347 | ("blue3" . "#0000CD") 348 | ("blue4" . "#00008B") 349 | ("blueviolet" . "#8A2BE2") 350 | ("brown" . "#A52A2A") 351 | ("brown1" . "#FF4040") 352 | ("brown2" . "#EE3B3B") 353 | ("brown3" . "#CD3333") 354 | ("brown4" . "#8B2323") 355 | ("burlywood" . "#DEB887") 356 | ("burlywood1" . "#FFD39B") 357 | ("burlywood2" . "#EEC591") 358 | ("burlywood3" . "#CDAA7D") 359 | ("burlywood4" . "#8B7355") 360 | ("cadetblue" . "#5F9EA0") 361 | ("cadetblue1" . "#98F5FF") 362 | ("cadetblue2" . "#8EE5EE") 363 | ("cadetblue3" . "#7AC5CD") 364 | ("cadetblue4" . "#53868B") 365 | ("chartreuse" . "#7FFF00") 366 | ("chartreuse1" . "#7FFF00") 367 | ("chartreuse2" . "#76EE00") 368 | ("chartreuse3" . "#66CD00") 369 | ("chartreuse4" . "#458B00") 370 | ("chocolate" . "#D2691E") 371 | ("chocolate1" . "#FF7F24") 372 | ("chocolate2" . "#EE7621") 373 | ("chocolate3" . "#CD661D") 374 | ("chocolate4" . "#8B4513") 375 | ("coral" . "#FF7F50") 376 | ("coral1" . "#FF7256") 377 | ("coral2" . "#EE6A50") 378 | ("coral3" . "#CD5B45") 379 | ("coral4" . "#8B3E2F") 380 | ("cornflowerblue" . "#6495ED") 381 | ("cornsilk" . "#FFF8DC") 382 | ("cornsilk1" . "#FFF8DC") 383 | ("cornsilk2" . "#EEE8CD") 384 | ("cornsilk3" . "#CDC8B1") 385 | ("cornsilk4" . "#8B8878") 386 | ("cyan" . "#00FFFF") 387 | ("cyan1" . "#00FFFF") 388 | ("cyan2" . "#00EEEE") 389 | ("cyan3" . "#00CDCD") 390 | ("cyan4" . "#008B8B") 391 | ("darkblue" . "#00008B") 392 | ("darkcyan" . "#008B8B") 393 | ("darkgoldenrod" . "#B8860B") 394 | ("darkgoldenrod1" . "#FFB90F") 395 | ("darkgoldenrod2" . "#EEAD0E") 396 | ("darkgoldenrod3" . "#CD950C") 397 | ("darkgoldenrod4" . "#8B6508") 398 | ("darkgray" . "#A9A9A9") 399 | ("darkgreen" . "#006400") 400 | ("darkgrey" . "#A9A9A9") 401 | ("darkkhaki" . "#BDB76B") 402 | ("darkmagenta" . "#8B008B") 403 | ("darkolivegreen" . "#556B2F") 404 | ("darkolivegreen1" . "#CAFF70") 405 | ("darkolivegreen2" . "#BCEE68") 406 | ("darkolivegreen3" . "#A2CD5A") 407 | ("darkolivegreen4" . "#6E8B3D") 408 | ("darkorange" . "#FF8C00") 409 | ("darkorange1" . "#FF7F00") 410 | ("darkorange2" . "#EE7600") 411 | ("darkorange3" . "#CD6600") 412 | ("darkorange4" . "#8B4500") 413 | ("darkorchid" . "#9932CC") 414 | ("darkorchid1" . "#BF3EFF") 415 | ("darkorchid2" . "#B23AEE") 416 | ("darkorchid3" . "#9A32CD") 417 | ("darkorchid4" . "#68228B") 418 | ("darkred" . "#8B0000") 419 | ("darksalmon" . "#E9967A") 420 | ("darkseagreen" . "#8FBC8F") 421 | ("darkseagreen1" . "#C1FFC1") 422 | ("darkseagreen2" . "#B4EEB4") 423 | ("darkseagreen3" . "#9BCD9B") 424 | ("darkseagreen4" . "#698B69") 425 | ("darkslateblue" . "#483D8B") 426 | ("darkslategray" . "#2F4F4F") 427 | ("darkslategray1" . "#97FFFF") 428 | ("darkslategray2" . "#8DEEEE") 429 | ("darkslategray3" . "#79CDCD") 430 | ("darkslategray4" . "#528B8B") 431 | ("darkslategrey" . "#2F4F4F") 432 | ("darkturquoise" . "#00CED1") 433 | ("darkviolet" . "#9400D3") 434 | ("deeppink" . "#FF1493") 435 | ("deeppink1" . "#FF1493") 436 | ("deeppink2" . "#EE1289") 437 | ("deeppink3" . "#CD1076") 438 | ("deeppink4" . "#8B0A50") 439 | ("deepskyblue" . "#00BFFF") 440 | ("deepskyblue1" . "#00BFFF") 441 | ("deepskyblue2" . "#00B2EE") 442 | ("deepskyblue3" . "#009ACD") 443 | ("deepskyblue4" . "#00688B") 444 | ("dimgray" . "#696969") 445 | ("dimgrey" . "#696969") 446 | ("dodgerblue" . "#1E90FF") 447 | ("dodgerblue1" . "#1E90FF") 448 | ("dodgerblue2" . "#1C86EE") 449 | ("dodgerblue3" . "#1874CD") 450 | ("dodgerblue4" . "#104E8B") 451 | ("firebrick" . "#B22222") 452 | ("firebrick1" . "#FF3030") 453 | ("firebrick2" . "#EE2C2C") 454 | ("firebrick3" . "#CD2626") 455 | ("firebrick4" . "#8B1A1A") 456 | ("floralwhite" . "#FFFAF0") 457 | ("forestgreen" . "#228B22") 458 | ("gainsboro" . "#DCDCDC") 459 | ("ghostwhite" . "#F8F8FF") 460 | ("gold" . "#FFD700") 461 | ("gold1" . "#FFD700") 462 | ("gold2" . "#EEC900") 463 | ("gold3" . "#CDAD00") 464 | ("gold4" . "#8B7500") 465 | ("goldenrod" . "#DAA520") 466 | ("goldenrod1" . "#FFC125") 467 | ("goldenrod2" . "#EEB422") 468 | ("goldenrod3" . "#CD9B1D") 469 | ("goldenrod4" . "#8B6914") 470 | ("gray" . "#BEBEBE") 471 | ("gray0" . "#000000") 472 | ("gray1" . "#030303") 473 | ("gray2" . "#050505") 474 | ("gray3" . "#080808") 475 | ("gray4" . "#0A0A0A") 476 | ("gray5" . "#0D0D0D") 477 | ("gray6" . "#0F0F0F") 478 | ("gray7" . "#121212") 479 | ("gray8" . "#141414") 480 | ("gray9" . "#171717") 481 | ("gray10" . "#1A1A1A") 482 | ("gray11" . "#1C1C1C") 483 | ("gray12" . "#1F1F1F") 484 | ("gray13" . "#212121") 485 | ("gray14" . "#242424") 486 | ("gray15" . "#262626") 487 | ("gray16" . "#292929") 488 | ("gray17" . "#2B2B2B") 489 | ("gray18" . "#2E2E2E") 490 | ("gray19" . "#303030") 491 | ("gray20" . "#333333") 492 | ("gray21" . "#363636") 493 | ("gray22" . "#383838") 494 | ("gray23" . "#3B3B3B") 495 | ("gray24" . "#3D3D3D") 496 | ("gray25" . "#404040") 497 | ("gray26" . "#424242") 498 | ("gray27" . "#454545") 499 | ("gray28" . "#474747") 500 | ("gray29" . "#4A4A4A") 501 | ("gray30" . "#4D4D4D") 502 | ("gray31" . "#4F4F4F") 503 | ("gray32" . "#525252") 504 | ("gray33" . "#545454") 505 | ("gray34" . "#575757") 506 | ("gray35" . "#595959") 507 | ("gray36" . "#5C5C5C") 508 | ("gray37" . "#5E5E5E") 509 | ("gray38" . "#616161") 510 | ("gray39" . "#636363") 511 | ("gray40" . "#666666") 512 | ("gray41" . "#696969") 513 | ("gray42" . "#6B6B6B") 514 | ("gray43" . "#6E6E6E") 515 | ("gray44" . "#707070") 516 | ("gray45" . "#737373") 517 | ("gray46" . "#757575") 518 | ("gray47" . "#787878") 519 | ("gray48" . "#7A7A7A") 520 | ("gray49" . "#7D7D7D") 521 | ("gray50" . "#7F7F7F") 522 | ("gray51" . "#828282") 523 | ("gray52" . "#858585") 524 | ("gray53" . "#878787") 525 | ("gray54" . "#8A8A8A") 526 | ("gray55" . "#8C8C8C") 527 | ("gray56" . "#8F8F8F") 528 | ("gray57" . "#919191") 529 | ("gray58" . "#949494") 530 | ("gray59" . "#969696") 531 | ("gray60" . "#999999") 532 | ("gray61" . "#9C9C9C") 533 | ("gray62" . "#9E9E9E") 534 | ("gray63" . "#A1A1A1") 535 | ("gray64" . "#A3A3A3") 536 | ("gray65" . "#A6A6A6") 537 | ("gray66" . "#A8A8A8") 538 | ("gray67" . "#ABABAB") 539 | ("gray68" . "#ADADAD") 540 | ("gray69" . "#B0B0B0") 541 | ("gray70" . "#B3B3B3") 542 | ("gray71" . "#B5B5B5") 543 | ("gray72" . "#B8B8B8") 544 | ("gray73" . "#BABABA") 545 | ("gray74" . "#BDBDBD") 546 | ("gray75" . "#BFBFBF") 547 | ("gray76" . "#C2C2C2") 548 | ("gray77" . "#C4C4C4") 549 | ("gray78" . "#C7C7C7") 550 | ("gray79" . "#C9C9C9") 551 | ("gray80" . "#CCCCCC") 552 | ("gray81" . "#CFCFCF") 553 | ("gray82" . "#D1D1D1") 554 | ("gray83" . "#D4D4D4") 555 | ("gray84" . "#D6D6D6") 556 | ("gray85" . "#D9D9D9") 557 | ("gray86" . "#DBDBDB") 558 | ("gray87" . "#DEDEDE") 559 | ("gray88" . "#E0E0E0") 560 | ("gray89" . "#E3E3E3") 561 | ("gray90" . "#E5E5E5") 562 | ("gray91" . "#E8E8E8") 563 | ("gray92" . "#EBEBEB") 564 | ("gray93" . "#EDEDED") 565 | ("gray94" . "#F0F0F0") 566 | ("gray95" . "#F2F2F2") 567 | ("gray96" . "#F5F5F5") 568 | ("gray97" . "#F7F7F7") 569 | ("gray98" . "#FAFAFA") 570 | ("gray99" . "#FCFCFC") 571 | ("gray100" . "#FFFFFF") 572 | ("green" . "#00FF00") 573 | ("green1" . "#00FF00") 574 | ("green2" . "#00EE00") 575 | ("green3" . "#00CD00") 576 | ("green4" . "#008B00") 577 | ("greenyellow" . "#ADFF2F") 578 | ("grey" . "#BEBEBE") 579 | ("grey0" . "#000000") 580 | ("grey1" . "#030303") 581 | ("grey2" . "#050505") 582 | ("grey3" . "#080808") 583 | ("grey4" . "#0A0A0A") 584 | ("grey5" . "#0D0D0D") 585 | ("grey6" . "#0F0F0F") 586 | ("grey7" . "#121212") 587 | ("grey8" . "#141414") 588 | ("grey9" . "#171717") 589 | ("grey10" . "#1A1A1A") 590 | ("grey11" . "#1C1C1C") 591 | ("grey12" . "#1F1F1F") 592 | ("grey13" . "#212121") 593 | ("grey14" . "#242424") 594 | ("grey15" . "#262626") 595 | ("grey16" . "#292929") 596 | ("grey17" . "#2B2B2B") 597 | ("grey18" . "#2E2E2E") 598 | ("grey19" . "#303030") 599 | ("grey20" . "#333333") 600 | ("grey21" . "#363636") 601 | ("grey22" . "#383838") 602 | ("grey23" . "#3B3B3B") 603 | ("grey24" . "#3D3D3D") 604 | ("grey25" . "#404040") 605 | ("grey26" . "#424242") 606 | ("grey27" . "#454545") 607 | ("grey28" . "#474747") 608 | ("grey29" . "#4A4A4A") 609 | ("grey30" . "#4D4D4D") 610 | ("grey31" . "#4F4F4F") 611 | ("grey32" . "#525252") 612 | ("grey33" . "#545454") 613 | ("grey34" . "#575757") 614 | ("grey35" . "#595959") 615 | ("grey36" . "#5C5C5C") 616 | ("grey37" . "#5E5E5E") 617 | ("grey38" . "#616161") 618 | ("grey39" . "#636363") 619 | ("grey40" . "#666666") 620 | ("grey41" . "#696969") 621 | ("grey42" . "#6B6B6B") 622 | ("grey43" . "#6E6E6E") 623 | ("grey44" . "#707070") 624 | ("grey45" . "#737373") 625 | ("grey46" . "#757575") 626 | ("grey47" . "#787878") 627 | ("grey48" . "#7A7A7A") 628 | ("grey49" . "#7D7D7D") 629 | ("grey50" . "#7F7F7F") 630 | ("grey51" . "#828282") 631 | ("grey52" . "#858585") 632 | ("grey53" . "#878787") 633 | ("grey54" . "#8A8A8A") 634 | ("grey55" . "#8C8C8C") 635 | ("grey56" . "#8F8F8F") 636 | ("grey57" . "#919191") 637 | ("grey58" . "#949494") 638 | ("grey59" . "#969696") 639 | ("grey60" . "#999999") 640 | ("grey61" . "#9C9C9C") 641 | ("grey62" . "#9E9E9E") 642 | ("grey63" . "#A1A1A1") 643 | ("grey64" . "#A3A3A3") 644 | ("grey65" . "#A6A6A6") 645 | ("grey66" . "#A8A8A8") 646 | ("grey67" . "#ABABAB") 647 | ("grey68" . "#ADADAD") 648 | ("grey69" . "#B0B0B0") 649 | ("grey70" . "#B3B3B3") 650 | ("grey71" . "#B5B5B5") 651 | ("grey72" . "#B8B8B8") 652 | ("grey73" . "#BABABA") 653 | ("grey74" . "#BDBDBD") 654 | ("grey75" . "#BFBFBF") 655 | ("grey76" . "#C2C2C2") 656 | ("grey77" . "#C4C4C4") 657 | ("grey78" . "#C7C7C7") 658 | ("grey79" . "#C9C9C9") 659 | ("grey80" . "#CCCCCC") 660 | ("grey81" . "#CFCFCF") 661 | ("grey82" . "#D1D1D1") 662 | ("grey83" . "#D4D4D4") 663 | ("grey84" . "#D6D6D6") 664 | ("grey85" . "#D9D9D9") 665 | ("grey86" . "#DBDBDB") 666 | ("grey87" . "#DEDEDE") 667 | ("grey88" . "#E0E0E0") 668 | ("grey89" . "#E3E3E3") 669 | ("grey90" . "#E5E5E5") 670 | ("grey91" . "#E8E8E8") 671 | ("grey92" . "#EBEBEB") 672 | ("grey93" . "#EDEDED") 673 | ("grey94" . "#F0F0F0") 674 | ("grey95" . "#F2F2F2") 675 | ("grey96" . "#F5F5F5") 676 | ("grey97" . "#F7F7F7") 677 | ("grey98" . "#FAFAFA") 678 | ("grey99" . "#FCFCFC") 679 | ("grey100" . "#FFFFFF") 680 | ("honeydew" . "#F0FFF0") 681 | ("honeydew1" . "#F0FFF0") 682 | ("honeydew2" . "#E0EEE0") 683 | ("honeydew3" . "#C1CDC1") 684 | ("honeydew4" . "#838B83") 685 | ("hotpink" . "#FF69B4") 686 | ("hotpink1" . "#FF6EB4") 687 | ("hotpink2" . "#EE6AA7") 688 | ("hotpink3" . "#CD6090") 689 | ("hotpink4" . "#8B3A62") 690 | ("indianred" . "#CD5C5C") 691 | ("indianred1" . "#FF6A6A") 692 | ("indianred2" . "#EE6363") 693 | ("indianred3" . "#CD5555") 694 | ("indianred4" . "#8B3A3A") 695 | ("ivory" . "#FFFFF0") 696 | ("ivory1" . "#FFFFF0") 697 | ("ivory2" . "#EEEEE0") 698 | ("ivory3" . "#CDCDC1") 699 | ("ivory4" . "#8B8B83") 700 | ("khaki" . "#F0E68C") 701 | ("khaki1" . "#FFF68F") 702 | ("khaki2" . "#EEE685") 703 | ("khaki3" . "#CDC673") 704 | ("khaki4" . "#8B864E") 705 | ("lavender" . "#E6E6FA") 706 | ("lavenderblush" . "#FFF0F5") 707 | ("lavenderblush1" . "#FFF0F5") 708 | ("lavenderblush2" . "#EEE0E5") 709 | ("lavenderblush3" . "#CDC1C5") 710 | ("lavenderblush4" . "#8B8386") 711 | ("lawngreen" . "#7CFC00") 712 | ("lemonchiffon" . "#FFFACD") 713 | ("lemonchiffon1" . "#FFFACD") 714 | ("lemonchiffon2" . "#EEE9BF") 715 | ("lemonchiffon3" . "#CDC9A5") 716 | ("lemonchiffon4" . "#8B8970") 717 | ("lightblue" . "#ADD8E6") 718 | ("lightblue1" . "#BFEFFF") 719 | ("lightblue2" . "#B2DFEE") 720 | ("lightblue3" . "#9AC0CD") 721 | ("lightblue4" . "#68838B") 722 | ("lightcoral" . "#F08080") 723 | ("lightcyan" . "#E0FFFF") 724 | ("lightcyan1" . "#E0FFFF") 725 | ("lightcyan2" . "#D1EEEE") 726 | ("lightcyan3" . "#B4CDCD") 727 | ("lightcyan4" . "#7A8B8B") 728 | ("lightgoldenrod" . "#EEDD82") 729 | ("lightgoldenrod1" . "#FFEC8B") 730 | ("lightgoldenrod2" . "#EEDC82") 731 | ("lightgoldenrod3" . "#CDBE70") 732 | ("lightgoldenrod4" . "#8B814C") 733 | ("lightgoldenrodyellow" . "#FAFAD2") 734 | ("lightgray" . "#D3D3D3") 735 | ("lightgreen" . "#90EE90") 736 | ("lightgrey" . "#D3D3D3") 737 | ("lightpink" . "#FFB6C1") 738 | ("lightpink1" . "#FFAEB9") 739 | ("lightpink2" . "#EEA2AD") 740 | ("lightpink3" . "#CD8C95") 741 | ("lightpink4" . "#8B5F65") 742 | ("lightsalmon" . "#FFA07A") 743 | ("lightsalmon1" . "#FFA07A") 744 | ("lightsalmon2" . "#EE9572") 745 | ("lightsalmon3" . "#CD8162") 746 | ("lightsalmon4" . "#8B5742") 747 | ("lightseagreen" . "#20B2AA") 748 | ("lightskyblue" . "#87CEFA") 749 | ("lightskyblue1" . "#B0E2FF") 750 | ("lightskyblue2" . "#A4D3EE") 751 | ("lightskyblue3" . "#8DB6CD") 752 | ("lightskyblue4" . "#607B8B") 753 | ("lightslateblue" . "#8470FF") 754 | ("lightslategray" . "#778899") 755 | ("lightslategrey" . "#778899") 756 | ("lightsteelblue" . "#B0C4DE") 757 | ("lightsteelblue1" . "#CAE1FF") 758 | ("lightsteelblue2" . "#BCD2EE") 759 | ("lightsteelblue3" . "#A2B5CD") 760 | ("lightsteelblue4" . "#6E7B8B") 761 | ("lightyellow" . "#FFFFE0") 762 | ("lightyellow1" . "#FFFFE0") 763 | ("lightyellow2" . "#EEEED1") 764 | ("lightyellow3" . "#CDCDB4") 765 | ("lightyellow4" . "#8B8B7A") 766 | ("limegreen" . "#32CD32") 767 | ("linen" . "#FAF0E6") 768 | ("magenta" . "#FF00FF") 769 | ("magenta1" . "#FF00FF") 770 | ("magenta2" . "#EE00EE") 771 | ("magenta3" . "#CD00CD") 772 | ("magenta4" . "#8B008B") 773 | ("maroon" . "#B03060") 774 | ("maroon1" . "#FF34B3") 775 | ("maroon2" . "#EE30A7") 776 | ("maroon3" . "#CD2990") 777 | ("maroon4" . "#8B1C62") 778 | ("mediumaquamarine" . "#66CDAA") 779 | ("mediumblue" . "#0000CD") 780 | ("mediumorchid" . "#BA55D3") 781 | ("mediumorchid1" . "#E066FF") 782 | ("mediumorchid2" . "#D15FEE") 783 | ("mediumorchid3" . "#B452CD") 784 | ("mediumorchid4" . "#7A378B") 785 | ("mediumpurple" . "#9370DB") 786 | ("mediumpurple1" . "#AB82FF") 787 | ("mediumpurple2" . "#9F79EE") 788 | ("mediumpurple3" . "#8968CD") 789 | ("mediumpurple4" . "#5D478B") 790 | ("mediumseagreen" . "#3CB371") 791 | ("mediumslateblue" . "#7B68EE") 792 | ("mediumspringgreen" . "#00FA9A") 793 | ("mediumturquoise" . "#48D1CC") 794 | ("mediumvioletred" . "#C71585") 795 | ("midnightblue" . "#191970") 796 | ("mintcream" . "#F5FFFA") 797 | ("mistyrose" . "#FFE4E1") 798 | ("mistyrose1" . "#FFE4E1") 799 | ("mistyrose2" . "#EED5D2") 800 | ("mistyrose3" . "#CDB7B5") 801 | ("mistyrose4" . "#8B7D7B") 802 | ("moccasin" . "#FFE4B5") 803 | ("navajowhite" . "#FFDEAD") 804 | ("navajowhite1" . "#FFDEAD") 805 | ("navajowhite2" . "#EECFA1") 806 | ("navajowhite3" . "#CDB38B") 807 | ("navajowhite4" . "#8B795E") 808 | ("navy" . "#000080") 809 | ("navyblue" . "#000080") 810 | ("oldlace" . "#FDF5E6") 811 | ("olivedrab" . "#6B8E23") 812 | ("olivedrab1" . "#C0FF3E") 813 | ("olivedrab2" . "#B3EE3A") 814 | ("olivedrab3" . "#9ACD32") 815 | ("olivedrab4" . "#698B22") 816 | ("orange" . "#FFA500") 817 | ("orange1" . "#FFA500") 818 | ("orange2" . "#EE9A00") 819 | ("orange3" . "#CD8500") 820 | ("orange4" . "#8B5A00") 821 | ("orangered" . "#FF4500") 822 | ("orangered1" . "#FF4500") 823 | ("orangered2" . "#EE4000") 824 | ("orangered3" . "#CD3700") 825 | ("orangered4" . "#8B2500") 826 | ("orchid" . "#DA70D6") 827 | ("orchid1" . "#FF83FA") 828 | ("orchid2" . "#EE7AE9") 829 | ("orchid3" . "#CD69C9") 830 | ("orchid4" . "#8B4789") 831 | ("palegoldenrod" . "#EEE8AA") 832 | ("palegreen" . "#98FB98") 833 | ("palegreen1" . "#9AFF9A") 834 | ("palegreen2" . "#90EE90") 835 | ("palegreen3" . "#7CCD7C") 836 | ("palegreen4" . "#548B54") 837 | ("paleturquoise" . "#AFEEEE") 838 | ("paleturquoise1" . "#BBFFFF") 839 | ("paleturquoise2" . "#AEEEEE") 840 | ("paleturquoise3" . "#96CDCD") 841 | ("paleturquoise4" . "#668B8B") 842 | ("palevioletred" . "#DB7093") 843 | ("palevioletred1" . "#FF82AB") 844 | ("palevioletred2" . "#EE799F") 845 | ("palevioletred3" . "#CD6889") 846 | ("palevioletred4" . "#8B475D") 847 | ("papayawhip" . "#FFEFD5") 848 | ("peachpuff" . "#FFDAB9") 849 | ("peachpuff1" . "#FFDAB9") 850 | ("peachpuff2" . "#EECBAD") 851 | ("peachpuff3" . "#CDAF95") 852 | ("peachpuff4" . "#8B7765") 853 | ("peru" . "#CD853F") 854 | ("pink" . "#FFC0CB") 855 | ("pink1" . "#FFB5C5") 856 | ("pink2" . "#EEA9B8") 857 | ("pink3" . "#CD919E") 858 | ("pink4" . "#8B636C") 859 | ("plum" . "#DDA0DD") 860 | ("plum1" . "#FFBBFF") 861 | ("plum2" . "#EEAEEE") 862 | ("plum3" . "#CD96CD") 863 | ("plum4" . "#8B668B") 864 | ("powderblue" . "#B0E0E6") 865 | ("purple" . "#A020F0") 866 | ("purple1" . "#9B30FF") 867 | ("purple2" . "#912CEE") 868 | ("purple3" . "#7D26CD") 869 | ("purple4" . "#551A8B") 870 | ("red" . "#FF0000") 871 | ("red1" . "#FF0000") 872 | ("red2" . "#EE0000") 873 | ("red3" . "#CD0000") 874 | ("red4" . "#8B0000") 875 | ("rosybrown" . "#BC8F8F") 876 | ("rosybrown1" . "#FFC1C1") 877 | ("rosybrown2" . "#EEB4B4") 878 | ("rosybrown3" . "#CD9B9B") 879 | ("rosybrown4" . "#8B6969") 880 | ("royalblue" . "#4169E1") 881 | ("royalblue1" . "#4876FF") 882 | ("royalblue2" . "#436EEE") 883 | ("royalblue3" . "#3A5FCD") 884 | ("royalblue4" . "#27408B") 885 | ("saddlebrown" . "#8B4513") 886 | ("salmon" . "#FA8072") 887 | ("salmon1" . "#FF8C69") 888 | ("salmon2" . "#EE8262") 889 | ("salmon3" . "#CD7054") 890 | ("salmon4" . "#8B4C39") 891 | ("sandybrown" . "#F4A460") 892 | ("seagreen" . "#2E8B57") 893 | ("seagreen1" . "#54FF9F") 894 | ("seagreen2" . "#4EEE94") 895 | ("seagreen3" . "#43CD80") 896 | ("seagreen4" . "#2E8B57") 897 | ("seashell" . "#FFF5EE") 898 | ("seashell1" . "#FFF5EE") 899 | ("seashell2" . "#EEE5DE") 900 | ("seashell3" . "#CDC5BF") 901 | ("seashell4" . "#8B8682") 902 | ("sienna" . "#A0522D") 903 | ("sienna1" . "#FF8247") 904 | ("sienna2" . "#EE7942") 905 | ("sienna3" . "#CD6839") 906 | ("sienna4" . "#8B4726") 907 | ("skyblue" . "#87CEEB") 908 | ("skyblue1" . "#87CEFF") 909 | ("skyblue2" . "#7EC0EE") 910 | ("skyblue3" . "#6CA6CD") 911 | ("skyblue4" . "#4A708B") 912 | ("slateblue" . "#6A5ACD") 913 | ("slateblue1" . "#836FFF") 914 | ("slateblue2" . "#7A67EE") 915 | ("slateblue3" . "#6959CD") 916 | ("slateblue4" . "#473C8B") 917 | ("slategray" . "#708090") 918 | ("slategray1" . "#C6E2FF") 919 | ("slategray2" . "#B9D3EE") 920 | ("slategray3" . "#9FB6CD") 921 | ("slategray4" . "#6C7B8B") 922 | ("slategrey" . "#708090") 923 | ("snow" . "#FFFAFA") 924 | ("snow1" . "#FFFAFA") 925 | ("snow2" . "#EEE9E9") 926 | ("snow3" . "#CDC9C9") 927 | ("snow4" . "#8B8989") 928 | ("springgreen" . "#00FF7F") 929 | ("springgreen1" . "#00FF7F") 930 | ("springgreen2" . "#00EE76") 931 | ("springgreen3" . "#00CD66") 932 | ("springgreen4" . "#008B45") 933 | ("steelblue" . "#4682B4") 934 | ("steelblue1" . "#63B8FF") 935 | ("steelblue2" . "#5CACEE") 936 | ("steelblue3" . "#4F94CD") 937 | ("steelblue4" . "#36648B") 938 | ("tan" . "#D2B48C") 939 | ("tan1" . "#FFA54F") 940 | ("tan2" . "#EE9A49") 941 | ("tan3" . "#CD853F") 942 | ("tan4" . "#8B5A2B") 943 | ("thistle" . "#D8BFD8") 944 | ("thistle1" . "#FFE1FF") 945 | ("thistle2" . "#EED2EE") 946 | ("thistle3" . "#CDB5CD") 947 | ("thistle4" . "#8B7B8B") 948 | ("tomato" . "#FF6347") 949 | ("tomato1" . "#FF6347") 950 | ("tomato2" . "#EE5C42") 951 | ("tomato3" . "#CD4F39") 952 | ("tomato4" . "#8B3626") 953 | ("turquoise" . "#40E0D0") 954 | ("turquoise1" . "#00F5FF") 955 | ("turquoise2" . "#00E5EE") 956 | ("turquoise3" . "#00C5CD") 957 | ("turquoise4" . "#00868B") 958 | ("violet" . "#EE82EE") 959 | ("violetred" . "#D02090") 960 | ("violetred1" . "#FF3E96") 961 | ("violetred2" . "#EE3A8C") 962 | ("violetred3" . "#CD3278") 963 | ("violetred4" . "#8B2252") 964 | ("wheat" . "#F5DEB3") 965 | ("wheat1" . "#FFE7BA") 966 | ("wheat2" . "#EED8AE") 967 | ("wheat3" . "#CDBA96") 968 | ("wheat4" . "#8B7E66") 969 | ("whitesmoke" . "#F5F5F5") 970 | ("yellow" . "#FFFF00") 971 | ("yellow1" . "#FFFF00") 972 | ("yellow2" . "#EEEE00") 973 | ("yellow3" . "#CDCD00") 974 | ("yellow4" . "#8B8B00") 975 | ("yellowgreen" . "#9ACD32")) 976 | "Alist of R colors. 977 | Each entry should have the form (COLOR-NAME . HEXADECIMAL-COLOR)." 978 | :group 'rainbow) 979 | (defcustom rainbow-r-colors-major-mode-list 980 | '(ess-mode) 981 | "List of major mode where R colors are enabled when 982 | `rainbow-r-colors' is set to auto." 983 | :group 'rainbow) 984 | 985 | (defcustom rainbow-r-colors 'auto 986 | "When to enable R colors. 987 | If set to t, the R colors will be enabled. If set to nil, the 988 | R colors will not be enabled. If set to auto, the R colors 989 | will be enabled if a major mode has been detected from the 990 | `rainbow-r-colors-major-mode-list'." 991 | :group 'rainbow) 992 | 993 | 994 | ;; Functions 995 | (defun rainbow-colorize-match (color &optional match) 996 | "Return a matched string propertized with a face whose 997 | background is COLOR. The foreground is computed using 998 | `rainbow-color-luminance', and is either white or black." 999 | (let ((match (or match 0))) 1000 | (put-text-property 1001 | (match-beginning match) (match-end match) 1002 | 'face `((:foreground ,(if (> 0.5 (rainbow-x-color-luminance color)) 1003 | "white" "black")) 1004 | (:background ,color))))) 1005 | 1006 | (defun rainbow-colorize-itself (&optional match) 1007 | "Colorize a match with itself." 1008 | (rainbow-colorize-match (match-string-no-properties (or match 0)) match)) 1009 | 1010 | (defun rainbow-colorize-hexadecimal-without-sharp () 1011 | "Colorize an hexadecimal colors and prepend # to it." 1012 | (rainbow-colorize-match (concat "#" (match-string-no-properties 1)))) 1013 | 1014 | (defun rainbow-colorize-by-assoc (assoc-list) 1015 | "Colorize a match with its association from ASSOC-LIST." 1016 | (rainbow-colorize-match (cdr (assoc-string (match-string-no-properties 0) 1017 | assoc-list t)))) 1018 | 1019 | (defun rainbow-rgb-relative-to-absolute (number) 1020 | "Convert a relative NUMBER to absolute. If NUMBER is absolute, return NUMBER. 1021 | This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"." 1022 | (let ((string-length (- (length number) 1))) 1023 | ;; Is this a number with %? 1024 | (if (eq (elt number string-length) ?%) 1025 | (/ (* (string-to-number (substring number 0 string-length)) 255) 100) 1026 | (string-to-number number)))) 1027 | 1028 | (defun rainbow-colorize-hsl () 1029 | "Colorize a match with itself." 1030 | (let ((h (/ (string-to-number (match-string-no-properties 1)) 360.0)) 1031 | (s (/ (string-to-number (match-string-no-properties 2)) 100.0)) 1032 | (l (/ (string-to-number (match-string-no-properties 3)) 100.0))) 1033 | (rainbow-colorize-match 1034 | (multiple-value-bind (r g b) 1035 | (color-hsl-to-rgb h s l) 1036 | (format "#%02X%02X%02X" (* r 255) (* g 255) (* b 255)))))) 1037 | 1038 | (defun rainbow-colorize-rgb () 1039 | "Colorize a match with itself." 1040 | (let ((r (rainbow-rgb-relative-to-absolute (match-string-no-properties 1))) 1041 | (g (rainbow-rgb-relative-to-absolute (match-string-no-properties 2))) 1042 | (b (rainbow-rgb-relative-to-absolute (match-string-no-properties 3)))) 1043 | (rainbow-colorize-match (format "#%02X%02X%02X" r g b)))) 1044 | 1045 | (defun rainbow-colorize-rgb-float () 1046 | "Colorize a match with itself, with relative value." 1047 | (let ((r (* (string-to-number (match-string-no-properties 1)) 255.0)) 1048 | (g (* (string-to-number (match-string-no-properties 2)) 255.0)) 1049 | (b (* (string-to-number (match-string-no-properties 3)) 255.0))) 1050 | (rainbow-colorize-match (format "#%02X%02X%02X" r g b)))) 1051 | 1052 | (defun rainbow-colorize-ansi () 1053 | "Return a matched string propertized with ansi color face." 1054 | (let ((xterm-color? (featurep 'xterm-color)) 1055 | (string (match-string-no-properties 0)) 1056 | color) 1057 | (save-match-data 1058 | (let* ((replaced (concat 1059 | (replace-regexp-in-string 1060 | "^\\(\\\\[eE]\\|\\\\033\\|\\\\x1[bB]\\)" 1061 | "\033" string) "x")) 1062 | xterm-color-current 1063 | ansi-color-context 1064 | (applied (funcall (if xterm-color? 1065 | 'xterm-color-filter 1066 | 'ansi-color-apply) 1067 | replaced)) 1068 | (face-property (get-text-property 1069 | 0 1070 | (if xterm-color? 'face 'font-lock-face) 1071 | applied))) 1072 | (unless (listp (car face-property)) 1073 | (setq face-property (list face-property))) 1074 | (setq color (funcall (if xterm-color? 'cadr 'cdr) 1075 | (or (assq (if xterm-color? 1076 | :foreground 1077 | 'foreground-color) 1078 | face-property) 1079 | (assq (if xterm-color? 1080 | :background 1081 | 'background-color) 1082 | face-property)))))) 1083 | (when color 1084 | (rainbow-colorize-match color)))) 1085 | 1086 | (defun rainbow-color-luminance (red green blue) 1087 | "Calculate the luminance of color composed of RED, BLUE and GREEN. 1088 | Return a value between 0 and 1." 1089 | (/ (+ (* .2126 red) (* .7152 green) (* .0722 blue)) 256)) 1090 | 1091 | (defun rainbow-x-color-luminance (color) 1092 | "Calculate the luminance of a color string (e.g. \"#ffaa00\", \"blue\"). 1093 | Return a value between 0 and 1." 1094 | (let* ((values (x-color-values color)) 1095 | (r (/ (car values) 256.0)) 1096 | (g (/ (cadr values) 256.0)) 1097 | (b (/ (caddr values) 256.0))) 1098 | (rainbow-color-luminance r g b))) 1099 | 1100 | (defun rainbow-turn-on () 1101 | "Turn on raibow-mode." 1102 | (font-lock-add-keywords nil 1103 | rainbow-hexadecimal-colors-font-lock-keywords) 1104 | ;; Activate X colors? 1105 | (when (or (eq rainbow-x-colors t) 1106 | (and (eq rainbow-x-colors 'auto) 1107 | (memq major-mode rainbow-x-colors-major-mode-list))) 1108 | (font-lock-add-keywords nil 1109 | rainbow-x-colors-font-lock-keywords)) 1110 | ;; Activate LaTeX colors? 1111 | (when (or (eq rainbow-latex-colors t) 1112 | (and (eq rainbow-latex-colors 'auto) 1113 | (memq major-mode rainbow-latex-colors-major-mode-list))) 1114 | (font-lock-add-keywords nil 1115 | rainbow-latex-rgb-colors-font-lock-keywords)) 1116 | ;; Activate ANSI colors? 1117 | (when (or (eq rainbow-ansi-colors t) 1118 | (and (eq rainbow-ansi-colors 'auto) 1119 | (memq major-mode rainbow-ansi-colors-major-mode-list))) 1120 | (font-lock-add-keywords nil 1121 | rainbow-ansi-colors-font-lock-keywords)) 1122 | ;; Activate HTML colors? 1123 | (when (or (eq rainbow-html-colors t) 1124 | (and (eq rainbow-html-colors 'auto) 1125 | (memq major-mode rainbow-html-colors-major-mode-list))) 1126 | (setq rainbow-html-colors-font-lock-keywords 1127 | `((,(regexp-opt (mapcar 'car rainbow-html-colors-alist) 'words) 1128 | (0 (rainbow-colorize-by-assoc rainbow-html-colors-alist))))) 1129 | (font-lock-add-keywords nil 1130 | `(,@rainbow-html-colors-font-lock-keywords 1131 | ,@rainbow-html-rgb-colors-font-lock-keywords))) 1132 | ;; Activate R colors? 1133 | (when (or (eq rainbow-r-colors t) 1134 | (and (eq rainbow-r-colors 'auto) 1135 | (memq major-mode rainbow-r-colors-major-mode-list))) 1136 | (setq rainbow-r-colors-font-lock-keywords 1137 | `((,(regexp-opt (mapcar 'car rainbow-r-colors-alist) 'words) 1138 | (0 (rainbow-colorize-by-assoc rainbow-r-colors-alist))))) 1139 | (font-lock-add-keywords nil 1140 | rainbow-r-colors-font-lock-keywords 1141 | ))) 1142 | 1143 | (defun rainbow-turn-off () 1144 | "Turn off rainbow-mode." 1145 | (font-lock-remove-keywords 1146 | nil 1147 | `(,@rainbow-hexadecimal-colors-font-lock-keywords 1148 | ,@rainbow-x-colors-font-lock-keywords 1149 | ,@rainbow-latex-rgb-colors-font-lock-keywords 1150 | ,@rainbow-r-colors-font-lock-keywords 1151 | ,@rainbow-html-colors-font-lock-keywords 1152 | ,@rainbow-html-rgb-colors-font-lock-keywords))) 1153 | 1154 | ;;;###autoload 1155 | (define-minor-mode rainbow-mode 1156 | "Colorize strings that represent colors. 1157 | This will fontify with colors the string like \"#aabbcc\" or \"blue\"." 1158 | :lighter " Rbow" 1159 | (progn 1160 | (if rainbow-mode 1161 | (rainbow-turn-on) 1162 | (rainbow-turn-off)))) 1163 | 1164 | (provide 'rainbow-mode) 1165 | 1166 | ;;; rainbow-mode.el ends here 1167 | --------------------------------------------------------------------------------