Mercurial > dotfiles
annotate dot_bashrc @ 436:cf524a68bebc
Add local-global npm install folder to path
author | Zeger Van de Vannet <zegervdv@me.com> |
---|---|
date | Mon, 16 Aug 2021 09:14:41 +0200 |
parents | 7838713fd3b4 |
children | c72fa6d32653 |
rev | line source |
---|---|
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 |
294 | 32 PATH=$HOME/.cargo/bin:$PATH |
314
205d82eb93b4
Add local installs to path
Zeger Van de Vannet <zegervdv@me.com>
parents:
294
diff
changeset
|
33 PATH=$HOME/.local/bin:$PATH |
436
cf524a68bebc
Add local-global npm install folder to path
Zeger Van de Vannet <zegervdv@me.com>
parents:
351
diff
changeset
|
34 PATH=$HOME/.npm-global/bin:$PATH |
257 | 35 |
36 cd_func () | |
37 { | |
38 local x2 the_new_dir adir index | |
39 local -i cnt | |
40 | |
41 if [[ $1 == "--" ]]; then | |
42 dirs -v | |
43 return 0 | |
44 fi | |
45 | |
46 the_new_dir=$1 | |
47 [[ -z $1 ]] && the_new_dir=$HOME | |
48 | |
49 if [[ ${the_new_dir:0:1} == '-' ]]; then | |
50 # | |
51 # Extract dir N from dirs | |
52 index=${the_new_dir:1} | |
53 [[ -z $index ]] && index=1 | |
54 adir=$(dirs +$index) | |
55 [[ -z $adir ]] && return 1 | |
56 the_new_dir=$adir | |
57 fi | |
58 | |
59 # | |
60 # '~' has to be substituted by ${HOME} | |
61 [[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}" | |
62 | |
63 # | |
64 # Now change to the new dir and add to the top of the stack | |
65 pushd "${the_new_dir}" > /dev/null | |
66 [[ $? -ne 0 ]] && return 1 | |
67 the_new_dir=$(pwd) | |
68 | |
69 # | |
70 # Trim down everything beyond 11th entry | |
71 popd -n +11 2>/dev/null 1>/dev/null | |
72 | |
73 # | |
74 # Remove any other occurence of this dir, skipping the top of the stack | |
75 for ((cnt=1; cnt <= 10; cnt++)); do | |
76 x2=$(dirs +${cnt} 2>/dev/null) | |
77 [[ $? -ne 0 ]] && return 0 | |
78 [[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}" | |
79 if [[ "${x2}" == "${the_new_dir}" ]]; then | |
80 popd -n +$cnt 2>/dev/null 1>/dev/null | |
81 cnt=cnt-1 | |
82 fi | |
83 done | |
84 | |
85 return 0 | |
86 } | |
87 | |
88 cd_min () { | |
89 cd -$1 | |
90 } | |
91 | |
92 _cd_min() { | |
93 local cur opts | |
94 cur="${COMP_WORDS[COMP_CWORD]}" | |
95 opts=$(dirs -v) | |
96 COMPREPLY=($(compgen -W "${opts}" --${cur})) | |
97 } | |
98 complete -F _cd_min cd_min | |
99 | |
100 alias cd=cd_func | |
101 | |
102 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' | |
103 | |
104 export EDITOR=nvim | |
105 export HGEDITOR=nvim | |
106 | |
107 stty > /dev/null | |
108 | |
109 # Options | |
110 shopt -s globstar | |
111 shopt -s autocd | |
112 shopt -s cdspell | |
113 shopt -s dirspell | |
114 shopt -s histverify | |
115 shopt -s nocaseglob | |
291
450e01f9d3bd
Use direxpand to expand variables into paths on tab
zegervdv <zegervdv@me.com>
parents:
259
diff
changeset
|
116 shopt -s direxpand |
257 | 117 |
118 set -o vi | |
119 | |
120 # Load mercurial autocompletion | |
121 if [ -f /etc/bash_completion ]; then | |
122 source /etc/bash_completion | |
123 fi | |
124 | |
125 | |
126 [ -f ~/.fzf.bash ] && source ~/.fzf.bash | |
127 export FZF_DEFAULT_COMMAND='ag -g ""' | |
128 source ~/.config/bash/fzf_aliases | |
129 | |
130 | |
131 export NVM_DIR="$HOME/.nvm" | |
132 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
133 [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
134 | |
135 [ -f ~/.bashrc.local ] && source ~/.bashrc.local | |
351
7838713fd3b4
Add color configuration for ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
314
diff
changeset
|
136 |
7838713fd3b4
Add color configuration for ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
314
diff
changeset
|
137 if [ ! -f ~/.lscolors.parsed.sh ]; then |
7838713fd3b4
Add color configuration for ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
314
diff
changeset
|
138 echo 'Generating ls colors' |
7838713fd3b4
Add color configuration for ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
314
diff
changeset
|
139 dircolors --sh ~/.lscolors > ~/.lscolors.parsed.sh |
7838713fd3b4
Add color configuration for ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
314
diff
changeset
|
140 fi |
7838713fd3b4
Add color configuration for ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
314
diff
changeset
|
141 source ~/.lscolors.parsed.sh |