-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDOTbashrc
207 lines (170 loc) · 5.92 KB
/
DOTbashrc
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
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# Fedora: Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
HISTCONTROL=ignoredups
# append to the history file, don't overwrite it
shopt -s histappend
HISTSIZE=10000
HISTFILESIZE=10000
# 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 a fancy prompt (non-color, unless we know we "want" color)
#case "$TERM" in
# xterm-color) color_prompt=yes;;
#esac
# Change the window title of X terminals
case $TERM in
xterm*|rxvt|Eterm|eterm)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
# 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'
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'
# 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 [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
# TODO: overflowing/overwriting prompt: http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
#
# for now I want nothing to commit but untrackd files to be green
function parse_git_dirty {
local status=$(git status 2> /dev/null | tail -n1)
([[ $status == "nothing to commit (working directory clean)" ]] && echo -e "\e[32m") || ([[ $status == "nothing added to commit but untracked files present (use \"git add\" to track)" ]] && echo -e "\e[33m") || echo -e "\e[31m"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/$(parse_git_dirty)\1/"
}
function display_git_branch {
git rev-parse > /dev/null 2>&1 && echo -e " "$(parse_git_branch)
}
# If running interactively, then:
if [ "$PS1" ]; then
alias aoeu='if [ $DISPLAY ]; then setxkbmap us; else loadkeys us; fi'
alias asdf='if [ $DISPLAY ]; then setxkbmap dvorak; else loadkeys dvorak; fi'
alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
# set a fancy prompt
#PS1="\u@\h:\w\$ ";
# https://gist.github.com/55729
# export PS1='\u@\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ '
# PS1="\[\e[33m\](\t) \[\e[38m\]\!\[\e[0m\] \[\e[36m\]\u\[\e[31m\]@\[\e[34m\]\h\[\e[31m\]:\[\e[32m\]\w$\[\e[0m\] "
#PS1='\[\e[33m\](\t) \[\e[38m\]\! \[\e[36m\]\u\[\e[31m\]@\[\e[34m\]\h\[\e[31m\]:\[\e[32m\]\w $(parse_git_branch)\[\e[32m\]$\[\e[0m\] '
PS1='\[\e[33m\](\t) \[\e[38m\]\! \[\e[36m\]\u\[\e[31m\]@\[\e[34m\]\h\[\e[31m\]:\[\e[32m\]\w$(display_git_branch)\[\e[32m\]$\[\e[0m\] '
# If this is an xterm set the title to user@host:dir
#case $TERM in
#xterm*)
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
# ;;
#*)
# ;;
#esac
fi
if [ `whoami` = "root" ]; then
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
export PATH
fi
# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
PATH=~/bin:"${PATH}"
export PATH
fi
if [ -d ~/.cabal/bin ] ; then
PATH=~/.cabal/bin:"${PATH}"
export PATH
fi
if [ $DISPLAY ];
then #setxkbmap dvorak > /dev/null 2>&1;
export EDITOR='/usr/bin/gvim'
# xorg screensaver set to 5 mins
xset s blank
xset s 300
else #loadkeys dvorak > /dev/null 2>&1;
export EDITOR='/usr/bin/vim'
fi
alias fceu='fceu -inputcfg gamepad1'
alias vi=$EDITOR
export SVN_EDITOR="$EDITOR -f"
export GIT_EDITOR="$EDITOR -f"
set -o vi
if [ -d ~/packages/godi/bin ] ; then
PATH=~/packages/godi/sbin:~/packages/godi/bin:${PATH}
export PATH
else
export PATH=/opt/godi-3.12.0/bin:/opt/godi-3.12.0/lib:$PATH
fi
if [ -d ~/trunk/peoplesearch ] ; then
PATH=~/trunk/lib/ocaml/atdgen:~/trunk/peoplesearch/programs:${PATH}
export PATH
fi
if [ -d ~/jsonpat ] ; then
PATH=~/jsonpat:${PATH}
export PATH
fi
# ocamlpath used by ocamlfind
if [ -d ~/trunk/lib/ocaml ] ; then
OCAMLPATH=.:..:~/trunk/lib/ocaml
export OCAMLPATH
fi
if [ -d ~/lib ] ; then
LD_LIBRARY_PATH=~/lib
export LD_LIBRARY_PATH
fi
alias rgrep="grep -r"
alias view="vi -R"
alias vimdiff="vi -d"
# Thanks to Daniel Velkov for these two functions
function f {
find . -iname "*$1*$2"
}
function vif {
results=$(f $1 $2)
if [ $(echo $results | wc -w) -lt 3 ]; then
vi $results
else
echo $results | tr ' ' '\n' | vi -R -
fi
}
function ocamlpath {
export OCAMLPATH=$(tmp=$(for i in $(find ~ -name META -exec dirname {} \;); do dirname $i; done | sort -u) && echo $tmp | sed -e 's/ /:/g')
}
function ocaml {
if [ -z $OCAMLPATH ]; then
ocamlpath
fi
ledit -x -h ~/.ocaml_history ocaml $@
}