-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc
73 lines (61 loc) · 2.46 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
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Setup nice colors
alias sudo='sudo '
[[ $OSTYPE == *linux* ]] && alias ls='ls --color=auto'
[[ $OSTYPE == *darwin* ]] && alias ls='ls -G'
alias grep='grep --color=auto'
alias diff='colordiff'
# Generate the databases of cscope and ctags
gentag() {
GT_OPT=""
if [ $# == 1 ] && [ "$1" == "-L" ]; then
GT_OPT="-L"
fi
rm -f /tmp/cscope.files
echo -ne "[ .... ] Create list of files in system\r"
find $GT_OPT $PWD -name '*.[ch]' | awk '{print "\""$0"\""}' > /tmp/cscope.files
find $GT_OPT $PWD -name '*.cpp' -o -name '*.cxx' | awk '{print "\""$0"\""}' >> /tmp/cscope.files
echo "[ Done ] Create list of files in system"
rm -f $PWD/cscope.out $PWD/cscope.*.out $PWD/tags $PWD/gentag.log
echo -ne "[ .... ] Generate cross-reference database\r"
cscope -bqki /tmp/cscope.files > $PWD/gentag.log 2>&1
ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q $PWD >> $PWD/gentag.log 2>&1
if [ ! -s $PWD/gentag.log ]; then
rm $PWD/gentag.log
echo "[ Done ] Generate cross-reference database"
else
rm -f $PWD/cscope.out $PWD/cscope.*.out $PWD/tags
echo "[ Fail ] Generate cross-reference database"
fi
}
PS1='[\u@\h \W]\$ '
case "$OSTYPE" in
linux*)
alias tmux='tmux -2'
# enable bash completion for git
BASH_COMPLETION_DIR=/usr/share/bash-completion/completions
[[ -a $BASH_COMPLETION_DIR/git-completion.bash ]] && source $BASH_COMPLETION_DIR/git-completion.bash
;;
darwin*)
# The configuration of application installed by Homebrew
if [ -x /usr/local/bin/brew ]; then
# required!
export PATH=/usr/local/bin:$PATH
# enable bash completion for git
BASH_COMPLETION_DIR=/usr/local/etc/bash_completion.d
[[ -a $BASH_COMPLETION_DIR/git-completion.bash ]] && source $BASH_COMPLETION_DIR/git-completion.bash
fi
# Android environment variables
export ANDROID_HOME=~/Library/Android
export PATH=$PATH:$ANDROID_HOME/sdk/tools:$ANDROID_HOME/sdk/platform-tools:$ANDROID_HOME/ndk/current
# Gradle environment variables
export GRADLE_HOME=~/.gradle
export PATH=$PATH:$GRADLE_HOME/current/bin
;;
*)
echo "Unsupported OS type: $OSTYPE"
;;
esac
# Remove duplicate entries
export PATH=$(perl -e 'print join ":", grep {!$h{$_}++} split ":", $ENV{PATH}')