shopt -s checkwinsize #Pour pas s'écrire dessus shopt -s histappend ##shopt -s autocd #Like zsh PROMPT_COMMAND='history -a' #For autocompletions #function have() { return 1; } #Some files use have: suppress warnings (yeah: 2>.. ) #function _completion_loader() { return 1; } #cd /usr/share/bash-completion/completions #for i in *; do source ./$i; done #unset have #unset _completion_loader complete -cf sudo complete -cf man man() { env LESS_TERMCAP_mb=$'\E[01;31m' \ LESS_TERMCAP_md=$'\E[01;38;5;74m' \ LESS_TERMCAP_me=$'\E[0m' \ LESS_TERMCAP_se=$'\E[0m' \ LESS_TERMCAP_so=$'\E[38;5;246m' \ LESS_TERMCAP_ue=$'\E[0m' \ LESS_TERMCAP_us=$'\E[04;38;5;146m' \ man "$@" } #####ON DEFINIT LES COULEURS red='\033[31m' RED='\033[31m\033[01m' blue='\033[34m' BLUE='\033[34m' cyan='\033[36m' CYAN='\033[36m' magenta='\033[35m' DFT='\033[0m' white='\033[37m' #####ON DÉFINIT LE TITRE DE LA FENETRE PAR LE REP EN COURS case "$TERM" in xterm*|rxvt*) PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"' ;; *) ;; esac #####LA COULEUR DU SHELL #PS1="$RED\u$DFT$white@$magenta\h $DFT>>$CYAN\w $DFT" #PS1="\u@\h >>\w " #PS1="\[$RED\u$DFT$white@$magenta\h $DFT>>$CYAN\w $DFT\]" #PS1="\[$RED\]\u\[$DFT$white\]@\[$magenta\]\h \[$DFT\]>>\[$CYAN\]\w \[$DFT\]" #PROMPT_COMMAND='history -a;echo -en "\033[m\033[38;5;2m"$(( `sed -nu "s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo`/1024))"\033[38;5;22m/"$((`sed -nu "s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip" /proc/meminfo`/1024 ))MB"\t\033[m\033[38;5;55m$(< /proc/loadavg)\033[m"' if [ "$HOSTNAME" == "chuck" ]; then MY_HOST_COL='[31m' #ugly ! else MY_HOST_COL='[34m' fi #PS1='\[\e[0;36m\]\t \[\e[1;30m\][\[\e$MY_HOST_COL\]\u@\H\[\e[1;30m\]\[\e[0;32m\]\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n$ ' source ~/.bash_ps1 #PS1='\[\e[0;36m\] \T \[\e[1;30m\][\[\e$MY_HOST_COL\]\u@\H\[\e[1;30m\]\[\e[0;32m\]\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n$ ' ############### #### ALIAS #### ############### # {{{ alias ..='cd ..' alias vf='cd' alias xs='cd' alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' alias vm='mv -i' alias df='dfc' alias free='freec' alias shred='shred -n 35 -z -u -v -f' if [ "$TERM" != "dumb" ]; then eval "`dircolors -b`" alias ls='ls --color=auto' fi alias sl='ls' alias la='ls -lah' alias sudp='sudo' #fuck tpyos :p alias sudpo='sudo' alias halt='sudo poweroff' #alias pacman='pacman-color' alias pacmacn='pacman' # '[r]emove [o]rphans' - recursively remove ALL orphaned packages alias pacro="/usr/bin/pacman -Qtdq > /dev/null && sudo /usr/bin/pacman -Rns \$(/usr/bin/pacman -Qtdq | sed -e ':a;N;\$!ba;s/\n/ /g')" alias grep='grep --color' alias b+='xbacklight -inc 10% -steps 1 -time 0' alias b-='xbacklight -dec 10% -steps 1 -time 0' alias svim='sudo vim' alias bim='vim' alias vi='vim' alias VIM='vim' alias ivm='vim' alias gl='git log --graph --abbrev-commit --pretty=oneline --decorate' alias gitst='git status' alias git_mail='git send-email --annotate --compose origin' alias poule='git pull' alias makew='make' alias BSI2='cd ~/Documents/UniGE/BSI2*/' BSI3_PATH='/home/frank/Documents/UniGE/BSI3 - 2013-2014/' alias BSI3='cd "$BSI3_PATH"' OCTOPUS=~/.my_utils/octopus.sh alias dual='$OCTOPUS monitor dual' alias laptop='$OCTOPUS monitor laptop' alias extern='$OCTOPUS monitor extern' alias clone='$OCTOPUS monitor clone' alias volup='$OCTOPUS volume up' alias voldown='$OCTOPUS volume down' alias volmute='$OCTOPUS volume mute' alias suspend='$OCTOPUS suspend' alias mfilms='cd /dev/shm && mkdir films && sshfs frank@vi-di.fr:/media/ films/' alias muni='cd /dev/shm && mkdir uni && sshfs villaro0@pc69240:/user/l1/2011/villaro0/ uni/' alias upgrub='sudo grub-mkconfig -o /boot/grub/grub.cfg' alias upkey='gpg --keyserver subkeys.pgp.net --send-key 6F36914A' alias shm='cd /dev/shm' alias ip6='ip -6' alias disk-usage-analyser='baobab' alias op='xdg-open' alias o='octave' alias cdu='cdu -idh' alias dus='du -sh * | sort -h' alias im='profanity' # }}} ############### ## FONCTIONS ## ############### # {{{ function cd() { # {{{ if [ $# -eq 0 ]; then builtin cd ~ && ls else builtin cd "$*" && ls fi } #}}} alias ssh='my_ssh' function my_ssh { # {{{ ssh-add -l | grep id_rsa.auth > /dev/null if [ $? -eq 1 ]; then echo -e "$RED Please enter ssh passphrase ;) $DFT" ssh-add ~/.ssh/id_rsa.auth fi; "/usr/bin/ssh" $* } # }}} alias scp='my_scp' function my_scp { # {{{ ssh-add -l | grep id_rsa.auth > /dev/null if [ $? -eq 1 ]; then echo -e "$RED Please enter ssh passphrase ;) $DFT" ssh-add ~/.ssh/id_rsa.auth fi; "/usr/bin/scp" $* } # }}} function logs { # {{{ tail -f $1 | ccze -A } # }}} function mkcd() { # {{{ mkdir -p "$@" cd "$@" } # }}} extract() { # {{{ local e=0 i c for i; do if [ -f $i && -r $i ]; then c= case $i in *.tar.bz2) c='tar xjf' ;; *.tar.gz) c='tar xzf' ;; *.bz2) c='bunzip2' ;; *.gz) c='gunzip' ;; *.tar) c='tar xf' ;; *.tbz2) c='tar xjf' ;; *.tgz) c='tar xzf' ;; *.7z) c='7z x' ;; *.Z) c='uncompress' ;; *.exe) c='cabextract' ;; *.rar) c='unrar x' ;; *.xz) c='unxz' ;; *.zip) c='unzip' ;; *) echo "$0: cannot extract \`$i': Unrecognized file extension" >&2; e=1 ;; esac [ $c ] && command $c "$i" else echo "$0: cannot extract \`$i': File is unreadable" >&2; e=2 fi done return $e } # }}} function study() { if [ -z $1 ]; then STUDY_PATH='' else if [ -d "$BSI3_PATH$1" ]; then STUDY_PATH="$1" else STUDY_PATH='' fi fi builtin cd "$BSI3_PATH$STUDY_PATH" if [ -e calendar ]; then echo -e "$RED WORK TO DO SOON:$BLUE" calendar -A10 echo -e "$DFT" fi ls } _StudyCompletion() { # {{{ local cur # Pointer to current completion word. COMPREPLY=() # Array variable storing the possible completions. cur=${COMP_WORDS[COMP_CWORD]} _STUDY_ACTUAL_DIR=`pwd` builtin cd "$BSI3_PATH" ALL_POSSIBLE_WORDS=(*) builtin cd "$_STUDY_ACTUAL_DIR" for i in ${ALL_POSSIBLE_WORDS[@]}; do # echo ">>>$i" WORD=$(echo $i | grep "^$cur" | tr -d ' ') #ugly if [ $WORD ]; then COMPREPLY+=("$WORD"); fi; done return 0 } # }}} complete -F _StudyCompletion -o filenames study ## FIXME TO IMPROVE WITH VARIOUS locations (ex: ro 1; ro 2; ro 3) RO_ROOT_DIRECTORY=/dev/shm/ro_$USER function ro() { # {{{ if [ ! -d $RO_ROOT_DIRECTORY ]; then mkdir $RO_ROOT_DIRECTORY fi if [ -z $1 ]; then my_root_set=`cat $RO_ROOT_DIRECTORY/default 2>/dev/null` else my_root_set=`cat $RO_ROOT_DIRECTORY/$1 2>/dev/null` fi; if [ -n "$my_root_set" ]; then cd $my_root_set; else if [ -z $1 ]; then echo -e "root for flag $1 not set.\nSet-it with roset $1" else echo "root not set ! set it with roset !"; fi fi; } # }}} function roset() { # {{{ if [ ! -d $RO_ROOT_DIRECTORY ]; then mkdir $RO_ROOT_DIRECTORY fi if [ -z $1 ]; then pwd > $RO_ROOT_DIRECTORY/default else pwd > $RO_ROOT_DIRECTORY/$1 fi } # }}} _RoRosetCompletion() { # {{{ local cur # Pointer to current completion word. COMPREPLY=() # Array variable storing the possible completions. cur=${COMP_WORDS[COMP_CWORD]} _ROSET_ACTUAL_DIR=`pwd` builtin cd $RO_ROOT_DIRECTORY ALL_POSSIBLE_WORDS=(*) builtin cd $_ROSET_ACTUAL_DIR # echo "Cur: >>$cur<<" for i in ${ALL_POSSIBLE_WORDS[@]}; do # echo ">>>$i" WORD=$(echo $i | grep "^$cur" | tr -d ' ') #ugly if [ $WORD ]; then # echo "blah!: >>$WORD<<" COMPREPLY+=("$WORD"); fi; done return 0 } # }}} complete -F _RoRosetCompletion -o filenames ro roset function calc() { echo "scale=3;$@" | bc -l } function xournal() { if [ -e "$1".xoj ]; then /usr/bin/xournal "$1".xoj else /usr/bin/xournal "$1" fi } function mutt() { if [ $# -eq 0 ]; then if [ "$(pidof mutt)" ]; then /usr/bin/mutt -R else /usr/bin/mutt fi; else /usr/bin/mutt $@ fi; } function latex2pdf() { test #$ -gt 1 || exit 1 tmp=tmp$$ file=/dev/shm/$tmp result=$(echo $1 | rev | cut -d. -f2- | rev).pdf sed 's/oeil/\\oe{}il/g; s/oeuvre/\\oe{}uvre/g; s/soeur/s\\oe{}ur/g; s/noeud/n\\oe{}ud/g; s/oeuf/\\oe{}uf/g; s/boeuf/b\\oe{}uf/g ' $1 > $file pdflatex $file mv $tmp.pdf $result rm -f $tmp* } # }}} SSHAGENT=/usr/bin/ssh-agent SSHAGENTARGS="-s" if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then eval `$SSHAGENT $SSHAGENTARGS` trap "kill $SSH_AGENT_PID" 0 fi ############### ### EXPORTS ### ############### # {{{ export EDITOR="vim" GPG_TTY=`tty` export GPG_TTY export GPGKEY=6F36914A export PYTHONPATH=/usr/local/lib/python2.7/dist-packages export CC=clang export DEVKITPRO=/opt/devkitpro export DEVKITARM=$DEVKITPRO/devkitARM export PATH=$PATH:$DEVKITARM/bin export MANPATH=$MANPATH:$DEVKITARM/man # }}} #Launch startx when login [[ -z $DISPLAY && $XDG_VTNR -le 4 && -z $SSH_CLIENT ]] && exec startx calendar -f ~/calendar