Skip to content

Instantly share code, notes, and snippets.

@avnik
Last active August 29, 2015 14:05
Show Gist options
  • Save avnik/89686d81fb6f148e1bcd to your computer and use it in GitHub Desktop.
Save avnik/89686d81fb6f148e1bcd to your computer and use it in GitHub Desktop.
alias fuck='sudo $(fc -ln -1)'
# Set up aliases
alias ack='ack-grep'
alias mv='nocorrect mv' # no spelling correction on mv
alias cp='nocorrect cp' # no spelling correction on cp
alias mkdir='nocorrect mkdir' # no spelling correction on mkdir
alias j=jobs
alias pu=pushd
alias po=popd
alias d='dirs -v'
alias h=history
alias ll='ls -l'
alias la='ls -a'
alias lsd='ls -ld *(-/DN)'
alias lsa='ls -ld .*'
# Suffix aliases
alias -s M='|more'
alias -s L='|less'
alias -s H='|head'
alias -s T='|tail'
bindkey '^Xa' _expand_alias
# -*- mode: sh -*-
# Tools
if [ -f /etc/debian_verion -o -f /etc/ubuntu_version -o -f /etc/altlinux-release ]; then
# Optimized common case
alias ls="ls --color=auto -phs"
export GREP_OPTIONS='--color=auto --directories=recurse'
export GZIP='--rsyncable'
eval $(lesspipe)
eval $(lessfile)
else
if [ `uname -s` = Darwin ]; then
alias ls="ls -FG"
elif ls --version | grep Stallman >/dev/null; then
alias ls="ls --color=auto -phs"
else
alias ls="ls -phs"
fi
if [ `uname -s` = Darwin -a $TERM = rxvt-unicode ]; then
export TERM=rxvt
fi
if [ $TERM = rxvt-256color ]; then
export TERM=rxvt
fi
if grep --version | grep GNU >/dev/null; then
export GREP_OPTIONS='--color=auto --directories=recurse'
fi
if gzip --help | grep --directories=skip rsyncable >/dev/null; then
export GZIP='--rsyncable'
fi
if [ -f /usr/bin/lessfile ]; then
eval $(lessfile)
fi
fi
export LESS=-IRcx4M
cdpath=(. .. ~ ~/work)
export RI='--format ansi'
# Zsh
if test -e ${HOME}/.zsh_aliases; then
source ${HOME}/.zsh_aliases
fi
bindkey -e
#
# $ZSH_VERSION
#
case "$ZSH_VERSION" in
4.3.1*|4.3.[789]|4.[456789]*|5.*)
autoload -Uz vcs_info;;
*)
echo "Upgrade your zsh!";;
esac
PS1='[%n@%m:%y]%~%70(l|
|)%# '
if [ $TERM = screen.rxvt ]; then
export TERM=rxvt-unicode
fi
case $TERM in
dumb)
export PROMPT="%#"
;;
*)
case "$ZSH_VERSION" in
4.3.1*|4.3.[789]|4.[456789]*)
export PROMPT="[%(!.%S.)%n%(!.%s.)@%m:%y]%~%(?..%B%?%b)%70(l|
|)%(1v.%F{blue}%1v%f.)%B%#%b ";;
*)
export PROMPT="[%(!.%S.)%n%(!.%s.)@%m:%y]%~%(?..%B%?%b)%70(l|
|)%B%#%b ";;
esac
;;
esac
case $TERM in
xterm*|Eterm*|rxvt*)
function preexec { local s=${2//\\/\\\\}; print -nP "\033]2;[zsh@%m:%~]%# $s\007\033]1;[%m:%~]%# $s\007" }
case "$ZSH_VERSION" in
4.3.1*|4.3.[789]|4.[56789]*)
function precmd {
print -nP "\033]2;[zsh@%m:%~]%#\007\033]1;[%m:%~]%#\007"
psvar=()
vcs_info
[[ -n $vcs_info_msg_0_ ]] && psvar[1]="$vcs_info_msg_0_"
};;
*)
function precmd {
print -nP "\033]2;[zsh@%m:%y]%~%#\007\033]1;[%m:%m]%~%#\007"
};;
esac
;;
esac
slashre=/; export WORDCHARS=${WORDCHARS/$slashre}
setopt no_auto_menu
setopt auto_pushd
setopt extended_glob
setopt share_history
setopt hist_ignore_all_dups
setopt hist_no_store
setopt hist_reduce_blanks
setopt inc_append_history
setopt extended_history
setopt pushd_ignore_dups
setopt no_bang_hist
setopt nobeep
autoload -U compinit
compinit
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zshcache
zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'
zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/).svn'
zstyle ':completion:*:cd:*' ignored-patterns '(*/)#.svn'
reporoot () {
if git rev-parse --is-inside-git-tree >/dev/null 2>&1; then
git rev-parse --git-dir | sed -e 's/\/.git$//'
elif hg root 2>/dev/null; then
:
else
echo $PWD
fi
}
alias cdroot='cd $(reporoot)'
if [ -f /usr/share/zsh-antigen/antigen.zsh ]; then
source /usr/share/zsh-antigen/antigen.zsh
fi
if [ -d /usr/share/zsh/vendor-completions ]; then
for each in $(find /usr/share/zsh/vendor-completions -type f); do
compdef $each
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment