#!/bin/bash

DGREEN='\e[1;32m\]'
LGREEN='\e[0;32m\]'
DBLUE='\e[1;34m\]'
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m'   # Black - Background
bakred='\e[41m'   # Red
badgrn='\e[42m'   # Green
bakylw='\e[43m'   # Yellow
bakblu='\e[44m'   # Blue
bakpur='\e[45m'   # Purple
bakcyn='\e[46m'   # Cyan
bakwht='\e[47m'   # White
txtrst='\e[0m'    # Text Reset
shopt -s checkwinsize # For hr='=='stuff to work.
hr='============================================================================================================================================================='
#PS1="${txtpur}===${txtrst}\$ "
#PS1='\n\$ '
# The next line is fully working.
PS1='${hr::COLUMNS}\r\n\[\e[1;32m\]\s-\v, \[\e[0;32m\]\[email protected]\u, \d \t \n\$PWD=\[\e[1;36m\]"\w" \[\e[1;37m\] \n\$ \[\e[1;37m\]'




#printf "%$(tput cols)s\n"|tr ' ' '='
#PS1='[email protected]$HOSTNAME ${hr::COLUMNS-${#USER}-${#HOSTNAME}-2}\n\w\$ '



#cd $HOME

# Bash_Completion {{{
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi
# }}}

# Aliases {{{
#alias webstart='sudo /etc/rc.d/mysqld start && /etc/rc.d/httpd start'
#alias webstop='sudo /etc/rc.d/mysqld stop && /etc/rc.d/httpd stop'
alias ls="ls --color"
alias P='pacman-color'
alias g='gvim --remote'
alias my_brigth='pkexec gnome-power-backlight-helper --set-brightness 8'
alias ILOVE="espeak -v pt+m3 'Catiane, eu te amo demais.'"
# List directories first. (There is a function in this file
# called 'lsf' to show only files that are not directories.)
alias lsd='ls --group-directories-first'
alias NM='sudo /etc/rc.d/networkmanager start'
alias NMs='sudo /etc/rc.d/networkmanager stop'
alias IPtables_amule_4662_4672='sudo iptables -I INPUT 1 -p tcp --dport 4662 -j ACCEPT && sudo iptables -I INPUT 2 -p tcp --dport 4672 -j ACCEPT'

# }}} Aliases end here.

# Environment Variables {{{
# O 'most' é mais colorido, mas tem que usar os arrow keys.
#export PAGER="/usr/bin/most"
# O 'less' tem os keybindings iguais ao vim hjkl, etc.
export PAGER='/bin/less'
export DE=GNOME
export BROWSER='firefox'
export EDITOR='/usr/bin/vim'
#export TERM="xterm-256color"
#export LC_ALL="en_US.UTF-8"
# }}} Environment Variables ends here.

# Works with cd commands. vim my_file.txt (which is inside on of the dirs
# listed bellow) does not work.
#export CDPATH=.:~/:~/Documents:~/Websites/jeditux.home/:~/Info_Tech/System_Config/:~/Info_Tech/

# Set the correct $TERM for xterm. {{{
#if [ -e /usr/share/terminfo/x/xterm-256color ]; then
#    export TERM='xterm-256color'
#else
#    export TERM='xterm-color'
#fi
# }}}

# SET TERM to get allong well with VIM - gnome-terminal {{{
# Set $TERM for libvte terminals that set $TERM wrong (like gnome-terminal)
# -->  It seems I don't need this if I have the if-else above.
#{
#  [ "_$TERM" = "_xterm" ] && type ldd && type grep && type tput && [ -L "/proc/$PPID/exe" ] && {
#    if ldd /proc/$PPID/exe | grep libvte; then
#      if [ "`tput -Tgnome-256color colors`" = "256" ]; then
#        TERM=gnome-256color
#      elif [ "`tput -Txterm-256color colors`" = "256" ]; then
#        TERM=xterm-256color
#      elif tput -T gnome; then
#        TERM=gnome
#      fi
#    fi
#  }
#} >/dev/null 2>/dev/null
# }}}
# My try - thanks to 'ohsix' in #Gnome on freenode.
if [[ $COLORTERM == 'gnome-terminal' ]]; then
    export TERM='xterm-256color'
fi

# Some useful functions: {{{

# Shows only files that are not directories.
lsf() { /bin/ls -F1 "[email protected]" | egrep -v '/$'| sort -d; }

function title { # {{{
unset PROMPT_COMMAND
echo -en "\033]2;$1\007"
}
# }}}

function icon_label {
echo -en "\033]1;$1\007"
}

function GetIp() {
curl -s -m 5 http://meuip.datahouse.com.br/ | grep "Meu ip - " | sed -e 's/<title>Meu ip - Qual &eacute; o Meu IP? //g' -e 's/<\/title>//g'
curl -s -m 5 http://meuip.datahouse.com.br/ | grep "Meu ip" | sed "s/^.* \([0-9.]*\).*/\1/g"
}

# }}} Some useful functions ends here.

# Proxy Ifsul:
function ifsul_proxy() { # {{{
#echo -n 'Username: '
#read -e username
#echo -n 'Password: '
#read -es password
#echo ''
echo 'Setting variable "http_proxy"...'
#export http_proxy="http://$username:[email protected]:8080/"
export http_proxy="http://172.17.0.1:8080/"
echo 'Setting variable "https_proxy..."'
export https_proxy="https://172.17.0.1:8080/"
echo 'Setting variable "ftp_proxy"...'
#export ftp_proxy="http://$username:[email protected]:8080/"
export ftp_proxy="http://172.17.0.1:8080/"
echo 'Done!'
} # }}}

function ifsul_proxyoff() { # {{{
unset HTTP_PROXY
unset http_proxy
unset FTP_proxy
unset ftp_proxy
echo -e "\nProxy environment variables removed!"
} # }}}

### Pacman - The Arch Linux Package Manager! ###
pacs() { # {{{
    local CL='\\e['
    local RS='\\e[0;0m'

    echo -e "$(pacman -Ss "[email protected]" | sed "
    /^core/		s,.*,${CL}1;31m&${RS},
    /^extra/	s,.*,${CL}0;32m&${RS},
    /^community/	s,.*,${CL}1;35m&${RS},
    /^[^[:space:]]/	s,.*,${CL}0;36m&${RS},
    ")"
} # }}}

# Run with: Build hello.c
Build() {
    gcc -std=c99 -Wall -pedantic -o "${1%.c}" "$1";
};
MakeBin() { 
    # %.c drops the '.c'
    gcc -std=c99 -Wall -pedantic -o "${1%.c}.bin" "${1}";
    mv ./*.bin ./Bin
};
C_compile_to_bin() { 
    # %.c drops the '.c'
    gcc -std=c99 -Wall -pedantic -o "${1%.c}.bin" "${1}";
    mv ./*.bin ./Bin
};

# vim: nowrap
# vim: foldmethod=marker foldmarker={{{,}}}:
# ""vim: set nomodifiable nowrite readonly: