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