
umask 022   # create new file with '644'
ulimit -c 0 # no dump core
export PAGER=less
export LESS='-FRX -i -P ?f%f:(stdin).  ?lb%lb?L/%L..  [?eEOF:?pb%pb\%..]'

set -o notify   # notify end of background job immediately

shopt -s histappend     # append command history instead of overwrite
shopt -s checkhash      # check always PATH hash table
shopt -s cmdhist        # save multi lines command to one line
shopt -s no_empty_cmd_completion    # no complementation with no input
shopt -s histverify     # check command history before execute
shopt -s histappend

# unlimited history list
export HISTFILESIZE=-1
export HISTSIZE=-1


# view last 30 history or search from last 1000 history
function i {
    if [ "$1" ]; then history 1000 | grep "$@"; else history 30; fi
}

# view last 30 history or search from all history
function I {
    if [ "$1" ]; then history | grep "$@"; else history 30; fi
}

if [ -f /usr/share/git/completion/git-prompt.sh ]; then
    source /usr/share/git/completion/git-prompt.sh
    export PS1='\u@\h:\w$(__git_ps1)\$ '
else
    export PS1='\u@\h:\w\$ '
fi

agent="$HOME/.ssh/ssh-agent-$USER"
if [ -S "$SSH_AUTH_SOCK" ]; then
    case $SSH_AUTH_SOCK in
    /tmp/*/agent.[0-9]*)
        ln -snf "$SSH_AUTH_SOCK" $agent && export SSH_AUTH_SOCK=$agent
    esac
elif [ -S $agent ]; then
    export SSH_AUTH_SOCK=$agent
else
    echo "no ssh-agent"
fi

if [ -d "$HOME/bin" ]; then
    PATH="$HOME/bin:$PATH"
fi

alias vi='vim'
alias sudo='sudo -H '
alias rm='rm -v'
alias screen='screen -U -R'
alias mv='mv -i'
alias cp='cp -i'
