All pastes #97586 Raw Edit

Mine

public text v1 · immutable
#97586 ·published 2006-07-23 21:42 UTC
rendered paste body
function precmd {
local TERMWIDTH
    (( TERMWIDTH = ${COLUMNS} - 1 ))

    ###
    # Truncate the path if it's too long.

    PR_FILLBAR=""
    PR_PWDLEN=""

    local promptsize=${#${(%):---(%n@%m:%l)---()--}}
    local pwdsize=${#${(%):-%~}}

    if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
	((PR_PWDLEN=$TERMWIDTH - $promptsize))
    else
	PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
    fi

 ###
    # Get ACPI info.

    if which acpi > /dev/null; then
	PR_ACPI_RESULT=`acpi`
        fi
}


setopt extended_glob
preexec () {
    if [[ "$TERM" == "screen" ]]; then
	local CMD=${1[(wr)^(*=*|sudo|-*)]}
	echo -ne "\ek$CMD\e\\"
    fi
}

setprompt () { 

    ###
    # Need this so the prompt will work.

    setopt prompt_subst
 ###
    # See if we can use colors.

    autoload colors zsh/terminfo
    if [[ "$terminfo[colors]" -ge 8 ]]; then
	colors
    fi
    for color in RED GREY GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
        eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
        eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
        (( count = $count + 1 ))
    done
    PR_NO_COLOUR="%{$terminfo[sgr0]%}"

    ###
    # See if we can use extended characters to look nicer.

    typeset -A altchar
    set -A altchar ${(s..)terminfo[acsc]}
    PR_SET_CHARSET="%{$terminfo[enacs]%}"
    PR_SHIFT_IN="%{$terminfo[smacs]%}"
    PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
    PR_HBAR=${altchar[q]:--}
    PR_ULCORNER=${altchar[l]:--}
    PR_LLCORNER=${altchar[m]:--}
    PR_LRCORNER=${altchar[j]:--}
    PR_URCORNER=${altchar[k]:--}

###
    # Decide if we need to set titlebar text.

    case $TERM in
	xterm*)
	    PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
    ;;
	screen)
	    PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
    ;;
	*)
	    PR_TITLEBAR=''
    ;;
    esac

###
    # Decide whether to set a screen title
    if [[ "$TERM" == "screen" ]]; then
	PR_STITLE=$'%{\ekzsh\e\\%}'
    else
	PR_STITLE=''
    fi

 ###
    # ACPI detection

     if which acpi > /dev/null; then
	PR_ACPI='$PR_RED${PR_ACPI_RESULT[(w)4,(w)5]/\ rate/%%}$PR_LIGHT_BLUE:'
    else
	PR_ACPI=''
    fi

 ###
    # Finally, the prompt.

    PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
$PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
$PR_BLUE%(!.%SROOT%s.%n)$PR_GREEN@%m:%l\
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_HBAR${(e)PR_FILLBAR}$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
$PR_MAGENTA%$PR_PWDLEN<...<%~%<<\
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_URCORNER$PR_SHIFT_OUT\

$PR_CYAN$PR_SHIFT_IN$PR_LLCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
%(?..$PR_LIGHT_RED%?$PR_BLUE:)\
${(e)PR_ACPI}$PR_YELLOW%D{%H:%M}\
$PR_LIGHT_BLUE:%(!.$PR_RED.$PR_WHITE)%#$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_NO_COLOUR '


    RPROMPT=' $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_BLUE$PR_HBAR$PR_SHIFT_OUT\
($PR_YELLOW%D{%a,%b%d}$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_LRCORNER$PR_SHIFT_OUT$PR_NO_COLOUR'

 PS2='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\
$PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR '



}

PATH=$PATH:~/bin:/usr/X11R6/bin:.

alias ls='ls --tabsize=0 --literal --color=auto --show-control-chars --human-readable'
alias ll='ls -l'
alias rocketarena='quake3 +set fs_game arena +nologo'
alias osp='quake3 +set fs_game osp +nologo'
alias cpma='quake3 +set fs_game cpma +nologo'
alias defrag='quake3 +set fs_game defrag'
alias termplayer='mplayer -really-quiet -vo fbdev2 -fs'
alias la='ls -a'
alias nano='nano -iw'
alias mplayer='/usr/bin/mplayer'


#grep -E -v '^(#|;|$|[ ]*#)'

