/
bashrc
54 lines (44 loc) · 1.77 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
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ETC_HOME="${ETC_HOME:-$HOME/projects/etc}"
ETC_USER="${ETC_USER:-$(whoami)}"
# Needed for some color-related bits
_start_ansi="\["
_end_ansi="\]"
# A function to help with creating directory aliases and providing
# completion for them.
# Taken from here:
# http://blog.caioromao.com/2010/10/10/Custom-directory-completion.html
# Tweaked to work with more than just 'cd'
_make_dir_complete() {
local aliasname=$1
local prgname="__s_${aliasname}__"
cd "$3" >/dev/null 2>&1
local dirname=$(pwd -L)
local realpath=$(pwd -P)
cd - >/dev/null 2>&1
FUNC="function $prgname() {
local cur len wrkdir;
local IFS=\$'\\n'
wrkdir=\"$realpath\"
cur=\${COMP_WORDS[COMP_CWORD]};
len=\$((\${#wrkdir} + 2));
COMPREPLY=( \$(compgen -S/ -d \$wrkdir/\$cur| cut -b \$len-) );
}"
ALIAS="$aliasname () { $2 \"$dirname/\$*\"; }"
eval $FUNC
eval $ALIAS
complete -o nospace -F $prgname $aliasname
}
test -s "$ETC_HOME/shell-common/functions.sh" && . "$ETC_HOME/shell-common/functions.sh"
test -s "$ETC_HOME/shell-common/exports.sh" && . "$ETC_HOME/shell-common/exports.sh"
test -s "$ETC_HOME/shell-common/aliases.sh" && . "$ETC_HOME/shell-common/aliases.sh"
test -s "$ETC_HOME/shell-common/common-init.sh" && . "$ETC_HOME/shell-common/common-init.sh"
test -s "$ETC_HOME/bash/pickjdk.sh" && . "$ETC_HOME/bash/pickjdk.sh"
test -s "$ETC_HOME/bash/shell-options.sh" && . "$ETC_HOME/bash/shell-options.sh"
test -s "$ETC_HOME/bash/completions.sh" && . "$ETC_HOME/bash/completions.sh"
source "$ETC_HOME/bash/themes/${BASH_THEME:-jszakmeister}.bash-theme"
test -f "$ETC_HOME/user/$ETC_USER/init.sh" &&
. "$ETC_HOME/user/$ETC_USER/init.sh"
test -f "$HOME/.etcrc" && . "$HOME/.etcrc"