257
|
1 export TERM=xterm-256color
|
|
2 export SHELL=bash
|
|
3
|
|
4 prompt_env() {
|
|
5 prompt_jobs=$(jobs | wc -l)
|
|
6 prompt_branch=$(hg branch 2> /dev/null | awk -- '{print "on "$1}')
|
|
7
|
|
8 PS1="\[\e[36m\]\A \[\e[1;34m\]\[\e[35m\]\H\[\e[1;34m\] \w\[\e[0m\] \[\e[32m\]$prompt_branch\[\e[0m\]\n$prompt_jobs > \[\e[0m\]"
|
|
9 }
|
|
10
|
|
11 PROMPT_COMMAND=prompt_env
|
|
12 PS1="\[\e[36m\]\A \[\e[1;34m\]\[\e[35m\]\H\[\e[1;34m\] \w\[\e[0m\] \[\e[32m\]$prompt_branch\[\e[0m\]\n$prompt_jobs > \[\e[0m\]"
|
|
13
|
|
14
|
|
15 alias ll="ls -lAvhtr --color"
|
|
16 alias l=ll
|
|
17 alias fgrep='fgrep -nrI --color --exclude-dir=.hg --exclude=*.log --exclude=*.dup --exclude=*.orig --exclude=transcript --exclude=tags --exclude=Session.vim'
|
|
18 alias xclip='xclip -selection clipboard'
|
|
19 alias mvim=gvim
|
|
20
|
|
21 export HISTCONTROL=erasedups
|
|
22 export HISTSIZE=10000
|
|
23 export HISTFILESIZE=20000
|
|
24 shopt -s histappend
|
|
25 shopt -s cmdhist
|
|
26 export HISTINGORE="pwd:ls:history"
|
|
27
|
258
|
28 export XDG_CONFIG_HOME=$HOME/.config
|
|
29
|
257
|
30 PATH=$HOME/bin:$PATH
|
|
31
|
|
32 cd_func ()
|
|
33 {
|
|
34 local x2 the_new_dir adir index
|
|
35 local -i cnt
|
|
36
|
|
37 if [[ $1 == "--" ]]; then
|
|
38 dirs -v
|
|
39 return 0
|
|
40 fi
|
|
41
|
|
42 the_new_dir=$1
|
|
43 [[ -z $1 ]] && the_new_dir=$HOME
|
|
44
|
|
45 if [[ ${the_new_dir:0:1} == '-' ]]; then
|
|
46 #
|
|
47 # Extract dir N from dirs
|
|
48 index=${the_new_dir:1}
|
|
49 [[ -z $index ]] && index=1
|
|
50 adir=$(dirs +$index)
|
|
51 [[ -z $adir ]] && return 1
|
|
52 the_new_dir=$adir
|
|
53 fi
|
|
54
|
|
55 #
|
|
56 # '~' has to be substituted by ${HOME}
|
|
57 [[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
|
|
58
|
|
59 #
|
|
60 # Now change to the new dir and add to the top of the stack
|
|
61 pushd "${the_new_dir}" > /dev/null
|
|
62 [[ $? -ne 0 ]] && return 1
|
|
63 the_new_dir=$(pwd)
|
|
64
|
|
65 #
|
|
66 # Trim down everything beyond 11th entry
|
|
67 popd -n +11 2>/dev/null 1>/dev/null
|
|
68
|
|
69 #
|
|
70 # Remove any other occurence of this dir, skipping the top of the stack
|
|
71 for ((cnt=1; cnt <= 10; cnt++)); do
|
|
72 x2=$(dirs +${cnt} 2>/dev/null)
|
|
73 [[ $? -ne 0 ]] && return 0
|
|
74 [[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
|
|
75 if [[ "${x2}" == "${the_new_dir}" ]]; then
|
|
76 popd -n +$cnt 2>/dev/null 1>/dev/null
|
|
77 cnt=cnt-1
|
|
78 fi
|
|
79 done
|
|
80
|
|
81 return 0
|
|
82 }
|
|
83
|
|
84 cd_min () {
|
|
85 cd -$1
|
|
86 }
|
|
87
|
|
88 _cd_min() {
|
|
89 local cur opts
|
|
90 cur="${COMP_WORDS[COMP_CWORD]}"
|
|
91 opts=$(dirs -v)
|
|
92 COMPREPLY=($(compgen -W "${opts}" --${cur}))
|
|
93 }
|
|
94 complete -F _cd_min cd_min
|
|
95
|
|
96 alias cd=cd_func
|
|
97
|
|
98 alias psm='/bin/ps -u $USER --sort pgid,time,size,time,pcpu -o pid,pgid,state,user,start_time,time,size:9,pcpu,command --forest'
|
|
99
|
|
100 export EDITOR=nvim
|
|
101 export HGEDITOR=nvim
|
|
102
|
|
103 stty > /dev/null
|
|
104
|
|
105 # Options
|
|
106 shopt -s globstar
|
|
107 shopt -s autocd
|
|
108 shopt -s cdspell
|
|
109 shopt -s dirspell
|
|
110 shopt -s histverify
|
|
111 shopt -s nocaseglob
|
|
112
|
|
113 set -o vi
|
|
114
|
|
115 # Load mercurial autocompletion
|
|
116 if [ -f /etc/bash_completion ]; then
|
|
117 source /etc/bash_completion
|
|
118 fi
|
|
119
|
|
120
|
|
121 [ -f ~/.fzf.bash ] && source ~/.fzf.bash
|
|
122 export FZF_DEFAULT_COMMAND='ag -g ""'
|
|
123 source ~/.config/bash/fzf_aliases
|
|
124
|
|
125
|
|
126 export NVM_DIR="$HOME/.nvm"
|
|
127 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
128 [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
|
129
|
|
130 [ -f ~/.bashrc.local ] && source ~/.bashrc.local
|