-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
81 lines (67 loc) · 2.64 KB
/
.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# shellcheck disable=1090
# If not running interactively, don't do anything.
[[ $- != *i* ]] && return
# If the executed command is the name of a directory, change to this directory.
shopt -s autocd
# Check the window size after each command and, if necessary, update the values
# of LINES and COLUMNS.
shopt -s checkwinsize
# Append to the history file, don't overwrite it.
shopt -s histappend
# Don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth
# Don't save commands matching these patterns in the history.
HISTIGNORE="ls:fg:bg:h:history"
# Number of commands to remember in the command history.
HISTSIZE=1000
# Maximum number of lines contained in the history file.
HISTFILESIZE=2000
# Source aliases and functions.
for f in ~/.bash_{aliases,functions}; do
[ -f "$f" ] && . "$f"
done
unset f
# Source custom completion functions from ~/.bash_completion.d which are not
# sourced by /usr/share/bash-completion/bash_completion.
if [ -d ~/.bash_completion.d ] ; then
for f in ~/.bash_completion.d/*; do
[ -f "$f" ] && . "$f"
done
unset f
fi
# Set up Node Version Manager when the first node related binary is executed.
init_nvm=/usr/share/nvm/init-nvm.sh
if [ -f "$init_nvm" ]; then
# Get all node related binaries.
mapfile -t bins < <(find ~/.nvm/versions/node -maxdepth 3 -path '*/bin/*' \
-exec basename '{}' \; -exec printf 'node\nnvm\n' \; | sort -u)
# Set up functions that mask the binaries. When called, the functions are
# torn down again and the arguments are passed to the actual command after
# initializing NVM.
for b in "${bins[@]}"; do
eval "$b(){ printf 'Initializing NVM...\\n'; unset -f ${bins[*]}
. $init_nvm; printf '...done\\n'; $b \"\$@\";}"
done; unset bins
fi; unset init_nvm
# Get number of colors this terminal supports.
# Make sure $TERM is set correctly at this point.
colors=0
[ -x "$(command -v tput)" ] \
&& tput setaf 1 > /dev/null 2>&1 \
&& tput colors > /dev/null 2>&1 \
&& colors=$(tput colors)
# Set prompt dependent on the number of colors available.
[ -f ~/.bash_prompt ] && . ~/.bash_prompt "$colors"
if [ "$colors" -ge 8 ]; then
# Setup colors for ls.
[ -x "$(command -v dircolors)" ] && eval "$(dircolors -b)"
# Try to initialize 16-color palette with colors from Xresources.
[ -x ~/bin/terminitc ] && ~/bin/terminitc
# Try to initialize 256-color palette with precise gruvbox colors.
[ "$colors" -ge 256 ] \
&& [ -f ~/.vim/plugged/gruvbox/gruvbox_256palette.sh ] \
&& . ~/.vim/plugged/gruvbox/gruvbox_256palette.sh
fi
unset colors
# vim: set filetype=sh: