append a session's history on shell exit and unlimited history list
[lab.git] / TipAndDoc / .bashrc
1
2 umask 022   # create new file with '644'
3 ulimit -c 0 # no dump core
4 export PAGER=less
5 export LESS='-FRX -i -P ?f%f:(stdin).  ?lb%lb?L/%L..  [?eEOF:?pb%pb\%..]'
6
7 set -o notify   # notify end of background job immediately
8
9 shopt -s histappend     # append command history instead of overwrite
10 shopt -s checkhash      # check always PATH hash table
11 shopt -s cmdhist        # save multi lines command to one line
12 shopt -s no_empty_cmd_completion    # no complementation with no input
13 shopt -s histverify     # check command history before execute
14 shopt -s histappend
15
16 # unlimited history list
17 export HISTFILESIZE=-1
18 export HISTSIZE=-1
19
20
21 # view last 30 history or search from last 1000 history
22 function i {
23     if [ "$1" ]; then history 1000 | grep "$@"; else history 30; fi
24 }
25
26 # view last 30 history or search from all history
27 function I {
28     if [ "$1" ]; then history | grep "$@"; else history 30; fi
29 }
30
31 if [ -f /usr/share/git/completion/git-prompt.sh ]; then
32     source /usr/share/git/completion/git-prompt.sh
33     export PS1='\u@\h:\w$(__git_ps1)\$ '
34 else
35     export PS1='\u@\h:\w\$ '
36 fi
37
38 agent="$HOME/.ssh/ssh-agent-$USER"
39 if [ -S "$SSH_AUTH_SOCK" ]; then
40     case $SSH_AUTH_SOCK in
41     /tmp/*/agent.[0-9]*)
42         ln -snf "$SSH_AUTH_SOCK" $agent && export SSH_AUTH_SOCK=$agent
43     esac
44 elif [ -S $agent ]; then
45     export SSH_AUTH_SOCK=$agent
46 else
47     echo "no ssh-agent"
48 fi
49
50 if [ -d "$HOME/bin" ]; then
51     PATH="$HOME/bin:$PATH"
52 fi
53
54 alias vi='vim'
55 alias sudo='sudo -H '
56 alias rm='rm -v'
57 alias screen='screen -U -R'
58 alias mv='mv -i'
59 alias cp='cp -i'