dotfiles/.zshrc
2018-05-03 15:21:02 +02:00

276 lines
6.8 KiB
Bash

export PATH="/sbin:/usr/local/bin:/usr/bin:/bin:/usr/games:~/bin:~/toolbox:~/hosting-run-scripts/rc-files"
export TERM=rxvt-unicode-256color
# completion
autoload -U compinit
compinit
# correction
setopt correct
#history
HISTFILE="$HOME/.zshistory"
HISTSIZE=20000
SAVEHIST=10000
alias hist='history -D -E'
setopt hist_ignore_dups
#autocd
setopt autocd
#extended wildcards
setopt extendedglob
#color adn format def
local black="%{"$'\033[00;30m'"%}"
local green="%{"$'\033[00;32m'"%}"
local red="%{"$'\033[00;31m'"%}"
local yellow="%{"$'\033[00;33m'"%}"
local blue="%{"$'\033[00;34m'"%}"
local dblue="%{"$'\033[00;34m'"%}"
local magenta="%{"$'\033[00;35m'"%}"
local cyan="%{"$'\033[00;36m'"%}"
local bgreen="%{"$'\033[03;32m'"%}"
local bcyan="%{"$'\033[03;36m'"%}"
local bold="%{"$'\033[01;39m'"%}"
local norm="%{"$'\033[00m'"%}"
setopt PROMPT_SUBST
autoload -Uz add-zsh-hook
#source /home/qgodefro/dotfiles/zshrc.sh
source ~/hosting-run-scripts/rc-files/ovhrc
export PS1="${bold}${bgreen}%n${yellow} â—‹ ${bcyan}%m ${norm}[${magenta}%~${norm}]${norm}${norm} %# ${norm}"
export RPROMPT='$(git_super_status) ${norm}(%*) (%(?.${green}0.${red}%?)${norm})${norm}'
## don't ask me 'do you wish to see all XX possibilities' before menu selection
LISTPROMPT=''
## SPROMPT - the spelling prompt
SPROMPT='zsh: correct '%R' to '%r' ? ([Y]es/[N]o/[E]dit/[A]bort) '
###########################################################################
#known hosts completion
hosts=( $(cat /etc/hosts | grep -v "^#" | awk '{print $1}'| cut -d"," -f1), $(cat $HOME/.ssh/known_hosts | awk '{print $1}'| cut -d"," -f1))
zstyle ':completion:*' hosts $hosts
## add colors to completions
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
## find all suid files
suidfind ()
{ ls -l /**/*(su0x) }
# Push the former directory in the pile when we use 'cd'
setopt auto_pushd
# Ignore repetition in the pile
setopt pushd_ignore_dups
# Do not display pile after a 'pushd' or 'popd'
setopt pushd_silent
# 'pushd' without given arguments = 'pushd $HOME'
setopt pushd_to_home
# Ask confirmation when mass deleting
unsetopt rm_star_silent
eval "$(dircolors -b $HOME/.myenv/dircolors.256dark)"
### DIRCOLORS ###
# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
[ -e "$HOME/.myenv/dircolors" ] && DIR_COLORS="$HOME/.myenv/dircolors"
[ -e "$DIR_COLORS" ] || DIR_COLORS=""
eval "`dircolors -b $DIR_COLORS`"
fi
##########################################################################
#Alias alias ...
# alias expend
alias sudo='sudo '
alias ls='ls --classify --tabsize=0 --literal --color=auto --show-control-chars --human-readable'
alias l='ls'
alias ll='ls -ahl'
# autocorrect
alias sl='ls'
alias ms='ls'
alias lq='ls'
#alias sm='ls'
alias ql='ls'
alias xs='cd'
alias vf='cd'
############
alias h='history'
#upgrading piss me off
alias upgrade='apt-get update && apt-get upgrade && apt-get clean'
alias man='man -P most'
# changing keymap quickly
alias fr='setxkbmap fr'
alias us='setxkbmap us'
alias 1='fr'
alias 2='us'
alias 3='ru'
# Command to compress/uncompress files to/from tar.gz quickly
alias ctz='tar cfvz'
alias xtz='tar zxvf'
alias xtj='tar jxvf'
alias df='df --human-readable'
alias du='du --human-readable'
alias rwin='rdesktop -g 1400x900 windesk'
alias sr='ssh -l root'
#alias ssh='ssh -2 -C -c blowfish'
alias cgrep="grep -n --color"
alias show="ls | grep --color $1"
alias p='popd'
#Opening specific files with adapted software
alias -s tex=vim
alias -s c=vim
alias -s com=w3m
alias -s fr=w3m
alias -s org=w3m
alias -s html=w3m
alias er="shred -u -z -n 25 "
alias more=less
# Special functions
###################################################
needed() {
objdump -p $1 | grep NEEDED | awk '{print $2;};'
}
status() {
print ""
print "Date..: "$(date "+%Y-%m-%d %H:%M:%S")""
print "Shell.: Zsh $ZSH_VERSION (PID = $$, $SHLVL nests)"
print "Term..: $TTY ($TERM), $BAUD bauds, $COLUMNS x $LINES cars"
print "Login.: $LOGNAME (UID = $EUID) on $HOST"
print "System: $(cat /etc/[A-Za-z]*[_-][rv]e[lr]*)"
print "Uptime:$(uptime)"
print ""
}
# searching piss me off too
s(){
apt-cache search $1 $2 $3
}
# See below...
i(){
apt-get install $1 $2 $3
}
z0() {
export TERM=xterm ; ssh qgodefro@z3.ovh.net -t -- root@$1 ; export TERM=rxvt-unicode
}
z3() {
ssh qgodefro@z3.ovh.net -t -- qgodefro@$1
}
mongs() {
ssh qgodefro@z3.ovh.net -t -- root@mon-gs.ovh.net
}
mongs2() {
ssh qgodefro@z3.ovh.net -t -- qgodefro@mon-gs2.ovh.net
}
mutu71() {
ssh qgodefro@z3.ovh.net -t -- root@mutubackup71-10g-rbx.ovh.net
}
mutu64() {
ssh qgodefro@z3.ovh.net -t -- root@mutubackup64-10g-rbx.ovh.net
}
qgodefro() {
ssh root@gw01.admings.net -p 10106
}
mpsgw() {
ssh root@5.135.111.53
}
sm() {
ssh -i /home/qgodefro/.ssh/id_rsa_sm qgodefro@213.186.33.101 -t --
}
ptsapi() {
export TERM=xterm ; ssh -i /home/qgodefro/.ssh/id_rsa_sm qgodefro@213.186.33.101 -t -- gs@10.15.21.1 ; export TERM=rxvt-unicode-256color
}
ptsmozg() {
export TERM=xterm ; ssh -i /home/qgodefro/.ssh/id_rsa_sm qgodefro@213.186.33.101 -t -- robot-gs@10.15.21.13 ; export TERM=rxvt-unicode-256color
}
meltingpot() {
export TERM=xterm ; ssh -i /home/qgodefro/.ssh/id_rsa_sm qgodefro@213.186.33.101 -t -- gs@mozg-meltingpot ; export TERM=rxvt-unicode-256color
}
sdev() {
export TERM=xterm ; ssh -i /home/qgodefro/.ssh/id_rsa_sm qgodefro@213.186.33.101 -t -- qgodefro@qgodefro.sdev ; export TERM=rxvt-unicode-256color
}
bigdata() {
export TERM=xterm ; ssh -i /home/qgodefro/.ssh/id_rsa_sm qgodefro@213.186.33.101 -t -- bigdata@mozg-bigdata ; export TERM=rxvt-unicode-256color
}
alias prestaadminca='z0 192.99.134.113'
alias prestaadminfr='z0 178.32.71.66'
alias ws='python -m SimpleHTTPServer 1024'
alias recordscreen='ffmpeg -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0+1280,0'
alias meteo='curl -4 http://wttr.in/Lyon'
goo() {
Q="$@";
GOOG_URL="http://www.google.com/search?q=";
AGENT="Mozilla/4.0";
stream=$(curl -A "$AGENT" -skLm 10 "${GOOG_URL}\"${Q/\ /+}\"" | grep -oP '\/url\?q=.+?&amp' | sed 's/\/url?q=//;s/&amp//'); echo -e "$
{stream//\%/\x}"
}
prettynetstat() {
netstat -an | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i =0; i < $1; i++) {printf("*")}; print "" }'
}
prettyroute() {
route -Cn | grep eth0 | awk '{print $2}' | awk -F: '{print $1}' | sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }'
}
established() {
for i in `netstat -an | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq`;
do
whois $i | grep -i netname | awk '{printf("%s : ",$2)}'
echo $i
done
}
rfc () { curl -s http://www.ietf.org/rfc/rfc$1.txt | less }
bindkey '^[[3~' delete-char # Del