-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_functions
145 lines (128 loc) · 7.7 KB
/
.bash_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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Easy extract
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
# Makes directory then moves into it
function mkcdr {
mkdir -p -v $1
cd $1
}
# Creates an archive from given directory
mktar() { tar cvf "${1%%/}.tar" "${1%%/}/"; }
mktgz() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; }
mktbz() { tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; }
#netinfo - shows network information for your system
netinfo ()
{
echo "--------------- Network Information ---------------"
/sbin/ifconfig | awk /'inet addr/ {print $2}'
/sbin/ifconfig | awk /'Bcast/ {print $3}'
/sbin/ifconfig | awk /'inet addr/ {print $4}'
/sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
myip=`lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' `
echo "${myip}"
echo "---------------------------------------------------"
}
##dirsize - finds directory sizes and lists them for the current directory
dirsize ()
{
du -shx * .[a-zA-Z0-9_]* 2> /dev/null | \
egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
egrep '^ *[0-9.]*M' /tmp/list
egrep '^ *[0-9.]*G' /tmp/list
rm -rf /tmp/list
}
#cleanof - clean files older than specific days
cleanof ()
{
find . -mtime +$1 | xargs /bin/rm -Rf
}
#smart pwd
function smart_pwd {
local pwdmaxlen=25
local trunc_symbol=".."
local dir=${PWD##*/}
local tmp=""
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
NEW_PWD=${PWD/#$HOME/\~}
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))
if [ ${pwdoffset} -gt "0" ]
then
tmp=${NEW_PWD:$pwdoffset:$pwdmaxlen}
tmp=${trunc_symbol}/${tmp#*/}
if [ "${#tmp}" -lt "${#NEW_PWD}" ]; then
NEW_PWD=$tmp
fi
fi
}
#just for fun
#
#
#
retrogame ()
{
f=3
b=4
for j in f b; do
for i in {0..7}; do
printf -v $j$i %b "\e[${!j}${i}m"
done
done
bld=$'\e[1m'
rst=$'\e[0m'
case $1 in
invaders)
cat <<-EOF
${f1} ▀▄ ▄▀ ${f2} ▄▄▄████▄▄▄ ${f3} ▄██▄ ${f4} ▀▄ ▄▀ ${f5} ▄▄▄████▄▄▄ ${f6} ▄██▄ $rst
${f1} ▄█▀███▀█▄ ${f2}███▀▀██▀▀███ ${f3}▄█▀██▀█▄ ${f4} ▄█▀███▀█▄ ${f5}███▀▀██▀▀███ ${f6}▄█▀██▀█▄$rst
${f1}█▀███████▀█ ${f2}▀▀███▀▀███▀▀ ${f3}▀█▀██▀█▀ ${f4}█▀███████▀█ ${f5}▀▀███▀▀███▀▀ ${f6}▀█▀██▀█▀$rst
${f1}▀ ▀▄▄ ▄▄▀ ▀ ${f2} ▀█▄ ▀▀ ▄█▀ ${f3}▀▄ ▄▀ ${f4}▀ ▀▄▄ ▄▄▀ ▀ ${f5} ▀█▄ ▀▀ ▄█▀ ${f6}▀▄ ▄▀$rst
$bld${f1}▄ ▀▄ ▄▀ ▄ ${f2} ▄▄▄████▄▄▄ ${f3} ▄██▄ ${f4}▄ ▀▄ ▄▀ ▄ ${f5} ▄▄▄████▄▄▄ ${f6} ▄██▄ $rst
$bld${f1}█▄█▀███▀█▄█ ${f2}███▀▀██▀▀███ ${f3}▄█▀██▀█▄ ${f4}█▄█▀███▀█▄█ ${f5}███▀▀██▀▀███ ${f6}▄█▀██▀█▄$rst
$bld${f1}▀█████████▀ ${f2}▀▀▀██▀▀██▀▀▀ ${f3}▀▀█▀▀█▀▀ ${f4}▀█████████▀ ${f5}▀▀▀██▀▀██▀▀▀ ${f6}▀▀█▀▀█▀▀$rst
$bld${f1} ▄▀ ▀▄ ${f2}▄▄▀▀ ▀▀ ▀▀▄▄ ${f3}▄▀▄▀▀▄▀▄ ${f4} ▄▀ ▀▄ ${f5}▄▄▀▀ ▀▀ ▀▀▄▄ ${f6}▄▀▄▀▀▄▀▄$rst
${f7}▌$rst
${f7}▌$rst
${f7} ▄█▄ $rst
${f7}▄█████████▄$rst
${f7}▀▀▀▀▀▀▀▀▀▀▀$rst
EOF
;;
pacman)
cat <<-EOF
${f3} ▄███████▄ ${f1} ▄██████▄ ${f2} ▄██████▄ ${f4} ▄██████▄ ${f5} ▄██████▄ ${f6} ▄██████▄
${f3}▄█████████▀▀ ${f1}▄${f7}█▀█${f1}██${f7}█▀█${f1}██▄ ${f2}▄${f7}█▀█${f2}██${f7}█▀█${f2}██▄ ${f4}▄${f7}█▀█${f4}██${f7}█▀█${f4}██▄ ${f5}▄${f7}█▀█${f5}██${f7}█▀█${f5}██▄ ${f6}▄${f7}█▀█${f6}██${f7}█▀█${f6}██▄
${f3}███████▀ ${f1}█${f7}▄▄█${f1}██${f7}▄▄█${f1}███ ${f2}█${f7}▄▄█${f2}██${f7}▄▄█${f2}███ ${f4}█${f7}▄▄█${f4}██${f7}▄▄█${f4}███ ${f5}█${f7}▄▄█${f5}██${f7}▄▄█${f5}███ ${f6}█${f7}▄▄█${f6}██${f7}▄▄█${f6}███
${f3}███████▄ ${f1}████████████ ${f2}████████████ ${f4}████████████ ${f5}████████████ ${f6}████████████
${f3}▀█████████▄▄ ${f1}██▀██▀▀██▀██ ${f2}██▀██▀▀██▀██ ${f4}██▀██▀▀██▀██ ${f5}██▀██▀▀██▀██ ${f6}██▀██▀▀██▀██
${f3} ▀███████▀ ${f1}▀ ▀ ▀ ▀ ${f2}▀ ▀ ▀ ▀ ${f4}▀ ▀ ▀ ▀ ${f5}▀ ▀ ▀ ▀ ${f6}▀ ▀ ▀ ▀
$bld${f3} ▄███████▄ ${f1} ▄██████▄ ${f2} ▄██████▄ ${f4} ▄██████▄ ${f5} ▄██████▄ ${f6} ▄██████▄
$bld${f3}▄█████████▀▀ ${f1}▄${f7}█▀█${f1}██${f7}█▀█${f1}██▄ ${f2}▄${f7}█▀█${f2}██${f7}█▀█${f2}██▄ ${f4}▄${f7}█▀█${f4}██${f7}█▀█${f4}██▄ ${f5}▄${f7}█▀█${f5}██${f7}█▀█${f5}██▄ ${f6}▄${f7}█▀█${f6}██${f7}█▀█${f6}██▄
$bld${f3}███████▀ ${f1}█${f7}▄▄█${f1}██${f7}▄▄█${f1}███ ${f2}█${f7}▄▄█${f2}██${f7}▄▄█${f2}███ ${f4}█${f7}▄▄█${f4}██${f7}▄▄█${f4}███ ${f5}█${f7}▄▄█${f5}██${f7}▄▄█${f5}███ ${f6}█${f7}▄▄█${f6}██${f7}▄▄█${f6}███
$bld${f3}███████▄ ${f1}████████████ ${f2}████████████ ${f4}████████████ ${f5}████████████ ${f6}████████████
$bld${f3}▀█████████▄▄ ${f1}██▀██▀▀██▀██ ${f2}██▀██▀▀██▀██ ${f4}██▀██▀▀██▀██ ${f5}██▀██▀▀██▀██ ${f6}██▀██▀▀██▀██
$bld${f3} ▀███████▀ ${f1}▀ ▀ ▀ ▀ ${f2}▀ ▀ ▀ ▀ ${f4}▀ ▀ ▀ ▀ ${f5}▀ ▀ ▀ ▀ ${f6}▀ ▀ ▀ ▀
EOF
;;
*)
echo retro!
;;
esac
}