summaryrefslogtreecommitdiff
path: root/etc/functions
blob: 113560f8957d749b4bc2d375313917fe42082235 (plain)
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
## Functions
## vim:ft=zsh
# builtin function for archives, see $ZDIR/alias_suffix
extr () {
	if [[ -f "$1" ]]; then
		case "$1" in
			*.tar.bz2) tar xjvf "$1" ;;
			*.tar.gz) tar xvzf "$1" ;;
			*.ace) unace e "$1" ;;
			*.rar) unrar x "$1" ;;
			*.deb) ar -x "$1" ;;
			*.bz2) bzip2 -d "$1" ;;
			*.lzh) lha x "$1" ;;
			*.gz) gunzip -d "$1" ;;
			*.tar) tar xvf "$1" ;;
			*.tgz) gunzip -d "$1" ;;
			*.tbz2) tar jxvf "$1" ;;
			*.zip) unzip "$1" ;;
			*.Z) uncompress "$1" ;;
			*.shar) sh "$1" ;;
			*) echo "I don't know the archive type of '"$1"' :(" ;;
		esac
	else
		echo "Hm. Seems '"$1"' is not a valid file."
	fi
}

# self-explaining, I think
l () {
	if [[ -f "$1" ]]; then
		case "$1" in
			*.bz2) bzless "$1" ;;
			*.gz) zless "$1" ;;
			*) less "$1" ;;
		esac
	else
		echo "No such file, dude."
	fi
}

cdl () {
	cd "$1";
	ls;
}

world-readable () {
	chmod -R a+rX .
}

chpwd () {
	pstags=''
	[ -f .todo ] && pstags+='todo '
	[ -f .fehindex.jpg ] && pstags+='feh '
	[ -d .hg ] && pstags+='hg '
	[ -d .git ] && pstags+='git '
	[ -d .svn ] && pstags+='svn '
	[ -f Makefile -o -f makefile ] && pstags+='make '
	source $ZDIR/prompt
}

plonkhost () {
	sudo iptables -I INPUT -s "$1" -j DROP
}