-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugins.sh
66 lines (55 loc) · 1.48 KB
/
plugins.sh
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
# Laziness is key
colourise() {
echo -e "\033[$1m$2\033[0m"
}
git_branch() {
gitbranch=$(git branch 2>/dev/null | grep "*" | awk '{print $2}')
if [ -n "$gitbranch" ]; then
changes="[$(git status -s | wc -l)]"
if [ "$changes" == "[0]" ]; then
changes=""
fi
tracking=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)
if [ -n "$tracking" ]; then
left="$(git cherry HEAD "$tracking")"
right="$(git cherry "$tracking" HEAD)"
if [ -n "$left" -a -n "$right" ]; then
state=" (<> $tracking)"
elif [ -n "$left" ]; then
state=" (<< $tracking)"
elif [ -n "$right" ]; then
state=" (>> $tracking)"
fi
fi
echo git: ${gitbranch}${changes}${state}
fi
}
aws_profile() {
if [ -n "$AWS_PROFILE" ]; then
if [ -n "$AWS_DEFAULT_REGION" ]; then
region=$AWS_DEFAULT_REGION
else
region=$(aws configure get region)
fi
if [ -n "$region" ]; then
region="($region)"
fi
echo aws: $AWS_PROFILE $region
fi
}
python_virtualenv() {
if [ -n "$VIRTUAL_ENV" ]; then
echo virtualenv: $(basename $VIRTUAL_ENV)
fi
}
node_virtualenv() {
if [ -n "$NODE_VIRTUAL_ENV" ]; then
echo nodeenv: $(basename $NODE_VIRTUAL_ENV)
fi
}
location() {
echo "cwd: \w"
}
ssh_location() {
echo "location: \u@\h:\w"
}