Skip to content

Commit

Permalink
Merge branch 'all' of github.com:lvii/home into all
Browse files Browse the repository at this point in the history
  • Loading branch information
lvii committed Jun 15, 2011
2 parents 7302d70 + 8d2624c commit bd8c79a
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 30 deletions.
195 changes: 169 additions & 26 deletions .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,144 @@ if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

source $HOME/.alias
if [ -f $HOME/.alias ]; then
source $HOME/.alias
fi

# 为执行时间比较长的命令添加别名,如: sleep 10; alert
# 依赖于 libnotify-bin 软件包
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# 原生的 git 分支提示
#PS1='[\u@\h`__git_ps1` \W]\$ '

## [ bash git branch prompt ]#{{{
##--------------------------------------------
## http://nuts-and-bolts-of-cakephp.com/2010/11/27/show-git-branch-in-your-bash-prompt/
#
##showing git branches in bash prompt
#function parse_git_branch {
# git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
#}
#
#function proml {
# local RED="\[\033[0;31m\]"
# local LIGHT_RED="\[\033[1;31m\]"
# local YELLOW="\[\033[0;33m\]"
# local LIGHT_GREEN="\[\033[1;32m\]"
# local WHITE="\[\033[1;37m\]"
# local LIGHT_GRAY="\[\033[0;37m\]"
# local LIGHT_PURPLE="\[\033[1;34m\]"
# case $TERM in
# xterm*)
# TITLEBAR='\[\033]0;\u@\h:\w\007\]'
# ;;
# *)
# TITLEBAR=""
# ;;
# esac
#
#PS1="${TITLEBAR}\
#$LIGHT_PURPLE\w$YELLOW\$(parse_git_branch)\
#\n$LIGHT_GRAY\$ "
#PS2='> '
#PS4='+ '
#}
#proml
#
##}}}

# [ 色块 color 标记 git 状态 ]#{{{
#--------------------------------------------
# Colorful bash prompt reflecting Git status
# From : http://opinionated-programmer.com/2011/01/colorful-bash-prompt-reflecting-git-status/

