-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_bashrc
158 lines (132 loc) · 3.77 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
# ~/.bashrc: executed by bash(1) for non-login shells.
# Determine my current platform
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
platform='linux'
elif [[ "$unamestr" == 'Darwin' ]]; then
platform='darwin'
fi
[ -z "$PS1" ] && return
shopt -s checkwinsize
if [ "$TERM" != "dumb" ]; then
if [[ $platform == 'linux' ]]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
elif [[ $platform == 'darwin' ]]; then
alias ls='ls -G'
fi
fi
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" -a -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
#-------------PROMPT STUFF HERE----------------
function find_git_branch {
local dir=. head
until [ "$dir" -ef / ]; do
if [ -f "$dir/.git/HEAD" ]; then
head=$(< "$dir/.git/HEAD")
if [[ $head == ref:\ refs/heads/* ]]; then
git_branch=" [${head#*/*/}]"
elif [[ $head != '' ]]; then
git_branch=' (detached)'
else
git_branch=' (unknown)'
fi
return
fi
dir="../$dir"
done
git_branch=''
}
function prompt_command {
TERMWIDTH=${COLUMNS}
# Calculate the width of the prompt:
hostnam=$(echo -n $HOSTNAME | sed -e "s/[\.].*//")
# "whoami" and "pwd" include a trailing newline
usernam=$(whoami)
cur_tty=$(tty | sed -e "s/.*tty\(.*\)/\1/")
newPWD="${PWD}"
# Add all the accessories below ...
let promptsize=$(echo -n "--(${usernam}@${hostnam}:${cur_tty})---(${PWD})--" \
| wc -c | tr -d " ")
let fillsize=${TERMWIDTH}-${promptsize}
fill=""
while [ "$fillsize" -gt "0" ]
do
fill="${fill}-"
let fillsize=${fillsize}-1
done
if [ "$fillsize" -lt "0" ]
then
let cut=3-${fillsize}
newPWD="...$(echo -n $PWD | sed -e "s/\(^.\{$cut\}\)\(.*\)/\2/")"
fi
}
PROMPT_COMMAND="find_git_branch; prompt_command"
function twtty {
local GRAY="\[\033[1;30m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
local WHITE="\[\033[1;37m\]"
local NO_COLOUR="\[\033[0m\]"
local LIGHT_BLUE="\[\033[1;34m\]"
local YELLOW="\[\033[1;33m\]"
local BLUE="\[\033[1;34m\]"
local RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local CYAN="\[\033[0;36m\]"
local MAGENTA="\[\033[1;35m\]"
case $TERM in
xterm-color)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
esac
# Okay...Now who we be?
if [ `/usr/bin/whoami` = "root" ] ; then
COLOR=$RED
else
COLOR=$BLUE
fi
PS1="$TITLEBAR\
$CYAN-$LIGHT_BLUE-(\
$BLUE\$usernam$BLUE@$YELLOW\$hostnam$LIGHT_BLUE:$WHITE\$cur_tty\
${LIGHT_BLUE})-${BLUE}-\${fill}${LIGHT_BLUE}-(\
$LIGHT_GREEN\${newPWD}\
$LIGHT_BLUE)-$CYAN-\
\n\
$CYAN-$LIGHT_BLUE-(\
$LIGHT_GREEN\$(date \"+%a %b %d\")$LIGHT_BLUE|$LIGHT_GREEN\$(date +%H:%M)\
$MAGENTA\$git_branch$WHITE\$$LIGHT_BLUE)-\
$NO_COLOUR "
PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$NO_COLOUR "
}
# Getting it all together
twtty
#-----------------------Utilities-------------------
function setdsm() {
# add the current directory and the parent directory to PYTHONPATH
# sets DJANGO_SETTINGS_MODULE
export PYTHONPATH=$PYTHONPATH:$PWD/..
export PYTHONPATH=$PYTHONPATH:$PWD
if [ -z "$1" ]; then
x=${PWD/\/[^\/]*\/}
export DJANGO_SETTINGS_MODULE=$x.settings
else
export DJANGO_SETTINGS_MODULE=$1
fi
echo "DJANGO_SETTINGS_MODULE set to $DJANGO_SETTINGS_MODULE"
}
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profiles
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
export QUILT_PATCHES=debian/patches
alias grep='grep --color'
export EDITOR=vim