Created
August 31, 2015 07:37
-
-
Save praseodym/dc60343a1ce0980e21c6 to your computer and use it in GitHub Desktop.
old zshrc without external dependencies
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
setopt NOHUP | |
# setopt AUTO_LIST # these two should be turned off | |
# setopt AUTO_REMOVE_SLASH # When the last character resulting from a completion is a slash and the next character typed is a word delimiter, remove the slash. | |
setopt HIST_ALLOW_CLOBBER | |
setopt HIST_REDUCE_BLANKS | |
setopt INC_APPEND_HISTORY SHARE_HISTORY | |
setopt ALL_EXPORT | |
setopt AUTO_CD # cd if no matching command | |
setopt EXTENDED_HISTORY # saves timestamps on history | |
setopt EXTENDED_GLOB # globs #, ~ and ^ | |
setopt PUSHD_IGNORE_DUPS | |
setopt HIST_IGNORE_ALL_DUPS | |
setopt AUTO_PARAM_SLASH # adds slash at end of tabbed dirs | |
setopt CHECK_JOBS # check bg jobs on exit | |
setopt CORRECT # corrects spelling | |
setopt CORRECT_ALL # corrects spelling | |
setopt GLOB_DOTS # find dotfiles easier | |
setopt HASH_CMDS # save cmd location to skip PATH lookup | |
setopt HIST_NO_STORE # don't save 'history' cmd in history | |
setopt LIST_ROWS_FIRST # completion options left-to-right, top-to-bottom | |
setopt LIST_TYPES # show file types in list | |
setopt MARK_DIRS # adds slash to end of completed dirs | |
setopt NUMERIC_GLOB_SORT # sort numerically first, before alpha | |
setopt PROMPT_SUBST # sub values in prompt | |
setopt MENUCOMPLETE | |
# Set/unset shell options | |
setopt autopushd pushdminus pushdsilent pushdtohome | |
setopt notify globdots correct autolist | |
setopt correctall autocd recexact longlistjobs | |
setopt autoresume histignoredups noclobber | |
setopt extendedglob rcquotes mailwarning | |
unsetopt bgnice autoparamslash cdablevars | |
# Autoload zsh modules when they are referenced | |
zmodload -a zsh/stat stat | |
zmodload -a zsh/zpty zpty | |
zmodload -a zsh/zprof zprof | |
zmodload -a zsh/mapfile mapfile | |
autoload -U age | |
DIRSTACKSIZE=15 | |
HISTSIZE=4000 | |
SAVEHIST=4000 | |
HISTFILE=$ZDOTDIR/.histfile-$USER | |
HOSTNAME="`hostname`" | |
zmodload zsh/terminfo | |
autoload colors | |
if [[ "$terminfo[colors]" -ge 8 ]]; then | |
colors | |
fi | |
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do | |
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' | |
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' | |
done | |
PR_RESET="%{$reset_color%}" | |
PS1="[$PR_BLUE%n$PR_RESET@$PR_CYAN%U%m%u$PR_RESET]%(!.#.$) " | |
RPS1="[$PR_GREEN%2c$PR_RESET] [$PR_CYAN%h $PR_LIGHT_BLUE%D{%d-%m %H:%M}$PR_RESET]" | |
#LC_ALL='en_US.UTF-8' | |
#LANG='en_US.UTF-8' | |
#LC_CTYPE=C | |
DISPLAY=:0 | |
LS_COLORS='*.swp=-1;44;37:*,v=5;34;93:*.vim=35:no=0:fi=0:di=32:ln=36:or=1;40:mi=1;40:pi=31:so=33:bd=44;37:cd=44;37:*.jpg=1;32:*.jpeg=1;32:*.JPG=1;32:*.gif=1;32:*.png=1;32:*.jpeg=1;32:*.ppm=1;32:*.pgm=1;32:*.pbm=1;32:*.c=1;32:*.C=1;33:*.h=1;33:*.cc=1;33:*.awk=1;33:*.pl=1;33:*.gz=0;33:*.tar=0;33:*.zip=0;33:*.lha=0;33:*.lzh=0;33:*.arj=0;33:*.bz2=0;33:*.tgz=0;33:*.taz=33:*.html=36:*.htm=1;34:*.doc=1;34:*.txt=1;34:*.o=1;36:*.a=1;36' | |
ZLS_COLORS='*.swp=00;44;37:*,v=5;34;93:*.vim=35:no=0:fi=0:di=32:ln=36:or=1;40:mi=1;40:pi=31:so=33:bd=44;37:cd=44;37:*.jpg=1;32:*.jpeg=1;32:*.JPG=1;32:*.gif=1;32:*.png=1;32:*.jpeg=1;32:*.ppm=1;32:*.pgm=1;32:*.pbm=1;32:*.c=1;32:*.C=1;33:*.h=1;33:*.cc=1;33:*.awk=1;33:*.pl=1;33:*.gz=0;33:*.tar=0;33:*.zip=0;33:*.lha=0;33:*.lzh=0;33:*.arj=0;33:*.bz2=0;33:*.tgz=0;33:*.taz=33:*.html=36:*.htm=1;34:*.doc=1;34:*.txt=1;34:*.o=1;36:*.a=1;36' | |
CLICOLOR=1 | |
unsetopt ALL_EXPORT | |
## ALIASES ############################################################################################################# | |
#alias man='LC_ALL=C LANG=C man' | |
alias egrep='egrep --color=auto' | |
alias fgrep='fgrep --color=auto' | |
alias grep='grep --color=auto' | |
alias f=finger | |
alias ll='ls -al' | |
alias dh='dirs -v' # directory history | |
# Find a file with a pattern in name: | |
# Find a file with pattern $1 in name and Execute $2 on it: | |
function findExec() { find . -type f -iname '*'$1'*' -exec "${2:-file}" {} \; ; } | |
function findInFilePattern() { find . -name "$2" | xargs grep -ni "$1" ; } | |
alias fe=findExec | |
alias fifp=findInFilePattern | |
# grep history | |
alias gh='fc -l 0 | grep' | |
alias mv='nocorrect mv' # no spelling correction on mv | |
alias cp='nocorrect cp' | |
alias mkdir='nocorrect mkdir' | |
alias cdw='cd ${WORKSPACE_DIR}' | |
cdWhichDirname() { | |
cd $(dirname =$1) | |
} | |
alias wcd=cdWhichDirname | |
alias pse='ps -ef | grep' | |
alias ag='alias | grep -i' | |
# alias update_locate='sudo /usr/libexec/locate.updatedb' | |
update-dotfiles() { pushd $DOTFILES && hg fetch && ./install.sh YES && popd } | |
# global aliases | |
# alias -g 21="2>&1" | |
alias -g L='| less' | |
alias -g G='| grep' | |
alias -g GV='| grep -v' | |
alias -g GE='| egrep' | |
alias -g PC="| pc" | |
alias -g XG="| xargs grep -ni" | |
alias cutcol=pc | |
pc() { awk "{print \$$1}" } # print column | |
rot13 () { tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]" } | |
alias wdc="watch --differences=cumulative" | |
alias diffcol="diff -y -W 160" # side by side diff 160 columns wide | |
#show directory usage for all directories in the current dir | |
alias duc='du -sh `ls -d *`' | |
# forward requests from port 80 to 8080 | |
alias ipfw80to8080='sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to any 80 in' | |
# starts a server on port 8000 that makes the current directory browsable with a webbrowser | |
alias webshare='python -m SimpleHTTPServer' | |
# print the contents of a single line (passed in as an argument) | |
alias ol=onlyLine | |
function onlyLine() { awk 'NR == '$1' {print;exit}'; } | |
# split the input based on the first parameter, the 2nd parameter is either a 1 (show the left hand side) or a 2 (show the right hand side) after the split | |
alias so=splitOn | |
function splitOn() { sed -E 's/(.*)'$1'(.*)/\'$2'/'; } | |
# show open ports | |
alias op='lsof -i' | |
alias nsop='netstat -tunl -p tcp' | |
# scan another machine's ports | |
alias nm='nmap -PN' | |
alias pg='su -s /bin/sh postgres' | |
alias rscp='rsync -avzP --exclude=.DS_Store' | |
alias host6='host -6' | |
alias zsu="su -c 'HOME=$HOME zsh'" | |
alias zsu-="su - -c 'ZDOTDIR=$ZDOTDIR zsh'" | |
alias zsudo="sudo zsh" | |
## BINDKEY ############################################################################################################# | |
# ctrl-L | |
# alias =clear | |
if [[ -o LOGIN ]]; then | |
stty erase \^\H | |
bindkey "^[[3~" delete-char | |
bindkey '^R' history-incremental-search-backward | |
bindkey '^[r' history-incremental-search-forward | |
bindkey "^[[5~" up-line-or-history | |
bindkey "^[[6~" down-line-or-history | |
bindkey "^[[H" beginning-of-line | |
bindkey "^[[1~" beginning-of-line | |
bindkey "^[[F" end-of-line | |
bindkey "^[[4~" end-of-line | |
bindkey ' ' magic-space # also do history expansion on space | |
bindkey '^I' complete-word # complete on tab, leave expansion to _expand | |
bindkey '^[[Z' reverse-menu-complete | |
bindkey '^W' vi-backward-kill-word | |
fi | |
## VERSION CONTROL ##################################################################################################### | |
vcst() { | |
# print out all of the files with a passed in status flag (M - modified, A - added, ? - unknown, etc) (default ?) | |
# expects first parameter to be the version control command (likely svn or hg) | |
STATUS='\?' | |
if [ -n "$2" ] | |
then | |
STATUS=$2 | |
fi | |
$1 status | egrep "^$STATUS" | awk '{print $2}' | |
} | |
alias svnst='vcst svn' | |
alias hgst='vcst hg' | |
# dsrm: removes all .DS_Store file from the current dir and below | |
alias dsrm="find . -type f -name .DS_Store -print0 | xargs -0 rm" | |
# zipf: to create a ZIP archive of a folder | |
zipf () { dsrm; zip -r "$1".zip "$1" ; } | |
alias ls='ls --color=auto' | |
alias ifconfig="/sbin/ifconfig" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment