Repository navigation
Expand file tree
/
Copy pathzsh_functions
More file actions
78 lines (70 loc) · 1.6 KB
/
Copy pathzsh_functions
File metadata and controls
78 lines (70 loc) · 1.6 KB
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
# -*- sh -*-
##
# cd == cd + ls
cd() {
builtin cd $*
ls --color="auto"
}
##
# extract
ext() {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar -jxvf $1 ;;
*.tar.gz) tar -zxvf $1 ;;
*.tar.xz) tar -Jxvf $1 ;;
*.bz2) bzip2 -d $1 ;;
*.gz) gunzip -d $1 ;;
*.tar) tar -xvf $1 ;;
*.tgz) tar -zxvf $1 ;;
*.tbz2) tar -xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.rar) unrar x $1 ;;
*.xz) xz -d $1 ;;
*) echo "'$1' Error. Please go away" ;;
esac
else
echo "'$1' is not valid!"
fi
}
compdef '_files -g "*.{tar.bz2,tar.gz,bz2,gz,tar,tgz,tbz2,zip,Z,7z,rar,xz}"' ext
##
# generate password
gpass() {
local chars="[:graph:]"
[[ "$1" == "-n" ]] && chars="[:alnum:]" && shift
tr </dev/urandom -dc "$chars" | head -c${1:-16}
echo
}
gpin() {
tr </dev/urandom -dc '[:digit:]' | head -c${1:-4}
echo
}
##
# play flash movies
pflv() {
pid=$(pgrep -f flashplayer | tail -l)
file=$(lsof -p ${pid} | awk \
'/\/tmp\/Flash/ {sub(/[rwu]$/, "", $4); print "/proc/" $2 "/fd/" $4}')
mplayer2 ${file}
}
##
# generate and print qrcode on cli
qr() {
f=$(date +%s)
qrencode "$1" -o "/tmp/$f.png" -s 1
icat "/tmp/$f.png"
rm "/tmp/$f.png"
}
##
# welcome
welcome() {
if [[ $(date +%j) == 256 ]]; then
echo "Happy programmers' day!"
#else
#echo "Słowo na $(date +'%j dzień roku %Y'):"
#~/dev/scripts/bash/fortunes/urbandictionary.sh
fi
}