-
Notifications
You must be signed in to change notification settings - Fork 0
/
zsh_functions
74 lines (67 loc) · 1.68 KB
/
zsh_functions
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
# zsh_functions: user-defined functions for zsh
up() {
if [ $# -eq 0 ]; then
cd ..
elif [ $# -eq 1 ]; then
directory=""
for ((i=0; i<$1; i++)); do
directory="../${directory}"
done
if [ -n "$directory" ]; then
cd "$directory"
fi
fi
}
git_current_status() {
# Use the first line of git status
git_status=$(git status --long 2> /dev/null | head -n 1 | sed 's/On branch //g')
if [ -z "$git_status" ]; then
echo ""
else
echo "$git_status "
fi
}
virtualenv_status() {
if [ -z "$VIRTUAL_ENV" ]; then
echo ""
else
echo "$(basename $VIRTUAL_ENV) "
fi
}
goto() {
workspace="$HOME/code"
mongo="$workspace/mongo"
if [ $# -gt 1 ]; then
echo "$0: error: expected only one argument"
elif [ $# -eq 1 ]; then
case $1 in
c|code)
cd "$workspace" ;;
cfg|config)
cd "$workspace/config-files" ;;
d|docs)
cd "$workspace/docs" ;;
db)
cd "$mongo/src/mongo/db" ;;
enterprise)
cd "$workspace/enterprise-modules" ;;
js|jstests)
cd "$mongo/jstests" ;;
m|mongo)
cd "$mongo" ;;
r|resmoke)
cd "$mongo/buildscripts/resmokeconfig/suites" ;;
src)
cd "$mongo/src/mongo" ;;
storage)
cd "$mongo/src/mongo/db/storage" ;;
*)
echo "Undefined label." ;;
esac
fi
}
weather() {
city=$(echo $@ | tr '[ ]' '[_]')
curl "wttr.in/$city"
}
#" vim: filetype=sh