~ jhdf /.bashrc

#########################################################################
#
# Last modified Sun 02 Apr 2006 11:02:15 AM 
#
#########################################################################

# Source the system files
for file in /etc/{bashrc,bash_completion}
do
        [ -r $file ] && . $file
done

# Better LS_COLORS
eval $(dircolors)

# Listing
lls () { ls --color=always -lh "$@" | less -RS; }
alias lsd='"ls" --color=always -Cd */ | sed '\''s/\///g'\'
alias ls='ls --color=tty'

# ps output sorted by lstart
alias pstimes='ps -eo lstart,comm,user --sort lstart'

# Names of open files
alias lsofnames="lsof | awk '!/^\$/ && /\// { print \$9 }' | sort -u"

alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'

# Dirstack
alias d='dirs -v'
j ()
{
        if (($# == 1 && ${#1})) && [[ $1 != *[^0-9]* ]]; then
                # Single numeric argument
                pushd +$1 >/dev/null
        else
                pushd "$@" >/dev/null
        fi
}
k ()
{
        if (($# == 1 && ${#1})) && [[ $1 != *[^0-9]* ]]; then
                # Single numeric argument
                popd +$1 >/dev/null
        else
                popd "$@" >/dev/null
        fi
}

jl ()
{
        j "$@" && ls
}
[[ $BASH_COMPLETION ]] && complete -o filenames -o nospace -F _cd j jl

# We use it too much
alias a=apt-cache
[[ $BASH_COMPLETION ]] && complete -o filenames -F _apt_cache a

# Source aliases and functions
for file in ~/.{aliases,functions}{,.local}
do
        [ -r $file ] && . $file
done; unset file

# Avoid history losses when using multiple terminals
PROMPT_COMMAND='history -a'
shopt -s histappend

# Do not treat multiple line commands as a single entry
shopt -u cmdhist

# Decent sized history
HISTSIZE=2500
HISTFILESIZE=2500

# Ignore consecutive executions of the same command
HISTIGNORE='&'
if [ ${BASH_VERSINFO[0]} -ge 3 ]; then
        HISTCONTROL=ignoredups
        HISTTIMEFORMAT='%a %b %d %T  $ '
#        if [[ $TERM == *xterm* ]]; then
#                __set_window_title ()
#                {
#                        [ -t 1 ] || return
#                        local line=$(history 1)
#                        echo -n $'\033'"]2;\$${line#*$}"$'\007'
#                }
#                trap __set_window_title DEBUG
#        fi
#else
#        if [[ $TERM == *xterm* ]]; then
#                __set_window_title ()
#                {
#                        [ -t 1 ] || return
#                        local line=$(history 1)
#                        echo -n $'\033'"]2;\$ ${line:7}"$'\007'
#                }
#                trap __set_window_title DEBUG
#        fi
### Above chunk commented out due to various corner cases; too much of
### a hack for BASH. (Running in iterations (the -t test is there, in
### large part, due to that), running with PROMPT_COMMAND, breaking `pv')
fi

# Using gdm, these are not currently set through ~/.bash_profile
PATH=~/bin:$PATH:/sbin:/usr/sbin:/usr/local/sbin

export PERLDOC_PAGER="less -Ssi"
export CVS_RSH=ssh

# Make it right for an xterm here (searching on less, e.g.)
[ -t 0 ] &&
        stty erase $'\177'

## Prompts

#PS1='\n\[\033[0;36m\]\u@\h: \[\033[0;34m\]\W\[\033[$((${COLUMNS:-80}-9))G\]\[\033[0;36m\][\t]\n\$\[\033[0m\] '
  # Ideal
if [ "$UID" != 0 ]; then
        PS1='\n\[\033[0;36m\]\u@\h: \[\033[0;34m\]\W\[\033[71G\]\[\033[0;36m\][\t]\[\033[0m\]\n\$ '
          # Vim quebrava na saída, então ficamos com a solução inflexível
else
        # root
        PS1='\n\[\033[0;33m\]\u@\h: \[\033[0;31m\]\W\[\033[71G\]\[\033[0;33m\][\t]\[\033[0m\]\n\$ '
fi

#PS1='\[\033[0;36m\][\u@\h \[\033[0;34m\]\W\[\033[0;36m\]]\$\[\033[0m\] '
#PS1='\n\[\033[0;36m\]\u@\h: \[\033[0;34m\]\W\n\[\033[0;36m\]\\$\[\033[0m\] '

#PS1='\[\033[0;36m\][\[\033[0;34m\]\W\[\033[0;36m\]]\$\[\033[0m\] '
#PS1='\[\033[0;36m\][\[\033[0;33m\]\u\[\033[0;36m\]@\[\033[0;33m\]\h \[\033[0;34m\]\W\[\033[0;36m\]]\$\[\033[0m\] '


#

# Make the prompt suitable for a dark background
if [ "$darkxterm" ]; then
        PS1="${PS1//0;/1;}"
fi

# Avoid tilde expansion from the bash_completion script
_expand () 
{ 
    [ "$cur" != "${cur%\\}" ] && cur="$cur\\";
    if [[ "$cur" == \~*/* ]]; then
        #eval cur=$cur;
                :;
    else
        if [[ "$cur" == \~* ]]; then
            cur=${cur#\~};
            COMPREPLY=($( compgen -P '~' -u $cur ));
            return ${#COMPREPLY[@]};
        fi;
    fi
}
#

mcd ()
{
        mkdir "$@" && cd "${!#}"
}

cdl ()
{
        cd "$@" && ls
}
[[ $BASH_COMPLETION ]] && complete -o filenames -o nospace -F _cd cdl

# Toggle xterm's number of lines between 24 and 48
bind -x '"\e\C-s": if ((LINES < 48)); then printf %b "\033[8;48;80t"; else printf %b "\033[8;24;80t"; fi; sleep .1; echo "\$LINES = $LINES"'
  # (the sleep is so that $LINES can be updated)

# This should be working from .inputrc, but for some reason isn't, so..
bind '"\eg": "| grep "'