-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzsh_functions
44 lines (40 loc) · 1.07 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
#!/bin/zsh
#
# William Falk-Wallace
# zsh_functions
#
# TODO: Investigate fpath, autoload
############################### MISC FUNCTIONS ###############################
### cd up-tree by specifying the number of jumps (ie. up 3 === cd ../../../)
function up()
{
ALTITUDE=1
if [ ! -z $1 ]; then
ALTITUDE=$1
fi
DIR=""
for ((i = 0; i < ALTITUDE; i++)); do
DIR="../$DIR"
done
cd $DIR
}
### open the specified manpage in chrome
function openManPageInChrome()
{
if [ $# -ne 1 ]; then
echo "Usage: openManPageInChrome <cmd>"
fi
man $1 | col -b | open -a /Applications/Google\ Chrome.app -f
}
############################# GIT + GITHUB HACKS #############################
### from ifandelse.com/listing-git-branches-in-order-of-most-recent-commit
function branches()
{
git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)|%(committerdate:iso)|%(authorname)' |
sed 's/refs\/heads\///g' |
grep -v BACKUP |
while IFS='|' read branch date author
do
printf '%-15s %-30s %s\n' "$branch" "$date" "$author"
done
}