Validation initiale
This commit is contained in:
2
rc/00modules.rc
Normal file
2
rc/00modules.rc
Normal file
@@ -0,0 +1,2 @@
|
||||
zmodload zsh/stat
|
||||
zmodload zsh/datetime
|
||||
44
rc/alias.rc
Normal file
44
rc/alias.rc
Normal file
@@ -0,0 +1,44 @@
|
||||
# -*- shell-script -*-x
|
||||
# vim: set syntax=zsh:
|
||||
# $Id: alias.rc 44 2005-08-09 14:50:41Z asyd $
|
||||
|
||||
# I prefer interactive mode
|
||||
alias ls="ls --color -h"
|
||||
alias ll="ls -lh"
|
||||
alias la="ls -A"
|
||||
alias df="df -h"
|
||||
alias du="du -hs"
|
||||
alias more="less"
|
||||
alias serial="screen 1 /dev/ttyS0"
|
||||
alias ser=serial
|
||||
alias scan="sudo iwlist wlan0 scan"
|
||||
alias route="route -n"
|
||||
# zsh corret clea to flea
|
||||
[[ -x `which flea` ]] && alias clea="clear"
|
||||
|
||||
[[ -x $(which vim) ]] && alias vi="vim"
|
||||
|
||||
# start mutt with list mailboxes
|
||||
[[ -x `which mutt` ]] && alias mutt="mutt -y"
|
||||
|
||||
# IPv6 Stuff
|
||||
alias netstat6="netstat -A inet6"
|
||||
|
||||
# acpi (show all available informations)
|
||||
[[ -x `which acpi` ]] && alias acpi="acpi -V"
|
||||
|
||||
# Etags
|
||||
[[ -x `which etags` ]] && alias etags="etags --members"
|
||||
|
||||
alias -s log="tail -f"
|
||||
|
||||
alias -s pem="openssl x509 -text -noout -in"
|
||||
alias -s req="openssl req -text -in"
|
||||
alias rand="openssl rand -base64"
|
||||
|
||||
# cron / fcronb
|
||||
if [[ -x $(which -p fcron) ]]; then
|
||||
alias crontab="fcrontab"
|
||||
fi
|
||||
|
||||
return 0
|
||||
11
rc/auto_screen.rc
Normal file
11
rc/auto_screen.rc
Normal file
@@ -0,0 +1,11 @@
|
||||
if [ "x$SSH_CLIENT" != "x" ]; then
|
||||
if [ "$TERM" != "screen" ]; then
|
||||
SOCK="$HOME/.zsh/ssh_auth_sock"
|
||||
if [ ! -z "$SSH_AUTH_SOCK" -a "$SSH_AUTH_SOCK" != "$SOCK" ]; then
|
||||
rm -f "$SOCK"
|
||||
ln -sf "$SSH_AUTH_SOCK" "$SOCK"
|
||||
export SSH_AUTH_SOCK="$SOCK"
|
||||
fi
|
||||
screen -xR && logout
|
||||
fi
|
||||
fi
|
||||
133
rc/functions.rc
Normal file
133
rc/functions.rc
Normal file
@@ -0,0 +1,133 @@
|
||||
# -*- shell-script -*-
|
||||
#
|
||||
# Trace libraries load by first argument (ELF only)
|
||||
# (note: exactly same result with ldd)
|
||||
tracelib () {
|
||||
LD_TRACE_LOADED_OBJECTS=1 $1
|
||||
}
|
||||
|
||||
srm() {
|
||||
if [ ! -z $1 ]; then
|
||||
echo "Deleting `find "$1" -type l | wc -l` symbolic links"
|
||||
find "$1" -type l -exec rm {} +
|
||||
rm -r "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
rvpn() {
|
||||
if echo $1 | grep "/" > /dev/null; then
|
||||
sudo route add -net $1 gw 192.168.10.1
|
||||
else
|
||||
sudo route add -host $1 gw 192.168.10.1
|
||||
fi
|
||||
}
|
||||
|
||||
cp_p() {
|
||||
strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
|
||||
| awk '{
|
||||
count += $NF
|
||||
if (count % 10 == 0) {
|
||||
percent = count / total_size * 100
|
||||
printf "%3d%% [", percent
|
||||
for (i=0;i<=percent;i++)
|
||||
printf "="
|
||||
printf ">"
|
||||
for (i=percent;i<100;i++)
|
||||
printf " "
|
||||
printf "]\r"
|
||||
}
|
||||
}
|
||||
END { print "" }' total_size=$(stat -c '%s' "${1}") count=0
|
||||
}
|
||||
|
||||
|
||||
# debian upgrade
|
||||
# if the first argument is void, proceed local upgrade
|
||||
# else, send command via ssh
|
||||
# assume user have sufficient permission for upgrade
|
||||
# without interaction
|
||||
#
|
||||
# Note:
|
||||
# i use sudo with the follow lines
|
||||
#
|
||||
# Cmnd_Alias DEBIAN = /usr/bin/apt-get, /usr/bin/dpkg
|
||||
# asyd ALL = PASSWD: ALL, NOPASSWD: DEBIAN
|
||||
upgrade () {
|
||||
sudo apt-get update
|
||||
sudo apt-get -u dist-upgrade -- force-yes -y
|
||||
}
|
||||
|
||||
lsperm () {
|
||||
echo $1 | perl -e 'chomp($s=<>);$p=(stat($s))[2] & 07777;printf "$s -> %04o\n",$p'
|
||||
}
|
||||
|
||||
findnosecure () {
|
||||
find / -perm +2000 -o -perm +4000 -print 2>/dev/null
|
||||
}
|
||||
|
||||
function cd () {
|
||||
if [[ -z $2 ]]; then
|
||||
if [[ -f $1 ]]; then
|
||||
builtin cd $1:h
|
||||
else
|
||||
builtin cd $1
|
||||
fi
|
||||
else
|
||||
if [[ -z $3 ]]; then
|
||||
builtin cd $1 $2
|
||||
else
|
||||
echo cd: too many arguments
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# display the NTTP message (wait a Message-Id)
|
||||
mid () {
|
||||
( echo "mode reader"; echo "article <$*>" | sed 's/%40/@/ ; s/%24/\$/g ; s/<<*/</g ; s/>>*/>/g') |
|
||||
tee /proc/self/fd/2 | nc $NNTPSERVER 119 | tail +3 }
|
||||
|
||||
set_title () {
|
||||
[ $TERM = "screen" ] && print -nR $'\033k'$1$'\033'\\
|
||||
}
|
||||
|
||||
# update screen caption, use the last argument as hostname
|
||||
ssh () {
|
||||
[[ "$*" == *"BatchMode=yes"* ]] && USE_XTABS="False"
|
||||
if [[ $USE_XTABS = "True" ]]; then
|
||||
open_new_tab ssh $@
|
||||
else
|
||||
target=$_
|
||||
target=${target//*@/}
|
||||
set_title $target
|
||||
command ssh $@
|
||||
fi
|
||||
}
|
||||
|
||||
# same for telnet
|
||||
telnet () {
|
||||
if [[ $USE_XTABS = "True" ]]; then
|
||||
open_new_tab telnet "$*"
|
||||
else
|
||||
target=$1
|
||||
set_title $target
|
||||
command telnet $*
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
# utf8
|
||||
utf8 () {
|
||||
if [[ $COLORTERM == "gnome-terminal" ]]; then
|
||||
echo -e '\e%G'
|
||||
fi
|
||||
export LC_CTYPE=fr_FR.UTF8
|
||||
unalias vi
|
||||
if [[ ! -x $(which -p vim) ]] ; then
|
||||
echo "utf8() Warning, vim not found !"
|
||||
else
|
||||
alias vi='vim "+set enc=utf8"'
|
||||
fi
|
||||
}
|
||||
|
||||
14
rc/history.rc
Normal file
14
rc/history.rc
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# History options
|
||||
#
|
||||
|
||||
setopt EXTENDED_HISTORY # add a timestamp and the duration of each command
|
||||
setopt SHARE_HISTORY # _all_ zsh sessions share the same history files
|
||||
setopt HIST_IGNORE_ALL_DUPS # ignores duplications
|
||||
setopt HIST_IGNORE_SPACE
|
||||
|
||||
HISTFILE=$ZDOTDIR/histories/$(hostname)
|
||||
HISTSIZE=1000000
|
||||
SAVEHIST=1000000
|
||||
|
||||
export HISTFILE HISTSIZE SAVEHIST
|
||||
16
rc/misc.rc
Normal file
16
rc/misc.rc
Normal file
@@ -0,0 +1,16 @@
|
||||
# -*- shell-script -*-
|
||||
|
||||
periodic () {
|
||||
rehash
|
||||
}
|
||||
|
||||
export PERIOD=300
|
||||
|
||||
# Zftp
|
||||
|
||||
# load zftp module
|
||||
#autoload -U zfinit
|
||||
#zfinit
|
||||
|
||||
# email address for anonymous ftp
|
||||
#export EMAIL_ADDR=enjoy.zsh@foo.bar
|
||||
27
rc/options.rc
Normal file
27
rc/options.rc
Normal file
@@ -0,0 +1,27 @@
|
||||
# -*- shell-script -*-
|
||||
#
|
||||
# Zsh Options
|
||||
#
|
||||
|
||||
export LISTPROMPT # in order to scroll if completion list is too big
|
||||
|
||||
setopt auto_cd # a commande like % /usr/local is equivalent to cd /usr/local
|
||||
setopt nohup # don't send HUP signal when closing term session
|
||||
setopt extended_glob # in order to use #, ~ and ^ for filename generation
|
||||
setopt always_to_end # move to cursor to the end after completion
|
||||
setopt notify # report the status of backgrounds jobs immediately
|
||||
setopt correct # try to correct the spelling if possible
|
||||
setopt rmstarwait # wait 10 seconds before querying for a rm which contains a *
|
||||
setopt auto_pushd # Always push directory in stack
|
||||
setopt pushdminus # Invert the behavior of cd -<tab> cd +<tab>
|
||||
setopt histverify # Verify history expansion
|
||||
|
||||
|
||||
export DIRSTACKSIZE=20 # Number of directory to keep in the stack
|
||||
|
||||
# Don't erase file with >, use >| (overwrite) or >> (append) instead
|
||||
set -C
|
||||
|
||||
# Watch new users
|
||||
watch=(all)
|
||||
LOGCHECK=5
|
||||
7
rc/run-help.rc
Normal file
7
rc/run-help.rc
Normal file
@@ -0,0 +1,7 @@
|
||||
function run-help-sudo {
|
||||
if [ $# -eq 0 ]; then
|
||||
man sudo
|
||||
else
|
||||
man $1
|
||||
fi
|
||||
}
|
||||
12
rc/svnscan.rc
Normal file
12
rc/svnscan.rc
Normal file
@@ -0,0 +1,12 @@
|
||||
if which svn > /dev/null; then
|
||||
if [ -z $NOSVN ]; then
|
||||
echo "Current rev :`LANG=C svn info "$ZDOTDIR" | grep Revision | cut -d' ' -f 2`"
|
||||
if [ -z $NOSVNSCAN ]; then
|
||||
MODFILE=`svn status "$ZDOTDIR" | grep -v " L"`
|
||||
if [ `echo -n "$MODFILE" | wc -c` -gt 2 ]; then
|
||||
echo "Modified Files :"
|
||||
echo "$MODFILE"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
13
rc/titles.rc
Normal file
13
rc/titles.rc
Normal file
@@ -0,0 +1,13 @@
|
||||
if [ $TERM = "screen" ]; then
|
||||
setopt extended_glob
|
||||
preexec () {
|
||||
local CMD=${1[(wr)^(*=*|sudo|-*)]}
|
||||
# if [[ $CMD -eq "man" ]]; then
|
||||
# CMD+=" ${2[(wr)^(*=*|sudo|-*)]}"
|
||||
# fi
|
||||
echo -n "\ek$CMD\e\\"
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
|
||||
25
rc/variables.rc
Normal file
25
rc/variables.rc
Normal file
@@ -0,0 +1,25 @@
|
||||
[ -d /usr/local/info ] && export INFO_PATH="$INFO_PATH;/usr/local/info"
|
||||
|
||||
# less
|
||||
if which less > /dev/null; then
|
||||
export PAGER=less
|
||||
export LESS="-ir"
|
||||
export LESS_TERMCAP_mb=$'\E[01;31m'
|
||||
export LESS_TERMCAP_md=$'\E[01;31m'
|
||||
export LESS_TERMCAP_me=$'\E[0m'
|
||||
export LESS_TERMCAP_se=$'\E[0m'
|
||||
export LESS_TERMCAP_so=$'\E[01;44;33m'
|
||||
export LESS_TERMCAP_ue=$'\E[0m'
|
||||
export LESS_TERMCAP_us=$'\E[01;32m'
|
||||
|
||||
if which lesspipe > /dev/null; then
|
||||
export LESSOPEN="| /usr/bin/lesspipe %s"
|
||||
export LESSCLOSE="/usr/bin/lesspipe %s %s"
|
||||
fi
|
||||
fi
|
||||
|
||||
PATH=$PATH:$ZDOTDIR/bin:~/.bin:/usr/local/bin:/usr/sbin:/sbin
|
||||
|
||||
export PATH
|
||||
|
||||
export WORDCHARS="${WORDCHARS:s#/#}"
|
||||
47
rc/verify_nano_rw.rc
Normal file
47
rc/verify_nano_rw.rc
Normal file
@@ -0,0 +1,47 @@
|
||||
nano () {
|
||||
if [ -f "$1" ]; then
|
||||
if [ -w "$1" ]; then
|
||||
command nano $*
|
||||
else
|
||||
echo "Unwritable file, openning through sudoedit"
|
||||
VISUAL=nano command sudoedit $*
|
||||
fi
|
||||
else
|
||||
if [ -d "`dirname \"$1\"`" ]; then
|
||||
if [ -w "`dirname \"$1\"`" ]; then
|
||||
command nano $*
|
||||
else
|
||||
echo "Unwritable file, openning through sudoedit"
|
||||
VISUAL=nano command sudoedit $*
|
||||
fi
|
||||
else
|
||||
echo "Unexpected result..."
|
||||
read
|
||||
command nano $*
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
vim () {
|
||||
if [ -f "$1" ]; then
|
||||
if [ -w "$1" ]; then
|
||||
command vim $*
|
||||
else
|
||||
echo "Unwritable file, openning through sudoedit"
|
||||
VISUAL=vim command sudoedit $*
|
||||
fi
|
||||
else
|
||||
if [ -d "`dirname \"$1\"`" ]; then
|
||||
if [ -w "`dirname \"$1\"`" ]; then
|
||||
command vim $*
|
||||
else
|
||||
echo "Unwritable file, openning through sudoedit"
|
||||
VISUAL=vim command sudoedit $*
|
||||
fi
|
||||
else
|
||||
echo "Unexpected result..."
|
||||
read
|
||||
command vim $*
|
||||
fi
|
||||
fi
|
||||
}
|
||||
15
rc/zle.rc
Normal file
15
rc/zle.rc
Normal file
@@ -0,0 +1,15 @@
|
||||
# vim: set syntax=zsh:
|
||||
|
||||
# Use emacs bindkey
|
||||
bindkey -e
|
||||
|
||||
bindkey '^U' backward-kill-line
|
||||
|
||||
#zle -N insert-root-prefix
|
||||
autoload -U insert-root-prefix
|
||||
zle -N insert-root-prefix
|
||||
bindkey "^[f" insert-root-prefix
|
||||
|
||||
# Use control-<left|right> arrows to move through words
|
||||
bindkey '^[[1;5D' vi-backward-word
|
||||
bindkey '^[[1;5C' vi-forward-word
|
||||
33
rc/zstyle.rc
Normal file
33
rc/zstyle.rc
Normal file
@@ -0,0 +1,33 @@
|
||||
# vim: set syntax=zsh:
|
||||
# -*- shell-script -*-
|
||||
|
||||
# Global completion behavior
|
||||
zstyle ':completion:*' completer _complete _prefix _approximate
|
||||
zstyle ':completion:*:complete:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
|
||||
zstyle ':completion:*' max-errors 1
|
||||
zstyle ':completion:*' use-ip true
|
||||
|
||||
# Use 'ps -au$USER' for fetch user process list
|
||||
zstyle ':completion:*:processes' command 'ps -au$USER'
|
||||
|
||||
# Verbose mode
|
||||
zstyle ':completion:*:descriptions' format '%B%d%b'
|
||||
|
||||
# Use cache
|
||||
zstyle ':completion:*' use-cache on
|
||||
zstyle ':completion:*' cache-path $ZDOTDIR/cache
|
||||
|
||||
zstyle ':completion:*' ignore-parents parent pwd
|
||||
|
||||
zstyle ':completion:*:*:zless:*' file-patterns '*(-/):directories *.gz:all-files'
|
||||
zstyle ':completion:*:*:gqview:*' file-patterns '*(-/):directories :(#i)*.(png|jpeg|jpg):all-files'
|
||||
zstyle ':completion:*:*:lintian:*' file-patterns '*(-/):directories *.deb'
|
||||
zstyle ':completion:*:*:evince:*' file-patterns '*(-/):directories (#i)*.(pdf|ps)'
|
||||
|
||||
zstyle ':completion:*:*:less:*' ignored-patterns '*.gz'
|
||||
zstyle ':completion:*:*:zcompile:*' ignored-patterns '(*~|*.zwc)'
|
||||
|
||||
# few simple completion definitions
|
||||
compdef _hosts mtr
|
||||
compdef _hosts rdesktop
|
||||
compdef _gnu_generic sort
|
||||
Reference in New Issue
Block a user