alias e='emacsclient -n'
alias m='less'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias mkdir='mkdir -p'

alias du='du -kh'
alias df='df -kTh'

alias lx='ls -lXB' #sort by extension
alias lk='ls -lSr' #sort by size

export LESSCHARSET="UTF-8"
export EDITOR="emacsclient -n"


 pousse() {
pushd;
}
 plop(){
 popd;
 }

zle -N pushdir pousse
zle -N pop plop
 #################### appuyer sur ESC puis sur la touche pour obtenir la séquence: ESC puis HOME = OH chez moi => ^[OH ( ^[ équivaut à ESC )
bindkey '^[OH' beginning-of-line
bindkey '^[OF' end-of-line
bindkey '^[[3~' delete-char             # Del
bindkey '^[[2~' overwrite-mode          # Insert
bindkey '^[[5~' history-search-backward # PgUp
bindkey '^[[6~' history-search-forward  # PgDn
bindkey '^[[5D' backward-word    #ctrl+left
bindkey '^[[5C' forward-word         #ctrl+right
bindkey -s '^[[5A' "pushd\n" #ctrl+up
bindkey -s '^[[5B' "popd\n" #ctrl+down
bindkey '^z' undo
bindkey '^y' redo


if [ "$TERM" = "linux" -o "$TERM" = "screen" -o "$TERM" = "rxvt" -o "$TERM" = "screen.linux" ]
then
  bindkey '^[[1~' beginning-of-line       # Home
  bindkey '^[[4~' end-of-line             # End
# bindkey '^[[D' backward-word
# bindkey '^[[C' forward-word 
fi

if [ "$TERM" = "xterm" ]
then
  bindkey '^[[H'  beginning-of-line       
  bindkey '^[[F'  end-of-line             
  bindkey '^[[1;5D' backward-word
  bindkey '^[[1;5C' forward-word
fi

#meilleure complétion
unsetopt list_ambiguous
#enlève le slash final
setopt auto_remove_slash
#cherche y compris dans les cachés
#setopt glob_dots
#traite les liens comme il faut =)
setopt chase_links

#push l'ancien repertoire sur la pile
setopt auto_pushd
#ne push pas 20 fois le même repertoire sur la pile
setopt PUSHD_IGNORE_DUPS
#auto_cd si le nom de la commande est celui d'un repertoire
setopt auto_cd
#oblige à mettre >| pour écraser et >>| pour créér
unsetopt clobber
#ne lance pas les jobs en bg avec une priorité infèrieure
unsetopt bg_nice
#si le shell est quitté, n'envoie pas de sigHUP (donc maintiens toutes les applis lancées avec ce shell)
unsetopt hup

#aucun beep
unsetopt beep
unsetopt hist_beep
unsetopt list_beep

#enregistre la date et la durée de chaque commande dans le fichier d'historique
setopt EXTENDED_HISTORY
#tous les shells écrivent à la suite dans le même fichier d'historique, dès que la commande est validée
setopt INC_APPEND_HISTORY
#tous les shells partagent le même historique
setopt SHARE_HISTORY
#lorsque l'on cherche dans l'historique, on n'affiche qu'une seule fois chaque commande, même s'il y a des doublons
setopt HIST_FIND_NO_DUPS
#si la commande entrée correspond exactement à une autre entrée du fichier d'historique, cette dernière est effacée(pas de doublons)
setopt HIST_IGNORE_ALL_DUPS
export HISTSIZE=1000
export SAVEHIST=1000
export HISTFILE=$HOME/.history

#j'ai renlevé le / pour pouvoir modifier des chemins plus facilement
export WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'

zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}'
zstyle ':completion:*' max-errors 3 numeric
zstyle ':completion:*' use-compctl false

setprompt
autoload -U compinit
compinit


# !?string Refer to the most recent command containing string.  The
# trailing ? may be omitted if string is followed immediately by a
# new-line. 
# ^string1^string2^ Quick substitution.  Repeat the last
# command, replacing string1 with string2.

#find -P ~/ -regex ".*\(~\|mozilla.*/Cache.*\|/.thumbnails/.*\|/.wine/.*/temp/.*\|/.gnome2/gnome-art/.*\)" -type f -print -delete && rm -vfr ~/.Trash/* ~/.dvdcss/* ~/.recently-used