From ade8a562ccd32e2b13fd3d6fb72a2cf660b5c9b4 Mon Sep 17 00:00:00 2001 From: maudin Date: Wed, 24 Feb 2016 00:18:23 +0100 Subject: [PATCH] now use antigen --- README.md | 15 +- custom/hybris-alias.zsh | 46 ---- custom/hybris-display.zsh | 19 -- custom/hybris-export.zsh | 11 - custom/hybris-zsh.zsh | 72 ------ custom/z.zsh | 245 -------------------- custom/hybris-dir-colors => dir-colors | 0 hybris.plugin.zsh | 46 ++++ custom/hybris.zsh-theme => hybris.zsh-theme | 0 zshrc | 62 ++--- 10 files changed, 70 insertions(+), 446 deletions(-) delete mode 100644 custom/hybris-alias.zsh delete mode 100644 custom/hybris-display.zsh delete mode 100644 custom/hybris-export.zsh delete mode 100644 custom/hybris-zsh.zsh delete mode 100644 custom/z.zsh rename custom/hybris-dir-colors => dir-colors (100%) create mode 100644 hybris.plugin.zsh rename custom/hybris.zsh-theme => hybris.zsh-theme (100%) diff --git a/README.md b/README.md index e067db1..0435e00 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,6 @@ zsh === -Zsh configuration +Zsh configuration using antigen. Clone in ~/.zsh and do -Install -------- - -* clone oh-my-zsh - - git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-myzsh - -* Link configuration - - ln -s $PWD/zshrc ~/.zshrc - - for i in `ls custom`; do ln -s $PWD/custom/$i ~/.oh-my-zsh/custom/$i; done + ln -s $HOME/.zsh/zshrc $HOME/.zshrc diff --git a/custom/hybris-alias.zsh b/custom/hybris-alias.zsh deleted file mode 100644 index fa4d714..0000000 --- a/custom/hybris-alias.zsh +++ /dev/null @@ -1,46 +0,0 @@ -# Scripts files -if [ -d $HOME/scripts ] -then - files=`ls $HOME/scripts` - if [ "x$files" != "x" ] - then - for i in `ls --file-type $HOME/scripts` - do - ALIAS=`echo $i | cut -d. -f1` - alias $ALIAS=$HOME/scripts/$i - done - fi -fi - -# Everyday aliases -alias cp='nocorrect cp' # no spelling correction on cp -alias cvlc-add='cvlc --playlist-enqueue' -alias grep='grep --color=auto' -alias h=history -alias j=jobs -alias l='ls -l' -alias la='ls -la' -alias ll='ls -l' -alias ls='ls --color=auto -F' -alias mkdir='nocorrect mkdir' # no spelling correction on mkdir -alias mv='nocorrect mv' # no spelling correction on mv -alias wi='wicd-curses' - -alias -g M='|more' -alias -g H='|head' -alias -g T='|tail' - -configupdate() {cd ~/; git add config; git commit -m "config update"; git push; cd -} -e() {emacsclient -n $@ > /dev/null 2>&1} -git-send-email() {git send-email --smtp-server /usr/bin/msmtp $@} -history() {perl -lne 'm#: (\d+):\d+;(.+)# && printf "\033[94m%s\033[0m %s\n",scalar localtime $1,$2' ~/.zhist} -logtail() {tail -f $1 | ccze -A} -mutt() {echo -ne "\033]0;screen mutt\007" ; /usr/bin/screen -O -S mutt -c ~/.screenrc_mutt} -quicksave() {cp --backup=numbered "$@" /tmp/} -wallpaper() {rm -f /home/hybris/Pictures/wallpaper; ln -s `pwd`/$1 /home/hybris/Pictures/wallpaper} -whiteboard() {convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"} - -# System -mouseon() {xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 8 1} -mouseoff() {xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 8 0} -pulse-restart() {killall pulseaudio && /usr/bin/pulseaudio --start --log-target=syslog} diff --git a/custom/hybris-display.zsh b/custom/hybris-display.zsh deleted file mode 100644 index d8fb54d..0000000 --- a/custom/hybris-display.zsh +++ /dev/null @@ -1,19 +0,0 @@ -# Shut the f*ck up. -xset b off - -# bip at command end -function precmd() { - echo -n -e "\a" - if [ "$TERM" != dumb ]; then echo -en "\033]0;${USER}@$(hostname)\007"; fi -} - -# do not share history between terms... -unsetopt share_history - -# "ctrl-x e" to edit command -autoload edit-command-line -zle -N edit-command-line -bindkey '^Xe' edit-command-line - -# dir colors -eval `dircolors $HOME/.oh-my-zsh/custom/hybris-dir-colors` diff --git a/custom/hybris-export.zsh b/custom/hybris-export.zsh deleted file mode 100644 index aa67e1a..0000000 --- a/custom/hybris-export.zsh +++ /dev/null @@ -1,11 +0,0 @@ -# Personnal -export EDITOR=emacsclient -export HISTFILE=~/.zhist -export HISTSIZE=5000 -export LESS=-cex3MRX -export LESSOPEN='|~/.lessfilter %s' -export LOGCHECK=60 -export READNULLCMD=${PAGER:-/usr/bin/pager} -export SAVEHIST=5000 -export WATCH=all -export WATCHFMT="%n has %a %l from %M" diff --git a/custom/hybris-zsh.zsh b/custom/hybris-zsh.zsh deleted file mode 100644 index cad18c3..0000000 --- a/custom/hybris-zsh.zsh +++ /dev/null @@ -1,72 +0,0 @@ -if [ $UID -eq 0 ]; then - umask 077; -else - umask 022; -fi - -autoload incremental-complete-word -autoload insert-files -autoload mere zed zfinit -autoload run-help -autoload -U compinit -autoload -U promptinit -autoload -U zen -compinit -promptinit -zle -N incremental-complete-word -zle -N insert-files -zmodload zsh/complist - -bindkey m menu-select -bindkey i incremental-complete-word -bindkey j insert-files - -fignore=(.o .c~ .pro) -fpath=( - $fpath - /root/.zen/zsh/scripts - /root/.zen/zsh/zle ) - -limit core 0 - -setopt correct -setopt auto_cd -setopt hist_ignore_dups -setopt auto_list -setopt append_history -setopt auto_param_keys -setopt auto_param_slash -setopt no_bg_nice -setopt complete_aliases -setopt equals -setopt extended_glob -setopt extendedhistory -setopt hash_cmds -setopt hash_dirs -setopt mail_warning -setopt magic_equal_subst -setopt numericglobsort -setopt interactivecomments -setopt printeightbit - -zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin -zstyle ':completion:*' format '-=> %d' -zstyle ':completion:*' auto-description 'specify: %d' -zstyle ':completion:*' completer _complete _correct _approximate -zstyle ':completion:*' group-name '' -zstyle ':completion:*' insert-unambiguous true -zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} -zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'l:|=* r:|=*' 'r:|[ -._-]=* r:|=*' -zstyle ':completion:*' max-errors 2 -zstyle ':completion:*' menu select=5 -zstyle ':completion:*' original true -zstyle ':completion:*' squeeze-slashes true -zstyle ':completion:*' verbose true -zstyle ':completion:*:rm:*' ignore-line yes -zstyle ':completion:*:mv:*' ignore-line yes -zstyle ':completion:*:cp:*' ignore-line yes - -unsetopt inc_append_history - -if [ "$TERM" != dumb ]; then echo -en "\033]0;${USER}@$(hostname)\007"; fi diff --git a/custom/z.zsh b/custom/z.zsh deleted file mode 100644 index ec9736a..0000000 --- a/custom/z.zsh +++ /dev/null @@ -1,245 +0,0 @@ -# Copyright (c) 2009 rupa deadwyler under the WTFPL license - -# maintains a jump-list of the directories you actually use -# -# INSTALL: -# * put something like this in your .bashrc/.zshrc: -# . /path/to/z.sh -# * cd around for a while to build up the db -# * PROFIT!! -# * optionally: -# set $_Z_CMD in .bashrc/.zshrc to change the command (default z). -# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z). -# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution. -# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself. -# set $_Z_EXCLUDE_DIRS to an array of directories to exclude. -# -# USE: -# * z foo # cd to most frecent dir matching foo -# * z foo bar # cd to most frecent dir matching foo and bar -# * z -r foo # cd to highest ranked dir matching foo -# * z -t foo # cd to most recently accessed dir matching foo -# * z -l foo # list matches instead of cd -# * z -c foo # restrict matches to subdirs of $PWD - -export _Z_EXCLUDE_DIRS="/tmp /lost+found" - -[ -d "${_Z_DATA:-$HOME/.z}" ] && { - echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory." -} - -_z() { - - local datafile="${_Z_DATA:-$HOME/.z}" - - # bail if we don't own ~/.z (we're another user but our ENV is still set) - [ -f "$datafile" -a ! -O "$datafile" ] && return - - # add entries - if [ "$1" = "--add" ]; then - shift - - # $HOME isn't worth matching - [ "$*" = "$HOME" ] && return - - # don't track excluded dirs - local exclude - for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do - [ "$*" = "$exclude" ] && return - done - - # maintain the data file - local tempfile="$datafile.$RANDOM" - while read line; do - # only count directories - [ -d "${line%%\|*}" ] && echo $line - done < "$datafile" | awk -v path="$*" -v now="$(date +%s)" -F"|" ' - BEGIN { - rank[path] = 1 - time[path] = now - } - $2 >= 1 { - # drop ranks below 1 - if( $1 == path ) { - rank[$1] = $2 + 1 - time[$1] = now - } else { - rank[$1] = $2 - time[$1] = $3 - } - count += $2 - } - END { - if( count > 6000 ) { - # aging - for( x in rank ) print x "|" 0.99*rank[x] "|" time[x] - } else for( x in rank ) print x "|" rank[x] "|" time[x] - } - ' 2>/dev/null >| "$tempfile" - # do our best to avoid clobbering the datafile in a race condition - if [ $? -ne 0 -a -f "$datafile" ]; then - env rm -f "$tempfile" - else - env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile" - fi - - # tab completion - elif [ "$1" = "--complete" ]; then - while read line; do - [ -d "${line%%\|*}" ] && echo $line - done < "$datafile" | awk -v q="$2" -F"|" ' - BEGIN { - if( q == tolower(q) ) imatch = 1 - split(substr(q, 3), fnd, " ") - } - { - if( imatch ) { - for( x in fnd ) tolower($1) !~ tolower(fnd[x]) && $1 = "" - } else { - for( x in fnd ) $1 !~ fnd[x] && $1 = "" - } - if( $1 ) print $1 - } - ' 2>/dev/null - - else - # list/go - while [ "$1" ]; do case "$1" in - --) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;; - -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in - c) local fnd="^$PWD $fnd";; - h) echo "${_Z_CMD:-z} [-chlrtx] args" >&2; return;; - x) sed -i -e "\:^${PWD}|.*:d" "$datafile";; - l) local list=1;; - r) local typ="rank";; - t) local typ="recent";; - esac; opt=${opt:1}; done;; - *) local fnd="$fnd${fnd:+ }$1";; - esac; local last=$1; shift; done - [ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1 - - # if we hit enter on a completion just go there - case "$last" in - # completions will always start with / - /*) [ -z "$list" -a -d "$last" ] && cd "$last" && return;; - esac - - # no file yet - [ -f "$datafile" ] || return - - local cd - cd="$(while read line; do - [ -d "${line%%\|*}" ] && echo $line - done < "$datafile" | awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" ' - function frecent(rank, time) { - # relate frequency and time - dx = t - time - if( dx < 3600 ) return rank * 4 - if( dx < 86400 ) return rank * 2 - if( dx < 604800 ) return rank / 2 - return rank / 4 - } - function output(files, out, common) { - # list or return the desired directory - if( list ) { - cmd = "sort -n >&2" - for( x in files ) { - if( files[x] ) printf "%-10s %s\n", files[x], x | cmd - } - if( common ) { - printf "%-10s %s\n", "common:", common > "/dev/stderr" - } - } else { - if( common ) out = common - print out - } - } - function common(matches) { - # find the common root of a list of matches, if it exists - for( x in matches ) { - if( matches[x] && (!short || length(x) < length(short)) ) { - short = x - } - } - if( short == "/" ) return - # use a copy to escape special characters, as we want to return - # the original. yeah, this escaping is awful. - clean_short = short - gsub(/[\(\)\[\]\|]/, "\\\\&", clean_short) - for( x in matches ) if( matches[x] && x !~ clean_short ) return - return short - } - BEGIN { split(q, words, " "); hi_rank = ihi_rank = -9999999999 } - { - if( typ == "rank" ) { - rank = $2 - } else if( typ == "recent" ) { - rank = $3 - t - } else rank = frecent($2, $3) - matches[$1] = imatches[$1] = rank - for( x in words ) { - if( $1 !~ words[x] ) delete matches[$1] - if( tolower($1) !~ tolower(words[x]) ) delete imatches[$1] - } - if( matches[$1] && matches[$1] > hi_rank ) { - best_match = $1 - hi_rank = matches[$1] - } else if( imatches[$1] && imatches[$1] > ihi_rank ) { - ibest_match = $1 - ihi_rank = imatches[$1] - } - } - END { - # prefer case sensitive - if( best_match ) { - output(matches, best_match, common(matches)) - } else if( ibest_match ) { - output(imatches, ibest_match, common(imatches)) - } - } - ')" - [ $? -gt 0 ] && return - [ "$cd" ] && cd "$cd" - fi -} - -alias ${_Z_CMD:-z}='_z 2>&1' - -[ "$_Z_NO_RESOLVE_SYMLINKS" ] || _Z_RESOLVE_SYMLINKS="-P" - -if compctl >/dev/null 2>&1; then - # zsh - [ "$_Z_NO_PROMPT_COMMAND" ] || { - # populate directory list, avoid clobbering any other precmds. - if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then - _z_precmd() { - _z --add "${PWD:a}" - } - else - _z_precmd() { - _z --add "${PWD:A}" - } - fi - [[ -n "${precmd_functions[(r)_z_precmd]}" ]] || { - precmd_functions[$(($#precmd_functions+1))]=_z_precmd - } - } - _z_zsh_tab_completion() { - # tab completion - local compl - read -l compl - reply=(${(f)"$(_z --complete "$compl")"}) - } - compctl -U -K _z_zsh_tab_completion _z -elif complete >/dev/null 2>&1; then - # bash - # tab completion - complete -o filenames -C '_z --complete "$COMP_LINE"' ${_Z_CMD:-z} - [ "$_Z_NO_PROMPT_COMMAND" ] || { - # populate directory list. avoid clobbering other PROMPT_COMMANDs. - grep "_z --add" <<< "$PROMPT_COMMAND" >/dev/null || { - PROMPT_COMMAND="$PROMPT_COMMAND"$'\n''_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null;' - } - } -fi - diff --git a/custom/hybris-dir-colors b/dir-colors similarity index 100% rename from custom/hybris-dir-colors rename to dir-colors diff --git a/hybris.plugin.zsh b/hybris.plugin.zsh new file mode 100644 index 0000000..be6bc96 --- /dev/null +++ b/hybris.plugin.zsh @@ -0,0 +1,46 @@ +# bip at command end +function precmd() {echo -n -e "\a"} +function preexec() {print -Pn "\e]0;toto\a"} + +# do not share history between terms... +unsetopt share_history + +# SSH agent lives for 2 hours +# zstyle :omz:plugins:ssh-agent lifetime 2h + +# Scripts files +SCRIPT_DIR=$HOME/.scripts +if [ -d $SCRIPT_DIR ] +then + files=`ls $SCRIPT_DIR` + if [ "x$files" != "x" ] + then + for i in `ls --file-type $SCRIPT_DIR` + do + ALIAS=`echo $i | cut -d. -f1` + alias $ALIAS=$SCRIPT_DIR/$i + done + fi +fi + +# Everyday aliases +alias j=jump +alias dnsfix="sudo service bind9 restart" +cless() {for a in $@; do colorize_via_pygmentize $a | less; done} + +# Some exports +export EDITOR=emacsclient +export HISTFILE=~/.zhist +export HISTSIZE=5000 +export INFRA=/home/hybris/dev/bearstech/bearstech/infra +export LESS=-cex2MRX +export LESSOPEN='|~/.lessfilter %s' +export LOGCHECK=60 +export PATH=/usr/local/bin:$INFRA/bin:/home/hybris/dev/bearstech/bearstech/xen:$PATH +export READNULLCMD=${PAGER:-/usr/bin/pager} +export SAVEHIST=5000 +export WATCH=all +export WATCHFMT="%n has %a %l from %M" + +# dir colors +eval `dircolors $HOME/.zsh/dir-colors` diff --git a/custom/hybris.zsh-theme b/hybris.zsh-theme similarity index 100% rename from custom/hybris.zsh-theme rename to hybris.zsh-theme diff --git a/zshrc b/zshrc index 42e4101..c682e9c 100644 --- a/zshrc +++ b/zshrc @@ -1,45 +1,27 @@ -# Path to your oh-my-zsh configuration. -ZSH=$HOME/.oh-my-zsh +source /usr/share/zsh-antigen/antigen.zsh -# Set name of the theme to load. -# Look in ~/.oh-my-zsh/themes/ -# Optionally, if you set this to "random", it'll load a random theme each -# time that oh-my-zsh is loaded. -ZSH_THEME="hybris" +antigen use oh-my-zsh -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" +antigen bundles <