if [ -z "${PS1}" ]
then
    return
fi

u_on=$(tput smul)
u_off=$(tput rmul)

bold=$(tput bold)
normal=$(tput sgr0)

ns=$(ip netns identify)
ns=${ns:+⬗${u_on}${ns}${u_off}}

gp() {

    #Empty Git prompt
    return
}

if [ -e ${HOME}/.git-prompt.sh ]
then
    export GIT_PS1_SHOWDIRTYSTATE=1
    . ${HOME}/.git-prompt.sh

    gp()
    {

        ps=$(__git_ps1 '%s')

        if [ -n "${ps}" ]
        then

            echo "⬗${u_on}${ps}${u_off}"
        fi
    }
fi

if [ "${EMACS}" != "t" ]
then
    export PS1='\n${bold}\u${normal}@${u_on}\h${u_off}${ns}$(gp): \w\n> '
else
    export PS1='\n\u@\h:\w > '
fi

export TERM="xterm-256color"

ulimit -c unlimited

umask 022

bind "set completion-ignore-case on"

bind "set show-all-if-ambiguous on"

shopt -s checkwinsize

if [ "${EMACS}" != "t" ]
then
    set -o emacs
    export EDITOR="emacs -nw"
fi

HISTFILESIZE=2000

HISTSIZE=1000
shopt -s histappend

if [ -z "${SYS_PATH}" ]
then
    SYS_PATH="${PATH}"
else
    PATH="${SYS_PATH}"
fi

if [ -d ${HOME}/local ]
then
    while read -d '' bin
    do
        PATH="${bin}:${PATH}"
    done < <(find -L ${HOME}/local \
                  -mindepth 2 -maxdepth 2 -type d -iname bin -print0)
fi

if [ -d ${HOME}/local/bin ]
then
    export PATH="${HOME}/local/bin:${PATH}"
fi

if [ -d ${HOME}/bin ]
then
    export PATH="${HOME}/bin:${PATH}"
fi

export CDPATH="${HOME}"

if [ -d ${HOME}/Bitbucket ]
then
    export CDPATH=${HOME}/Bitbucket:${CDPATH}
fi

alias grep="grep --color=auto "
alias h="history 100 "
alias lf="ls -FA "
alias ll="ls -lA "

if which emacsclient > /dev/null
then
    alias ec="emacsclient --alternate-editor=emacs -n "
fi

view() { emacs -nw --eval "(find-file-read-only \"${@}\")"; }

ediff() { ec --eval "(ediff-files \"${1}\" \"${2}\")"; }

work() {
    xfce4-terminal --geometry=134x64+0-10 \
                   --default-working-directory="${HOME}/Bureau" \
                   --title=Bureau \
                   --tab --working-directory="${HOME}/Bitbucket" \
                   --title=Bitbucket \
                   > /dev/null 2>&1 & disown

    # Pourquoi ce changement 116x66-6+0 -> 103x56 ?
    emacs --geometry=103x56 > /dev/null 2>&1 & disown
}

cpmv() {
	for f in "${@}" ; do

		g=$(echo ${f} | sed -r "{

	 			 s:/$::g

	 			 s:(^[^.]*)(\.?)(.*):\1.${CPMV_EXT:-bu}\2\3:g

				 s:^\.?::g
		}")

		cmd="${CPMV_CMD:-cp -R} '${f}' '${g}'"
		echo ${cmd}
		eval ${cmd}

	done
}

alias org="CPMV_EXT=org CPMV_CMD='cp -R' cpmv "
alias old="CPMV_EXT=old CPMV_CMD=mv cpmv "
alias bu="cpmv "
