-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashrc
110 lines (92 loc) · 2.13 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
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
# .bashrc
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# Source global definitions
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
# Source local definitions
if [ -d $HOME/.bash.d ]; then
for i in $HOME/.bash.d/*; do
. "$i"
done
fi
shopt -s checkwinsize
# Prevent PuTTY's (and possibly others') CTRL-S/CTRL-Q flow control
stty ixany -ixoff -ixon
# Aliases stolen from CSE
alias grep='grep -I -d skip --color=auto'
alias cgrep='grep -I -d skip --color=always'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias vi='vim'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
# User specific aliases and functions
alias ssh-start='SSH_BASH=1 exec ssh-agent bash -l'
alias resume='vi -S $(git rev-parse --abbrev-ref HEAD).vim'
alias qcc='gcc -Wall -g -std=c11'
alias q++='g++ -Wall -g -std=gnu++11'
function poff() {
export PROMPT_COMMAND=''
export PS1='[\u@\h \W]$ '
}
function pon() {
export PROMPT_COMMAND='__git_ps1 "[" "\u@\h \W]$ " "%s "'
}
function grepl() {
grep --color=always --exclude=tags --exclude=cscope.out "$@" | less -R
}
function crontab() {
if [ $# -eq 0 ]; then
echo "no"
else
command crontab "$@"
fi
}
function mkd() {
mkdir -vp "$@" && cd $_
echo "Entered directory $_"
}
function cdiff() {
colordiff -u "$@" | less -R
}
function catf() {
head -n -0 "$@"
}
function watcher() {
WATCHERTIME=$1
WATCHERFILE=/tmp/watcher$$
shift
while true; do
WATCHERHEIGHT=$(($(tput lines) - 3))
( eval $* ) | tail -n ${WATCHERHEIGHT} > ${WATCHERFILE} 2>/dev/null
clear
/bin/echo -n "Every ${WATCHERTIME} seconds - "
date
/bin/echo
cat ${WATCHERFILE}
\rm -f ${WATCHERFILE}
/bin/echo
/bin/echo "=="
sleep ${WATCHERTIME}
done
}
function yesno() {
read -p "Continue? (y/N): " -r
# bash return doesn't allow boolean zen :(
if [[ $REPLY =~ ^[Yy] ]]
then
return 0
fi
return 1
}