Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
number23
committed
Oct 6, 2010
1 parent
8ebf0e6
commit ef57de8
Showing
8 changed files
with
350 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
#! /usr/bin/env zsh | ||
|
||
##if test -x =dircolors; then | ||
## eval "`dircolors`" | ||
## export LS_COLORS="*.ogm=01;35:${LS_COLORS}" | ||
## export ZLS_COLORS=$LS_COLORS | ||
##fi | ||
|
||
autoload -U is-at-least | ||
|
||
#[ a ]########################################################################## | ||
setopt aliases # expand aliases | ||
setopt auto_continue # send SIGCONT to jobs disowned | ||
setopt auto_list # list choice on ambiguous command | ||
setopt auto_menu # show menu for completion | ||
setopt no_autoname_dirs # after foo=/absolute/path, ~foo may expand to | ||
# /absolute/path, but `%~' in prompt won't give | ||
# `~foo' until `~foo' has been used (rtfm closely) | ||
setopt auto_param_keys # remove trailing spaces after completion if needed | ||
setopt auto_param_slash # add slash for directories | ||
setopt auto_pushd # cd = pushd | ||
setopt auto_remove_slash # remove slash on dirs if word separator added | ||
setopt auto_resume # simgle word resume if possible | ||
|
||
#[ b ]########################################################################## | ||
setopt bad_pattern # warn on bad file patterns | ||
setopt bang_hist # yeah ! expansion | ||
setopt bare_glob_qual # () is quaifier list | ||
setopt no_bash_auto_list # auto_list is sufficient, i want it on first tab | ||
setopt beep # beep me o yeah | ||
setopt no_bg_nice # don't renice jobs in bg | ||
setopt brace_ccl # expand of {adasd} | ||
setopt no_bsd_echo # dont want BSD echo compat | ||
|
||
#[ c ]########################################################################## | ||
setopt case_glob # case sensitive globbing | ||
setopt c_bases # understand 12#120 as 120 in base 12 | ||
setopt no_cdable_vars # dont add ~ automagically | ||
setopt no_chase_dots # foo/bar/.. is foo/ even if bar is a symlink | ||
setopt chase_links # cd to a symlink is in fact cd to the true dir | ||
setopt check_jobs # check jobs on exit | ||
setopt clobber # redirection can create files | ||
setopt complete_aliases # dont replace alias before completion | ||
setopt complete_in_word # we want completion to be done from cursor in word | ||
setopt correct # try to correct command line | ||
setopt no_correct_all # don't coorect args | ||
setopt no_csh_junkiehistory # csh sucks | ||
setopt no_csh_junkie_loops # want do /list/; done | ||
setopt no_csh_junkie_quotes # csh quote rules sucks too | ||
setopt no_csh_nullcmd # want to keep my (READ)?NULLCMD settings | ||
setopt no_csh_null_glob # don't erase not matched globs silently | ||
|
||
#[ d-g ]######################################################################## | ||
setopt no_dvorak # use only regular (qw|az)erty | ||
setopt no_emacs # use rather bindkeys that builtin | ||
setopt equals # perform = file expansions | ||
setopt no_err_exit # don't weant to see exit status even if nonzero | ||
setopt no_err_return # no return from a function with non 0 ending cmds | ||
setopt exec # sure we want to exec commands | ||
setopt extended_glob # #,~,^ expansion | ||
setopt no_extended_history # regular history | ||
setopt no_flow_control # ignore ^S/^Q | ||
setopt function_argzero # $0 == name of script | ||
setopt glob # sure i want globbing | ||
setopt no_global_export # local vars are not globals one | ||
setopt global_rcs # use global rcs | ||
setopt no_glob_assign # no globbing on foo=*, use foo=(*) | ||
setopt no_glob_complete # don't generate matches and cycle through them | ||
setopt no_glob_dots # not require . in filename to be match explicitely | ||
setopt no_glob_subst # no recursive expansion | ||
|
||
#[ h-j ]######################################################################## | ||
setopt hash_cmds # do not always search through path, hash cmds | ||
setopt hash_dirs # hash directories holding commands too | ||
setopt hash_list_all # verify path hash on completion | ||
setopt hist_allow_clobber # add | to redirections in history | ||
setopt no_hist_beep # don't beep on history expansion errors | ||
setopt hist_find_no_dups # don't show dups even if not contiguous | ||
setopt hist_ignore_all_dups # ignore all -- even non contiguous -- dups | ||
setopt no_hist_ignore_space # historify commands with spaces too | ||
setopt hist_no_functions # don't save functions defs in history | ||
setopt hist_no_store # remove hists access cmds from hist | ||
setopt hist_reduce_blanks # remove superfluous blanks | ||
setopt hist_save_no_dups # no dups on history saving | ||
setopt hist_verify # some expansion gadget | ||
setopt no_hup # don't SIGHUP bg cmds on logout | ||
setopt no_ignore_braces # do braces expansion | ||
setopt no_ignore_eof # don't ignore ^D | ||
setopt no_inc_appendhistory # dont' append incrementally | ||
setopt interactive_comments # allow comments in interactive shell | ||
|
||
#[ k-o ]######################################################################## | ||
setopt no_ksh_arrays # don't emulate ksh arrays | ||
setopt no_ksh_autoload # don't do some dark autoload on function call | ||
setopt no_ksh_glob # ignore @ before () | ||
setopt ksh_option_print # modify setopt output | ||
setopt no_ksh_typeset # use zsh typeset | ||
setopt list_ambiguous # unambiguous prefix completion is done silently | ||
setopt no_list_beep # don't beep for completion | ||
setopt list_packed # different width for completion | ||
setopt no_list_rows_first # sort by colums | ||
setopt list_types # show types of listing files | ||
setopt long_list_jobs # list jobs in long format | ||
setopt magic_equal_subst # foo= is file expanded | ||
setopt no_mail_warning # auto-explained | ||
setopt mark_dirs # adds / on dirs in filename completion | ||
setopt no_menu_complete # don't show menu on ambiguous completion | ||
setopt monitor # job control | ||
setopt multios # multi redirection allowed | ||
setopt nomatch # print error on non matched patterns | ||
setopt notify # notify immediately, not on next prompt | ||
setopt no_null_glob # don't delete not matched globs | ||
setopt numeric_glob_sort # sort in numeric order rather than lexicographic | ||
setopt no_octal_zeroes # 010 = 9 sucks | ||
setopt no_overstrike # dont start le in overstrike mode | ||
|
||
#[ p-r ]######################################################################## | ||
setopt path_dirs # search in path even if cmd has '/' in it | ||
setopt no_posix_builtins # yeah don't like posix, i'm a rebel | ||
setopt print_eight_bit # just to be sure | ||
setopt no_prompt_bang # dont perform history expansion in prompt | ||
setopt no_prompt_cr # don'tprint <cr> before prompt ---> see precmd ! | ||
setopt prompt_percent # expand % escapes in prompt | ||
setopt prompt_subst # subts in prompt | ||
setopt pushd_ignore_dups # ignore dups in pushd | ||
setopt pushd_silent # don't print stack after push/pop | ||
setopt pushd_to_home # pushd == pushd $HOME | ||
setopt rc_expand_param # some expansion trick for arrays in params | ||
setopt rc_quotes # '' == ' in 'quoted exprs | ||
setopt rcs # source all /etc rcs | ||
setopt no_rec_exact # recognize exact match even if ambiguous | ||
setopt no_rm_star_silent # ask user before rm foo/* | ||
setopt no_rm_star_wait # dont't idle 10 seconds | ||
|
||
#[ s-z ]######################################################################## | ||
setopt no_share_history # traditional bash-history | ||
setopt no_sh_file_expansion # dont expand filnames first | ||
setopt no_sh_glob # allow globbing with [(|)<] | ||
setopt no_sh_nullcmd # use my NULLCMD | ||
setopt sh_option_letters # interprete single option letters a la ksh | ||
setopt short_loops # short loops | ||
setopt no_sh_word_split # `s="a b"; a=($s)' => array of length 1, not 2 | ||
setopt no_single_line_zle # use multiline editor | ||
setopt no_sun_keyboard_hack # i don't use sun kb | ||
setopt transient_rprompt # better for cut/paste | ||
setopt vi # use bindkeys | ||
setopt no_xtrace # do not debug by default | ||
setopt zle # use zsh le | ||
|
||
is-at-least 4.3.0 && { | ||
unsetopt hist_save_by_copy | ||
} | ||
|
||
[ -w $zsh_cache ] && HISTFILE=$zsh_cache/history | ||
|
||
HISTSIZE=10000 # size of history | ||
LISTMAX=1000 # never ask | ||
NULLCMD='cat' # use cat for > null commands | ||
REPORTTIME=2 # report time if execution exceeds amount of seconds | ||
SAVEHIST=10000 # maximum of history events to be save | ||
LOGCHECK=60 | ||
watch=(notme) # watch login/logout | ||
WORDCHARS="*?_-.[]~/&;!#$%^(){}<>" | ||
# part of word in line editor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#! /usr/bin/env zsh | ||
|
||
bindkey -v | ||
autoload -U edit-command-line | ||
zle -N edit-command-line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#! /usr/bin/env zsh | ||
|
||
#自动补全功能 | ||
setopt AUTO_LIST | ||
setopt AUTO_MENU | ||
#开启此选项,补全时会直接选中菜单项 | ||
setopt MENU_COMPLETE | ||
|
||
autoload -U compinit | ||
compinit | ||
|
||
#自动补全缓存 | ||
zstyle ':completion::complete:*' use-cache on | ||
zstyle ':completion::complete:*' cache-path .zcache | ||
zstyle ':completion:*:cd:*' ignore-parents parent pwd | ||
|
||
#自动补全选项 | ||
zstyle ':completion:*:match:*' original only | ||
zstyle ':completion::prefix-1:*' completer _complete | ||
zstyle ':completion:predict:*' completer _complete | ||
zstyle ':completion:incremental:*' completer _complete _correct | ||
zstyle ':completion:*' completer _complete _prefix _correct _prefix _match _approximate | ||
|
||
#路径补全 | ||
zstyle ':completion:*' expand 'yes' | ||
zstyle ':completion:*' squeeze-shlashes 'yes' | ||
zstyle ':completion::complete:*' '\\' | ||
|
||
zstyle ':completion:*' menu select | ||
zstyle ':completion:*:*:default' force-list always | ||
|
||
#彩色补全菜单 | ||
##eval $(dircolors -b) | ||
##export ZLSCOLORS="${LS_COLORS}" | ||
zmodload zsh/complist | ||
##zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | ||
##zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' | ||
|
||
#错误校正 | ||
zstyle ':completion:*' completer _complete _match _approximate | ||
zstyle ':completion:*:match:*' original only | ||
zstyle ':completion:*:approximate:*' max-errors 1 numeric | ||
|
||
#kill 命令补全 | ||
compdef pkill=kill | ||
compdef pkill=killall | ||
zstyle ':completion:*:*:kill:*' menu yes select | ||
zstyle ':completion:*:*:*:*:processes' force-list always | ||
zstyle ':completion:*:processes' command 'ps -au$USER' | ||
|
||
#补全类型提示分组 | ||
zstyle ':completion:*:matches' group 'yes' | ||
zstyle ':completion:*' group-name '' | ||
zstyle ':completion:*:options' description 'yes' | ||
zstyle ':completion:*:options' auto-description '%d' | ||
##zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m' | ||
##zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m' | ||
##zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m' | ||
|
||
zstyle ':completion:*:descriptions' format $'%{\e[01;33m%} -- %d --%{\e[0m%}' | ||
zstyle ':completion:*:messages' format $'%{\e[01;35m%}-- %d --%{\e[0m%}' | ||
zstyle ':completion:*:warnings' format $'%{\e[01;31m%}-- No Matches Found --%{\e[0m%}' | ||
|
||
##空行(光标在行首)补全 cd | ||
user-complete(){ | ||
if [[ -n $BUFFER ]] ; then | ||
zle expand-or-complete | ||
else | ||
BUFFER="cd " | ||
zle end-of-line | ||
zle expand-or-complete | ||
fi } | ||
zle -N user-complete | ||
bindkey "\t" user-complete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /usr/bin/env zsh | ||
|
||
#关于历史纪录的配置 | ||
#历史纪录条目数量 | ||
export HISTSIZE=1000000 | ||
#注销后保存的历史纪录条目数量 | ||
export SAVEHIST=1000000 | ||
#历史纪录文件 | ||
export HISTFILE=~/.history | ||
#以附加的方式写入历史纪录 | ||
setopt INC_APPEND_HISTORY | ||
#如果连续输入的命令相同,历史纪录中只保留一个 | ||
#setopt HIST_IGNORE_DUPS | ||
#为历史纪录中的命令添加时间戳 | ||
#setopt EXTENDED_HISTORY | ||
|
||
#启用 cd 命令的历史纪录,cd -[TAB]进入历史路径 | ||
setopt AUTO_PUSHD | ||
#相同的历史路径只保留一个 | ||
setopt PUSHD_IGNORE_DUPS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#! /usr/bin/env zsh | ||
|
||
# 文件关联 | ||
autoload -U zsh-mime-setup | ||
zsh-mime-setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/zsh | ||
# URL encode something and print it. | ||
function url-encode; { | ||
setopt extendedglob | ||
echo "${${(j: :)@}//(#b)(?)/%$[[##16]##${match[1]}]}" | ||
} | ||
|
||
# Search google for the given keywords. | ||
function google; { | ||
w3m "http://www.google.com/search?q=`url-encode "${(j: :)@}"`" | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#! /usr/bin/env zsh | ||
|
||
tohtml() { | ||
if test -z $1 ; then | ||
echo "tohtml <file>" >&2 | ||
return 1 | ||
fi | ||
vim -e +:TOhtml +w +qa $1 | ||
} | ||
|
||
function vman() { vim -c ":RMan ${*}" ; } | ||
function vimgrep () { tmp="$@" ; vim -c "vimgrep $tmp" ; } | ||
|
||
function xpwd () { echo $PWD | xclip -i ; xclip -o ; } | ||
function xcd () { cd `xclip -o` ; } | ||
|
||
function sum() { SUM=0; while read NUM; do SUM=$(($SUM+$NUM)); done; echo $SUM; } | ||
|
||
# generate html file from current directory | ||
function dir-tohtml() { | ||
local td="" | ||
local of="" | ||
if [ $# = 1 ]; then | ||
of=$1; | ||
elif [ $# = 2 ]; then | ||
td=$1; | ||
of=$2; | ||
else | ||
echo "$0 [dir] <file>"; | ||
exit 1; | ||
fi | ||
if [ ! -d $td ]; then | ||
echo "$0 [dir] <file>"; | ||
exit 1; | ||
fi | ||
local dir_list; | ||
if [ "x$td" = "x" ]; then | ||
dir_list=(`ls .`) | ||
else | ||
dir_list=(`ls $td`) | ||
fi | ||
local real_path=""; | ||
if [ "x$td" = "x" ]; then | ||
real_path=`pwd` | ||
else | ||
if [ ! $td = "/" ]; then | ||
real_path=$td | ||
fi | ||
fi | ||
|
||
echo -e "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd\">\n" \ | ||
"<html>\n" \ | ||
"<head>\n" \ | ||
"<title>$of</title>\n" \ | ||
"<meta http-equiv=\"content-type\" content=\"text/html\"; charset=UTF-8\">" \ | ||
"</head>\n" \ | ||
"\t<body bgcolor=\"#808080\" text=\"#ffffff\">\n" \ | ||
"\t<font face=\"monospace\">" > $of | ||
for i in ${dir_list[@]}; | ||
do | ||
echo -e "\t\t<a href=\"file://$real_path/$i\">$i</a>\n" \ | ||
"\t\t<br>" >> $of | ||
done | ||
echo -e "\t</font>\n" \ | ||
"\t</body>\n" \ | ||
"</html>\n" >> $of | ||
} |