Skip to content

Instantly share code, notes, and snippets.

@minimal
Created July 13, 2009 15:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minimal/146193 to your computer and use it in GitHub Desktop.
Save minimal/146193 to your computer and use it in GitHub Desktop.
zshrc
#!/bin/zsh
# Dynamically build the $PATH variable
for dircomponent in $path /sw/bin /sw/sbin /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin /compat/linux/bin /compat/linux/sbin /compat/linux/usr/bin /compat/linux/usr/sbin /usr/games /usr/X11R6/bin /usr/X11R6/sbin ~/bin ~/crossover/bin
do
if [[ -e $dircomponent ]]; then
path=($path $dircomponent)
fi
done
typeset -U path
unset dircomponent
#!/bin/zsh
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=5000
SAVEHIST=5000
setopt appendhistory autocd extendedglob
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/chris/.zshrc'
#fpath=(/usr/local/share/zsh/4.3.10/functions)
autoload -Uz compinit
compinit
# End of lines added by compinstall
autoload -U promptinit && promptinit
#prompt adam2
# key bindings - for cygwin compatiblity
#press control-v then key to find its string.
bindkey -e
bindkey '^?' backward-delete-char
bindkey '^[[3~' delete-char
bindkey -s '^[[1~' '^A'
bindkey -s '^[[4~' '^E'
#bindkey -s '^[[C' '^[f'
#bindkey -s '^[[D' '^[b'
# version control
autoload -Uz vcs_info
alias ls='ls --color=auto'
#alias dir='ls --color=auto --format=vertical'
#alias vdir='ls --color=auto --format=long'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias rgrep='rgrep --color=auto'
#alias ack='ack-grep'
alias ackpy='ack --python'
# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
# more aliases
alias apt-install='sudo apt-get install' # debian/ubuntu
alias apt-remove='sudo apt-get remove'
alias zyp-install='sudo zypper install' # suse
alias open='kde-open'
alias ppjson='python -c "import simplejson; import sys; print simplejson.dumps(simplejson.loads(sys.stdin.read()), indent=4)" | pygmentize -f console -l js'
alias p-ack="ps ax | ack"
alias gita="git-archive --format=zip `git-reflog | grep 'HEAD@{0}' | cut -d \" \" -f1 | sed 's/[.]*//g'` > archive.zip"
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export LESS="-R" # raw mode for correct colors
export EDITOR="emacsclient -nw" # no window mode
export TERM=xterm-256color; # nice colours
# start a Python HTTP server with webshare
alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"'
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
compress () {
FILE=$1
shift
case $FILE in
*.tar.bz2) tar cjf $FILE $* ;;
*.tar.gz) tar czf $FILE $* ;;
*.tgz) tar czf $FILE $* ;;
*.zip) zip $FILE $* ;;
*.rar) rar $FILE $* ;;
*) echo "Filetype not recognized" ;;
esac
}
##### Set the prompt
#autoload colors zsh/terminfo
#colors
#setopt prompt_subst
#if [[ $SYS_IS_GENTOO == 1 ]]; then
# # Make the system prompt look like the default Gentoo bash prompt
# PROMPT='%B%(!.%{${fg[red]}%}.%{${fg[green]}%}%n@)%m%{${fg[default]}%} %{${fg[blue]}%}%1~%b %(!.#.$)%{${fg[default]}%} '
#else
# # Declare an associative array, "_pr_ompt _c_omponents"
# typeset -A prc
#
# # Define common and useful things to put in a prompt
# prc[abbrevpath]='%{${fg[red]}%}%B%45<...<%~%<<%b%{${fg[default]}%}'
# prc[newline]=$'\n'
# prc[promptchar]='%(!.#.$)'
# prc[smiley]='%(?.%{${fg[green]}%}:).%{${fg[red]}%}:()%{${fg[default]}%}'
# prc[timestamp]='%B%{${fg[blue]}%}[%T]%{${fg[default]}%}%b'
# prc[userspec]='%B%(!.%{${fg[red]}%}.%{${fg[green]}%})%n@%m%{${fg[default]}%}%b'
#
# # String them together in a readable format
# PROMPT="${prc[userspec]} ${prc[timestamp]} ${prc[abbrevpath]}${prc[newline]}${prc[smiley]} zsh \$(parse_git_branch)${prc[promptchar]} "
#
# # Unclutter the namespace
# unset prc
#fi
#case $TERM in
# xterm*)
# precmd () {print -Pn "\e]0;%m:%y %h:%* - %n@%m:%~\a"}
# ;;
#esac
#virtualenv setup
export WORKON_HOME="$HOME/devel/envs"
source $HOME/bin/virtualenvwrapper_bashrc
#PS1="$PS1\w\$(parse_git_branch) $ "
# git prompt
setopt prompt_subst
autoload colors
colors
autoload -Uz vcs_info
# set some colors
for COLOR in RED GREEN YELLOW WHITE BLACK CYAN; do
eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
done
PR_RESET="%{${reset_color}%}";
# set formats
# %b - branchname
# %u - unstagedstr (see below)
# %c - stangedstr (see below)
# %a - action (e.g. rebase-i)
# %R - repository path
# %S - path in the repository
FMT_BRANCH="${PR_GREEN}%b%u%c${PR_RESET}" # e.g. master¹²
FMT_ACTION="(${PR_CYAN}%a${PR_RESET}%)" # e.g. (rebase-i)
FMT_PATH="%R${PR_YELLOW}/%S" # e.g. ~/repo/subdir
# check-for-changes can be really slow.
# you should disable it, if you work with large repositories
zstyle ':vcs_info:*:prompt:*' check-for-changes true
zstyle ':vcs_info:*:prompt:*' unstagedstr '¹' # display ¹ if there are unstaged changes
zstyle ':vcs_info:*:prompt:*' stagedstr '²' # display ² if there are staged changes
zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}//" "${FMT_PATH}"
zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}//" "${FMT_PATH}"
zstyle ':vcs_info:*:prompt:*' nvcsformats "" "%~"
function precmd {
vcs_info 'prompt'
}
function lprompt {
local brackets=$1
local color1=$2
local color2=$3
local bracket_open="${color1}${brackets[1]}${PR_RESET}"
local bracket_close="${color1}${brackets[2]}"
local git='$vcs_info_msg_0_'
local cwd="${color2}%B%1~%b"
local smiley='%(?.%{${fg[green]}%}:).%{${fg[red]}%}:()%{${fg[default]}%}'
local newline=$'\n'
local timestamp='%B%{${fg[blue]}%}[%T]%{${fg[default]}%}%b'
PROMPT="${bracket_open}${git}${cwd}${bracket_close}${PR_RESET}${newline}${smiley} ${timestamp} %(!.#.$) ${PR_RESET}"
}
function rprompt {
local brackets=$1
local color1=$2
local color2=$3
local bracket_open="${color1}${brackets[1]}${PR_RESET}"
local bracket_close="${color1}${brackets[2]}${PR_RESET}"
local colon="${color1}:"
local at="${color1}@${PR_RESET}"
local user_host="${color2}%n${at}${color2}%m"
local vcs_cwd='${${vcs_info_msg_1_%%.}/$HOME/~}'
local cwd="${color2}%B%20<..<${vcs_cwd}%<<%b"
local inner="${user_host}${colon}${cwd}"
local newline=$'\n'
RPROMPT="${PR_RESET}${bracket_open}${inner}${bracket_close}${PR_RESET}"
}
lprompt '[]' $BR_BRIGHT_BLACK $PR_WHITE
rprompt '()' $BR_BRIGHT_BLACK $PR_WHITE
# -- start rip config -- #
RIPDIR=/home/chris/.rip
RUBYLIB="$RUBYLIB:$RIPDIR/active/lib"
PATH="$PATH:$RIPDIR/active/bin"
export RIPDIR RUBYLIB PATH
# -- end rip config -- #
#.lightning/functions.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment