-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbashrc
230 lines (193 loc) · 6.81 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
if [ -f /.dockerenv ]; then
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;31m\]$(__git_ps1)\[\033[00m\]\$ '
elif [ "$(id -u)" = "0" ]; then
PS1='\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;31m\]$(__git_ps1)\[\033[00m\]\$ '
else
PS1='\[\033[38;5;214m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;31m\]$(__git_ps1)\[\033[00m\]\$ '
fi
else
PS1='\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# 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 dir='dir --color=auto'
alias vdir='vdir --color=auto'
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
__git_ps1()
{
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo " ["${ref#refs/heads/}"]";
}
[ -f ~/.ctfrc ] && . ~/.ctfrc
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export PATH=~/bin:$PATH
export EDITOR=vim
export PYTHONSTARTUP="$HOME/.pythonrc"
export CLICOLOR=1
export TERM=screen-256color
export PIN_ROOT="$HOME/bin/pin"
#alias gdb="gdb -q"
alias gdbb="gdb -n"
alias pwndbg="gdb -x ~/.pwndbg/gdbinit.py"
alias tmux="TERM=xterm-256color tmux"
alias rip="curl orange.tw"
alias tip="curl --socks5 127.0.0.1:9150 orange.tw"
alias tcurl="curl --socks5 127.0.0.1:9150 "
alias tssh="ssh -o 'ProxyCommand /usr/bin/nc -x 127.0.0.1:9150 %h %p'"
alias rssh="ssh -NfR 12345:localhost:22 "
alias lssh="ssh -NfL 12345:localhost:12345 "
alias strace="strace -ixv"
alias ltrace="ltrace -iC"
alias objdump="objdump -M intel"
alias len="expr length "
alias fuck="killall -9 "
alias djson="python -m json.tool"
alias folders="find . -maxdepth 1 -type d -print0 | xargs -0 du -skh | sort -rn"
alias ll='ls -l'
alias la='ls -Ahl'
alias l='ls -CF'
alias rm="rm -i"
alias mv="mv -i"
alias cp="cp -i"
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# Less Colors for Man Pages
export PAGER="$(which less) -s"
export BROWSER="$PAGER"
export LESS_TERMCAP_mb=$'\E[38;5;167m' # begin blinking
export LESS_TERMCAP_md=$'\E[38;5;39m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # end mode
export LESS_TERMCAP_se=$'\E[38;5;231m' # end standout-mode
export LESS_TERMCAP_so=$'\E[38;5;167m' # begin standout-mode - info box
export LESS_TERMCAP_us=$'\E[38;5;167m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # end underline
# ssh auto complete
complete -W "$(cat ~/.ssh/known_hosts 2>&1| cut -f 1 -d ' ' | sed -e s/,.*//g | grep -v '^#' | uniq | grep -v '\[';\
cat ~/.ssh/config 2>&1| grep '^Host ' | grep -v '*' | awk '{print $2}')" ssh
# virtualenvwrapper
if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
export WORKON_HOME=~/Env
source /usr/local/bin/virtualenvwrapper.sh
fi
function at() {
if [[ "$1" =~ ^[0-9]+$ ]]
then
sudo gdb attach $1
else
sudo gdb attach `pidof -s $1`
fi
}
function de()
{
docker exec -it $1 bash
}
function tunnel()
{
if [ $# != 4 ]; then
echo "tunnel <LOCAL PORT> <DEST HOST> <DEST PORT> <host>"
else
ssh -NfL $1:$2:$3 $4
fi
}
function tunnel()
{
if [ $# != 4 ]; then
echo "tunnel <LOCAL PORT> <DEST HOST> <DEST PORT> <host>"
else
ssh -NfL $1:$2:$3 $4
fi
}
# OSX and Cygwin
if [ "$(uname)" == "Darwin" ]; then
export LSCOLORS="Exfxcxdxbxegedabagacad"
alias ls="ls -G"
alias hidedesk="defaults write com.apple.finder CreateDesktop false;killall Finder"
alias showdesk="defaults write com.apple.finder CreateDesktop true;killall Finder"
elif [ "$(uname -o)" == "Cygwin" ]; then
chcp.com 437 > /dev/null # set codepage to 437
if [ ! -z $BABUN_HOME ]; then
# Fix babun bug of reload .bashrc
[[ -z ${USER_BASHRC} ]] && USER_BASHRC="1" || return
# Relink Tools folder for portable use
[[ -e ~/Tools/ ]] && rm -f ~/Tools
export TOOLS=$(dirname $BABUN_HOME)
ln -s $TOOLS ~/Tools
export PATH=$PATH:$TOOLS:$TOOLS/java/bin
export JAVA_HOME=$TOOLS/java
alias big5="iconv -f big5"
alias sqlmap="~/Tools/sqlmap/sqlmap.py"
alias dex2jar="~/Tools/dex2jar/d2j-dex2jar.bat"
alias apktool="~/Tools/apktool/apktool.bat"
# pin
alias pin="~/Tools/pin/pin"
export PIN_ROOT="$TOOLS/pin"
# msvc
alias vc9="~/Tools/VC9/setenv"
alias vc12="~/Tools/VC12/setenv"
alias clexe="vc9 cl.exe /MD /EHsc /Oi /O2 /Gy /nologo "
alias cldll="vc9 cl.exe /LD /link "
alias deaslr="vc9 link.exe /edit /dynamicbase:NO "
unset PYTHONHOME
fi
fi