function _git_prompt() {
local git_status="`git status -unormal 2>&1`"
if ! [[ "$git_status" =~ Not\ a\ git\ repo ]]; then
if [[ "$git_status" =~ nothing\ to\ commit ]]; then
local ansi=42
elif [[ "$git_status" =~ nothing\ added\ to\ commit\ but\ untracked\ files\ present ]]; then
local ansi=43
else
local ansi=45
fi
if [[ "$git_status" =~ On\ branch\ ([^[:space:]]+) ]]; then
branch=${BASH_REMATCH[1]}
test "$branch" != master || branch=' '
else
# Detached HEAD. (branch=HEAD is a faster alternative.)
branch="(`git describe --all --contains --abbrev=4 HEAD 2> /dev/null ||
echo HEAD`)"
fi
echo -n '\[\e[0;37;'"$ansi"';1m\]'"$branch"'\[\e[0m\] '
fi
}
function _prompt_command() {
PS1="`_git_prompt`"'\[\e[1;34m\]\w \n \$\[\e[0m\] '
}
PROMPT_COMMAND=_prompt_command

#}}}

## [ bash git 箭头 / 雷电字符 ]#{{{
##--------------------------------------------
## From : https://gist.github.com/634750
## From : https://gist.github.com/738048
#
# RED="\[\033[0;31m\]"
# YELLOW="\[\033[0;33m\]"
# GREEN="\[\033[0;32m\]"
# BLUE="\[\033[0;34m\]"
# LIGHT_RED="\[\033[1;31m\]"
#LIGHT_GREEN="\[\033[1;32m\]"
# WHITE="\[\033[1;37m\]"
# LIGHT_GRAY="\[\033[0;37m\]"
# COLOR_NONE="\[\e[0m\]"
#
#function parse_git_branch {
#
# git rev-parse --git-dir &> /dev/null
# git_status="$(git status 2> /dev/null)"
# branch_pattern="^# On branch ([^${IFS}]*)"
# remote_pattern="# Your branch is (.*) of"
# diverge_pattern="# Your branch and (.*) have diverged"
# if [[ ! ${git_status}} =~ "working directory clean" ]]; then
#state="${RED}⚡"
# fi
# # add an else if or two here if you want to get more specific
# if [[ ${git_status} =~ ${remote_pattern} ]]; then
#if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then
#remote="${YELLOW}↑"
# else
#remote="${YELLOW}↓"
# fi
#fi
#if [[ ${git_status} =~ ${diverge_pattern} ]]; then
#remote="${YELLOW}↕"
# fi
#if [[ ${git_status} =~ ${branch_pattern} ]]; then
#branch=${BASH_REMATCH[1]}
# echo " (${branch})${remote}${state}"
# fi
#}
#
#function prompt_func() {
# previous_return_value=$?;
# prompt="${TITLEBAR}${BLUE}[${LIGHT_GRAY}\w${GREEN}$(parse_git_branch)${BLUE}]${COLOR_NONE} "
# if test $previous_return_value -eq 0
# then
#PS1="${prompt}➔ "
# else
#PS1="${prompt}${RED}➔${COLOR_NONE} "
# fi
#}
#
## XXX 和下面 tmux / screen 标题栏 定义的 PROMPT_COMMAND 冲突
#PROMPT_COMMAND=prompt_func
#
##}}}
#
# [ PS1 color style ]# {{{
#--------------------------------------------

Expand All @@ -13,7 +149,7 @@ source $HOME/.alias

# 换行 绝对路径
#PS1='\[\033[1;32m\]\u @ \[\033[1;34m\]\w \[\033[1;33m\][ \d \t ] \n[ h:\! l:\# ]\[\033[1;31m\] $ \[\033[0;39m\]'
PS1='\[\033[1;32m\]\u @ \[\033[1;34m\]\w \[\033[1;33m\] \n\[\033[1;31m\] $ \[\033[0;39m\]'
#PS1='\[\033[1;32m\]\u @ \[\033[1;34m\]\w \[\033[1;33m\] \n\[\033[1;31m\] $ \[\033[0;39m\]'

# 用户名 只在右上角
#PS1="\[\e[1;31m\] \W \$ \[\e[s\]\[\e[1;\$((COLUMNS-5))f\]\[\e[1;32m\]\$(whoami)\[\e[u\]\[\e[0m\]"
Expand Down Expand Up @@ -99,29 +235,29 @@ export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
# export PROMPT_COMMAND
# fi

#alias tmux='tmux -2 ' # 256 colors
# xterm urxvt 256 color [tmux]
export TERM=xterm-256color

# xterm title 标题栏,PROMPT_COMMAND 会在 PS1 随执行,报警声,bell
case $TERM in
xterm*)
PROMPT_COMMAND='echo -ne "\033]0;xterm -> ${PWD}\007"'
export PROMPT_COMMAND
;;
#screen*)
# # 以下为 自定义 变量
# PATHTITLE='\[\ek\W\e\\\]'
# PROGRAMTITLE='\[\ek\e\\\]'
# PS1="${PROGRAMTITLE}${PATHTITLE}${PS1}"
# ;;
rxvt)
PROMPT_COMMAND='echo -ne "\033]0;urxvt : ${PWD}\007"'
export PROMPT_COMMAND
;;
*)
;;
esac
##alias tmux='tmux -2 ' # 256 colors
## xterm urxvt 256 color [tmux]
#export TERM=xterm-256color
#
## xterm title 标题栏,PROMPT_COMMAND 会在 PS1 随执行,报警声,bell
#case $TERM in
# xterm*)
# PROMPT_COMMAND='echo -ne "\033]0;xterm -> ${PWD}\007"'
# export PROMPT_COMMAND
# ;;
# #screen*)
# # # 以下为 自定义 变量
# # PATHTITLE='\[\ek\W\e\\\]'
# # PROGRAMTITLE='\[\ek\e\\\]'
# # PS1="${PROGRAMTITLE}${PATHTITLE}${PS1}"
# # ;;
# rxvt)
# PROMPT_COMMAND='echo -ne "\033]0;urxvt : ${PWD}\007"'
# export PROMPT_COMMAND
# ;;
# *)
# ;;
#esac



Expand All @@ -144,9 +280,16 @@ esac

#--------------------------------------------

# 去除重复历史记录。bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace

# append to the history file, don't overwrite it
shopt -s histappend

# HISTSIZE 控制历史命令记录的总行数,默认 500
export HISTSIZE=1000
export HISTFILESIZE=1000
export HISTFILESIZE=2000

# 禁用 history,,将 HISTSIZE 设置为 0
#export HISTSIZE=0
Expand Down
12 changes: 9 additions & 3 deletions .mutt/muttrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
# [ path 路径 ]# {{{
#--------------------------------------------

# [ 路径相关选项 ]
#--------------------------------------------
#set certificate_file
#set header_cache
#set message_cachedir

set mbox_type=Maildir

#move mail from spool to mailbox when quiting ?
Expand Down Expand Up @@ -85,7 +91,7 @@ set imap_user=guodong
set [email protected]

set ssl_force_tls=yes
set certificate_file=${HOME}/.mutt/certificates
set certificate_file=${HOME}/.me/mutt.certificates

## IMAP settings
# allow mutt to open new imap connection automatically
Expand Down Expand Up @@ -133,8 +139,8 @@ source ${HOME}/.me/gmail.offlineimap
# From : http://www.fwolf.com/blog/post/306
# 指定的是一个目录,这样每个邮件目录都会在这个目录下建立一个缓存文件
# 也可以直接指定一个独立的文件, 打开有几千封邮件的文件夹的时候,都要花费时间建立索引、排序
set header_cache="~/mail/cache/"
set message_cachedir=${HOME}/.mutt/cache/
set header_cache="~/.mail/cache/head"
set message_cachedir=${HOME}/.mail/cache/message

# [?] 编辑邮件时,vim 临时文件存放位置
#set tmpdir=${HOME}/mail/tmp
Expand Down
3 changes: 2 additions & 1 deletion .screenrc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'

# 0.05 0.05 0.05 | 0 ~ 1 /tmp [ 2 top ] 05/21 16:10
#caption always "%{=b k}%{c} %l | %{k}%L=%-w%7>%{g}[ %n %t ]%{-}%+w%-014< %-012=%{b y}%m/%d %c "
caption always "%{=b k}%{c} %l | %{k}%L=%-w%7>%{g}%n %t%{-}%+w%-014< %-012=%{b y}%m/%d %c "
#caption always "%{=b k}%{c} %l | %{k}%L=%-w%7>%{g}%n %t%{-}%+w%-014< %-012=%{b y}%m/%d %c "
caption always "%{=b k}%{b y} %m-%d %c | %{k}%L=%-w%7>%{g}%n %t%{-}%+w%-014< %-016=%{c} %l "

# %{k}%L=%-w%7
# 背景色黑色 左对齐 窗口标题 7像素宽
Expand Down

0 comments on commit bd8c79a

Please sign in to comment.