comparison dot_bashrc @ 257:d726921aaabe

Clean start of dotfiles repo
author zegervdv <zegervdv@me.com>
date Thu, 21 May 2020 11:28:36 +0200
parents
children e76bb97c0099
comparison
equal deleted inserted replaced
-1:000000000000 257:d726921aaabe
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
28 PATH=$HOME/bin:$PATH
29
30 cd_func ()
31 {
32 local x2 the_new_dir adir index
33 local -i cnt
34
35 if [[ $1 == "--" ]]; then
36 dirs -v
37 return 0
38 fi
39
40 the_new_dir=$1
41 [[ -z $1 ]] && the_new_dir=$HOME
42
43 if [[ ${the_new_dir:0:1} == '-' ]]; then
44 #
45 # Extract dir N from dirs
46 index=${the_new_dir:1}
47 [[ -z $index ]] && index=1
48 adir=$(dirs +$index)
49 [[ -z $adir ]] && return 1
50 the_new_dir=$adir
51 fi
52
53 #
54 # '~' has to be substituted by ${HOME}
55 [[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
56
57 #
58 # Now change to the new dir and add to the top of the stack
59 pushd "${the_new_dir}" > /dev/null
60 [[ $? -ne 0 ]] && return 1
61 the_new_dir=$(pwd)
62
63 #
64 # Trim down everything beyond 11th entry
65 popd -n +11 2>/dev/null 1>/dev/null
66
67 #
68 # Remove any other occurence of this dir, skipping the top of the stack
69 for ((cnt=1; cnt <= 10; cnt++)); do
70 x2=$(dirs +${cnt} 2>/dev/null)
71 [[ $? -ne 0 ]] && return 0
72 [[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
73 if [[ "${x2}" == "${the_new_dir}" ]]; then
74 popd -n +$cnt 2>/dev/null 1>/dev/null
75 cnt=cnt-1
76 fi
77 done
78
79 return 0
80 }
81
82 cd_min () {
83 cd -$1
84 }
85
86 _cd_min() {
87 local cur opts
88 cur="${COMP_WORDS[COMP_CWORD]}"
89 opts=$(dirs -v)
90 COMPREPLY=($(compgen -W "${opts}" --${cur}))
91 }
92 complete -F _cd_min cd_min
93
94 alias cd=cd_func
95
96 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'
97
98 export EDITOR=nvim
99 export HGEDITOR=nvim
100
101 stty > /dev/null
102
103 # Options
104 shopt -s globstar
105 shopt -s autocd
106 shopt -s cdspell
107 shopt -s dirspell
108 shopt -s histverify
109 shopt -s nocaseglob
110
111 set -o vi
112
113 # Load mercurial autocompletion
114 if [ -f /etc/bash_completion ]; then
115 source /etc/bash_completion
116 fi
117
118
119 [ -f ~/.fzf.bash ] && source ~/.fzf.bash
120 export FZF_DEFAULT_COMMAND='ag -g ""'
121 source ~/.config/bash/fzf_aliases
122
123
124 export NVM_DIR="$HOME/.nvm"
125 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
126 [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
127
128 [ -f ~/.bashrc.local ] && source ~/.bashrc.local