-
Notifications
You must be signed in to change notification settings - Fork 1
/
.common_rc
88 lines (71 loc) · 2.25 KB
/
.common_rc
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
82
83
84
85
86
87
88
#---------------------Environment variables------------------------------
export EDITOR=vim
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
setopt APPEND_HISTORY # append to history, don't overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
export PYTHONSTARTUP=$HOME/.pythonrc
#---------------------Functions------------------------------
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1"
fi
}
newpy() {
echo -e "import os\nimport sys\nimport shutil\n" > $1
}
my_trash(){
mkdir -p $HOME/$(echo $USER)_trash
mv $1 $HOME/$(echo $USER)_trash
}
is_package_installed(){
INSTALLED=$(dpkg -l \grep $1)
if [ "$INSTALLED" != "" ]; then
echo "installed"
else
echo "not_installed"
fi
}
#---------------------Aliases------------------------------
alias hn='hostname'
alias treel='tree -L'
alias treel2="tree -L 2"
alias vimro="vim -R"
alias reloadrc="source $HOME/.common_rc"
alias grepi="grep -i"
alias '...'='../..'
alias '....'='../../..'
alias '.....'='../../../..'
alias bighist='history -1000000'
if [[ "$(is_package_installed trash-cli)" == "installed" ]]; then
alias rm='trash-put'
fi
alias chmox="chmod +x"
alias lsa="ls -alh"
alias reproot='cd $(git rev-parse --show-toplevel)'
alias rr='reproot'
alias projroot="cd $( pwd | sed 's/\/deps\/.*//g' )"
alias shopen='gnome-open'
alias pdl='pdflatex'
alias ptp='ptpython'
alias matlab_remote='/usr/local/MATLAB/R2014b/bin/matlab -nosplash -nodesktop -minimize'
alias grv='git remote -v'
alias bfg='java -jar ~/bin/bfg-1.11.5.jar'
alias ump='update_matlab_project `pwd`'
#---------------------Other------------------------------
source $HOME/utils/common_utils.sh
pathadd $HOME/utils
user_rc_file=$HOME/.$(echo $USER)_rc
if [ -f $user_rc_file ]; then
source $user_rc_file
fi
user_utils=$HOME/utils/$(echo $USER)_utils.sh
if [ -f $user_utils ]; then
source $user_utils
fi
machine_rc_file=$HOME/.$(hostname)_rc
if [ -f $machine_rc_file ]; then
source $machine_rc_file
fi