Skip to content

Instantly share code, notes, and snippets.

View JNRowe's full-sized avatar

James Rowe JNRowe

View GitHub Profile
@JNRowe
JNRowe / vimrc
Created December 17, 2009 19:44
autocmd FileType taglist setlocal nospell |
\ setlocal statusline=%f |
\ setlocal nofoldenable |
\ setlocal foldcolumn=0
>>> from dateutil import parser
>>> s = '2009 10 30 23:35:16+0400'
>>> parser.parse(s)
datetime.datetime(2009, 10, 30, 23, 35, 16, tzinfo=tzoffset(None, 14400))
>>> from pyparsing import (Literal, White, Word, alphas, nums)
>>> matcher = Word(alphas) + Word(nums) + Literal('\\') + Word(alphas) + White()
>>> matcher.parseString('make 123\\match ')
(['make', '123', '\\', 'match', ' '], {})
>>> re.findall(r' (\d+\\\w+) ', 'make 123\match ', re.DEBUG|re.LOCALE)
literal 32
subpattern 1
max_repeat 1 65535
in
category category_digit
literal 92
max_repeat 1 65535
in
category category_word
>>> re.findall(' ([0-9]+\\[a-z]+) ', 'make 123\match ', re.DEBUG)
literal 32
subpattern 1
max_repeat 1 65535
in
range (48, 57)
literal 91
literal 97
literal 45
literal 122
>>> import re
>>> re.findall(' ([0-9]+\\[a-z]+) ', 'make 123\match ')
[]
>>> # Whereas with raw strings this match will work
>>> re.findall(r' ([0-9]+\\[a-z]+) ', 'make 123\match ')
['123\\match']
autoload -U add-zsh-hook
autoload -Uz vcs_info
zstyle ':vcs_info:*' actionformats \
'%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats \
'%F{2}%s%F{7}:%F{2}(%F{1}%b%F{2})%f '
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
zstyle ':vcs_info:*' enable git
autoload -U add-zsh-hook
autoload -Uz vcs_info
zstyle ':vcs_info:*' actionformats \
'%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats \
'%F{2}%s%F{7}:%F{2}(%F{1}%b%F{2})%f '
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
zstyle ':vcs_info:*' enable git
add-zsh-hook precmd prompt_jnrowe_precmd
prompt_jnrowe_precmd () {
vcs_info
if [ "${vcs_info_msg_0_}" = "" ]; then
dir_status="%F{2}→%f"
elif [[ $(git cached --name-status 2>/dev/null ) != "" ]]; then
dir_status="%F{1}▶%f"
elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
autoload -Uz vcs_info
# See the documentation for the format string definition
# This generates a fancy coloured string with $vcs:($branch)
zstyle ':vcs_info:*' formats '%F{2}%s%F{7}:%F{2}(%F{1}%b%F{2})%f '
zstyle ':vcs_info:*' enable git hg