-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc_afs
170 lines (123 loc) · 4.4 KB
/
.bashrc_afs
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Great Practical Ideas for Computer Scientists
# Sample .bashrc file
# We provide a few (useful) aliases and scripts for you to get started:
### afsperms <arguments to fs sa> -- Recursively runs fs sa on a directory
### cc <arguments to gcc> -- Invokes gcc with the flags you will usually use
### valgrind-leak <arguments to valgrind> -- Invokes valgrind in the mode to show all leaks
### hidden <arguments to ls> -- Displays ONLY the hidden files
### killz <program name> -- Kills all programs with the given program name
### shell -- Displays the name of the shell being used
### get_cs_afs_access -- Sets up cross-realm authentication with CS.CMU.EDU so you can access files stored there.
# More features may be added later as thought of or requested.
# ----- guard against non-interactive logins ---------------------------------
[ -z "$PS1" ] && return
# ----- convenient alias and function definitions ----------------------------
# color support for ls and grep
alias grep='grep --color=auto'
if [[ `uname` = "Darwin" || `uname` = "FreeBSD" ]]; then
alias ls='ls -G'
else
alias ls='ls --color=auto'
fi
alias killz='killall -9 '
alias hidden='ls -d .*'
alias rm='rm -v'
alias cp='cp -v'
alias mv='mv -v'
alias shell='ps -p $$ -o comm='
alias sml='rlwrap sml'
alias math='rlwrap MathKernel'
alias coin='rlwrap coin'
alias cc='gcc -Wall -W -ansi -pedantic -O2 '
alias valgrind-leak='valgrind --leak-check=full --show-reachable=yes'
afsperms(){ find $1 -type d -exec fs sa {} $2 $3 \; ; }
get_cs_afs_access() {
# Script to give a user with an andrew.cmu.edu account access to cs.cmu.edu
# See https://www.cs.cmu.edu/~help/afs/cross_realm.html for information.
# Get tokens. This might create the user, but I'm not sure that that's
# reliable, so we'll also try to do pts createuser.
aklog cs.cmu.edu
pts createuser $(whoami)@ANDREW.CMU.EDU -cell cs.cmu.edu 2>&1 | grep -v "Entry for name already exists"
aklog cs.cmu.edu
echo "Be sure to add aklog cs.cmu.edu & to your ~/.bashrc"
}
# ----- shell settings and completion -------------------------------------
# Make .bash_history store more and not store duplicates
export HISTCONTROL=ignoreboth
export HISTSIZE=250000
export HISTFILESIZE=250000
# Append to the history file, don't overwrite it
shopt -s histappend
# Check the window size after each command and, if necessary,
# Update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Enable programmable completion features
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
bind "set completion-ignore-case on"
# Make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe.sh ] && export LESSOPEN="|/usr/bin/lesspipe.sh %s"
# Turn off the ability for other people to message your terminal using wall
mesg n
# ----- change the prompt ----------------------------------------------------
# It's really fun to customize your prompt.
# Give it a try! See man bash for help
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# ----- GPI-specific configuration -------------------------------------------
source ~/.bashrc_gpi
# ----- Adding bins for CS Classes -------------------------------------------
# For C0, Coin, etc (15-122)
export PATH=$PATH:/afs/andrew/course/15/122/bin
# For smlnj, etc (15-150)
export PATH=$PATH:/afs/andrew/course/15/122/bin
#========= PERSONAL CONGIFUGRATIONS ========#
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
###=====================SHORTCUT FUNCTIONS=====================###
#cd and then ls
cdls(){
cd "$1" && l -a
}
alias cdl=cdls
#Git
gitpush(){
git add .
git commit -m "$1"
git push
}
#Process handling
alias showproc=htop
findproc(){
ps -e | grep -i "$1"
}
killproc(){
kill `ps -e -o pid,cmd | grep -i '$1' | grep -Po '^[0-9]+|^.*?\K[0-9]+'`
}
#Echo functions with fancy colours
echo_colour(){
echo -e "$(tput setaf $2)$1$(tput sgr0)"
}
alias echo_color=echo_colour
echo_err(){
echo_colour "$1" 1 #red
}
echo_ok(){
echo_colour "$1" 82 #green
}
echo_orange(){
echo_colour "$1" 172
}
echo_blue(){
echo_colour "$1" 81
}