-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
168 lines (133 loc) · 3.64 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
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
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
if [ -e /usr/bin/vimx ]; then
alias vim='/usr/bin/vimx'; # vim with +xterm_clipboard
fi
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
if [[ $EUID -ne 0 ]]; then
umask 002
cd() {
builtin cd "$@"
ls --color=auto
}
fi
set -o vi
PS1="\[\e[33;1m\]\u\[\e[32;1m\]@\[\e[32;1m\]\h \[\e[37;1m\]\w\[\e[32;1m\] $ \[\e[0m\]"
PATH=$PATH:./:/usr/local/bin:~/scripts
# enable color support of ls
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
export HISTSIZE=10000
export HISTFILESIZE=10000
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
stty werase undef
bind '"\C-w": unix-filename-rubout'
bind '"\C-x": unix-filename-rubout'
bind '"\C-k": history-search-backward'
bind '"\C-j": history-search-forward'
alias soba='source ~/.bashrc'
alias suvim='sudo vim'
alias sutail='sudo tail'
alias ll='ls -l'
alias lla='ll -a'
alias lsa='ls -a'
alias ltr='ls -ltr'
alias cdu='cd ../'
alias cduu='cd ../../'
alias cduuu='cd ../../../'
alias cduuuu='cd ../../../../'
mkcd() { mkdir $1 && cd $1; }
cpu() { cp "$@" ../; }
cpuu() { cp "$@" ../../; }
cpuuu() { cp "$@" ../../../; }
cpuuuu() { cp "$@" ../../../../; }
mvu() { mv "$@" ../; }
mvuu() { mv "$@" ../../; }
mvuuu() { mv "$@" ../../../; }
mvuuuu() { mv "$@" ../../../../; }
# git related:
alias gpull='git pull'
alias gpush='git push'
alias gs='git status'
alias gc='git commit'
alias ga='git add'
alias gd='git diff'
alias gb='git branch'
alias gl='git log'
alias gsb='git show-branch'
alias gco='git checkout'
alias gg='git grep'
alias gk='gitk --all'
alias gr='git rebase'
alias gri='git rebase --interactive'
alias gcp='git cherry-pick'
alias grm='git rm'
wwwperm() {
sudo find . -type d -print0 | xargs -0 -n100 sudo chmod ug+rwx,o+rx,o-w
sudo find . -type f -print0 | xargs -0 -n100 sudo chmod ug+rw,o+r,o-wx
}
latestmods() { # find lately modified files
find $1 -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head -n $1;
}
box() {
builtin cd ~/docker/clime/
make $1 ${2:+tag="-$2"}
builtin cd -
}
ix() {
curl -n -F 'f:1=<-' http://ix.io
}
alias clime.cz='ssh -p 1022 clime.cz'
alias p2packs='cd /usr/lib/python2.7/site-packages'
alias p3packs='cd /usr/lib/python3.7/site-packages'
export p2packs=/usr/lib/python2.7/site-packages
export p3packs=/usr/lib/python3.7/site-packages
alias sysrst="sudo systemctl restart"
alias sysctl="sudo systemctl"
alias syslog="sudo journalctl -xe -u"
alias setclip='xclip -selection c'
alias getclip='xclip -selection clipboard -o'
source ~/scripts/alias_autocomplete.sh
ix() { curl -n -F 'f:1=<-' http://ix.io; }
alias pscp="rsync -P -e ssh"
# Usage:
#
# attach_to_thread <thread_name> 'gdb cmd'
#
# e.g.
#
# attach_to_thread CMPTO_NET_SERVE 'b SrtConnection.cpp:492'
function attach_to_thread {
thread_name=$1
if [ -z "$thread_name" ]; then
echo "<thread_name> required" 1>&2
return 1
fi
thread_pid=
while true; do
thread_pid=$(ps -eL | grep "$thread_name" | awk '{ print $1; }')
if [ -n "$thread_pid" ]; then
break
fi
echo "Waiting for thread to spawn..."
sleep 1
done
echo "Found thread ${thread_name} with pid ${thread_pid}."
gdb -ex "$2" -p "$thread_pid"
}
export EDITOR=vim
alias psql='PAGER="vim -" psql'
# source local definitions
if [ -f ~/.local_bashrc ]; then
. ~/.local_bashrc
fi