-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot-bashrc
234 lines (192 loc) · 6.47 KB
/
dot-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
231
232
233
234
#!/bin/bash
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
#if [[ $- != '*i*' ]]; then
# Old versions of bash (e.g. 2.05b) don't have an equivalent to this syntax.
# Take the performance hit of spawning a few processes to work around it. It
# was probably slow anyway... right?
if $(echo $- | grep -vq 'i'); then
# Shell is non-interactive. Be done now
return
fi
# bail if we tried to use an unset variable
#set -o nounset
# allow typos in arguments to cd
shopt -s cdspell
# immediate notification of background job termination
set -b
export DOTNET_CLI_TELEMETRY_OPTOUT=1
alias rdesktop="rdesktop -u Administrator"
alias fuck='sudo $(history -p \!\!)'
# Assume that if common utilities return true for -L (i.e. they are symbolic
# links) then this is a busyboxy system and don't use anything fancy
test ! -L /bin/ls && alias ls='ls -F --color=auto'
test -e /usr/bin/gnome-open && alias open='gnome-open'
# typo and utility aliases
alias cd..='cd ..'
# I find I don't really use these much since ^D is always faster
alias :q='exit'
alias :qa='exit'
alias l='ls'
alias sl='ls'
alias ll='ls -lh'
alias la='ll -a'
alias lsd='ls -d */.'
alias lld='ll -d */.'
alias l.="ls -d .[^.]*"
alias iv=vi
# Makes sure that ctrl-alt-backspace doesn't give someone a shell
alias startx='exec startx'
# -i is really annoying
alias rm='rm -f'
alias grep="grep --color"
alias gi='git'
alias gti='git'
alias mtrunc=":> ~/.msf4/logs/framework.log && tail -fn0 ~/.msf4/logs/framework.log | egrep --color -i 'call stack|exception|$'"
alias mtail="tail -fn0 ~/.msf4/logs/framework.log | egrep --color -i 'call stack|exception|$'"
function mcd() { mkdir -p "$1";cd "$1"; }; export -f mcd
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
if test ! -L /usr/bin/which; then
# this no worky on busybox
function which () {
(alias; declare -f) | /usr/bin/which \
--tty-only --read-functions \
--read-alias --show-dot --show-tilde $@
}
export -f which
fi
# I'm still looking for a way to do this on old versions of bash that do
# not have [[ or =~.
function append_to_path {
if [[ -d "$1" && ! "$PATH" =~ "$1" ]]; then
export PATH=$PATH:$1
fi
}
append_to_path "$HOME/.local/bin"
append_to_path /sbin
append_to_path /usr/sbin
export HISTCONTROL="ignoredups:ignorespace"
export MANPAGER="less"
export RI="-f ansi"
export PAGER="less -R"
export EDITOR="vi"
export VISUAL="vi"
# colors for ls, etc. Prefer ~/.dir_colors
if test -f ~/.dir_colors; then
eval `dircolors -b ~/.dir_colors`
elif test -f /etc/DIR_COLORS; then
eval `dircolors -b /etc/DIR_COLORS`
fi
# Set up a nice window title
case $TERM in
xterm*|rxvt*|Eterm)
BEGIN_TITLE="\[\033]0;"
END_TITLE="\007\]"
TITLE_BAR="${BEGIN_TITLE}\u@\h \w${END_TITLE}"
;;
screen*)
# <esc><underbar>
BEGIN_TITLE="\[\033\137"
# <esc><backslash>
END_TITLE="\033\134\]"
# screen uses this escape sequence to tell when a line contains a
# prompt for purposes of determining what command is being executed.
# <esc><k><esc><backslash>
MARK_PROMPT="\[\033k\033\134\]"
TITLE_BAR="${BEGIN_TITLE}\u@\h (screen) \w${END_TITLE}${MARK_PROMPT}"
;;
*)
TITLE_BAR=''
;;
esac
function prompt_func () {
local status=$?
local COLOR_BLACK="\[\e[00;30m\]"
local COLOR_BLUE_BOLD="\[\e[34;1m\]"
local COLOR_BLUE="\[\e[01;34m\]"
local COLOR_BROWN="\[\e[00;33m\]"
local COLOR_CYAN_BOLD="\[\e[36;1m\]"
local COLOR_CYAN="\[\e[00;36m\]"
local COLOR_FOREST="\[\e[00;32m\]"
local COLOR_GRAY="\[\e[00;37m\]"
local COLOR_GREEN_BOLD="\[\e[32;1m\]"
local COLOR_GREEN="\[\e[01;32m\]"
local COLOR_MAGENTA_BOLD="\[\e[35;1m\]"
local COLOR_MAGENTA="\[\e[00;35m\]"
local COLOR_NAVY="\[\e[00;34m\]"
local COLOR_RED_BOLD="\[\e[31;1m\]"
local COLOR_RED="\[\e[00;31m\]"
local COLOR_WHITE="\[\e[01;37m\]"
local COLOR_YELLOW_BOLD="\[\e[33;1m\]"
local COLOR_YELLOW="\[\e[00;33m\]"
local NONE="\[\e[0m\]"
if test 0 -eq $EUID; then
PS1="${COLOR_RED_BOLD}\u"
else
PS1="${COLOR_FOREST}\u"
fi
# If we're on a remote connection, color the host differently, otherwise
# don't bother with the hostname
if test -n "$SSH_CLIENT" -o -n "$SSH_CONNECTION"; then
PS1="${PS1}@${COLOR_CYAN_BOLD}\h "
else
PS1="${PS1} "
fi
# Working directory
PS1="${PS1}${COLOR_CYAN}\W"
# Add the current git branch if there is one
branch=$(parse_git_branch)
if [ -n "$branch" ]; then
PS1="${PS1}${NONE}:${COLOR_GREEN}${branch}${NONE}"
fi
PS1="${PS1} "
# Add the return code from the last command
if test 0 -ne $status; then
PS1="${PS1}${COLOR_RED_BOLD}($status) "
fi
PS1="${PS1}${COLOR_NAVY}\\$ ${NONE}"
# Change the window title of X terminals
if test -n "${TITLE_BAR}"; then
PS1="${PS1}${TITLE_BAR}"
fi
export PS1
}
export -f prompt_func
export PROMPT_COMMAND='prompt_func'
export RAILS_ENV='development'
#
# cdiff: coloured diff format
#
# Paul Warren <[email protected]>
# 12/01/2001
#
# colour for added lines (bright yellow)
diffnew=`tput setf 6``tput bold`
# colour for removed lines (bright red)
diffold=`tput setf 4``tput bold`
# colour for unchanged lines (bright black, aka dark grey)
diffsame=`tput setf 0``tput bold`
# reset - original pair, unset all attributes
reset=`tput op``tput sgr0`
alias cdiff="diff --changed-group-format='%<%>' \
--new-group-format='%>' \
--old-group-format='%<' \
--new-line-format='${diffnew}+ %l$reset' \
--old-line-format='${diffold}- %l$reset' \
--unchanged-line-format='${diffsame} %l${reset}
' "
test -f ~/.gitrob_token && source ~/.gitrob_token
# The bash completion packages sometimes don't fail gracefully. Put them at
# the end to prevent them from screwing up the rest of our configuration.
test -f /etc/profile.d/bash-completion && source /etc/profile.d/bash-completion
test -f /etc/bash_completion && source /etc/bash_completion
export rvmsudo_secure_path=1
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
true