-
Notifications
You must be signed in to change notification settings - Fork 1
/
Functions.txt
107 lines (94 loc) · 2.87 KB
/
Functions.txt
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
Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4
Creation-Date: 2016-10-23T14:54:15+02:00
====== Functions ======
Created søndag 23 oktober 2016
**Functions works as Aliases. Add the preferred functions to your** //.bashrc/.zshrc// **file.**
== Extract ==
**# Make sure you add** //shopt -s extglob// **to the** //.basrc/.zshrc// **file**
**# Use with** //ex filename//
{{{code: lang="texinfo" linenumbers="True"
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
}}}
== Copy and go to dir ==
**# Use with** //cpg /path/to/file /new/path//
{{{code: lang="texinfo" linenumbers="True"
cpg (){
if [ -d "$2" ];then
cp $1 $2 && cd $2
else
cp $1 $2
fi
}
}}}
== Move and go to dir ==
**# Use with** //mvg /path/to/file /new/path//
{{{code: lang="texinfo" linenumbers="True"
mvg (){
if [ -d "$2" ];then
mv $1 $2 && cd $2
else
mv $1 $2
fi
}
}}}
== Arch news feed (rss) ==
**# Use with **//feed //
{{{code: lang="texinfo" linenumbers="True"
feed() {
# The characters "ç, £, §" are used as metacharacters. They should not be encountered in a feed...
echo -e "$(echo $(curl --silent https://www.archlinux.org/feeds/news//// | sed -e ':a;N;$!ba;s/\n/ /g') | \
sed -e 's/>/ç/g' |
sed -e 's/<\/aç/£/g' |
sed -e 's/href\=\"/§/g' |
sed -e 's/<title>/\\n\\n\\n :: \\e[01;31m/g' -e 's/<\/title>/\\e[00m ::\\n/g' |
sed -e 's/<link>/ [ \\e[01;36m/g' -e 's/<\/link>/\\e[00m ]/g' |
sed -e 's/<description>/\\n\\n\\e[00;37m/g' -e 's/<\/description>/\\e[00m\\n\\n/g' |
sed -e 's/<pç/\n/g' |
sed -e 's/<bç\|<strongç/\\e[01;30m/g' -e 's/<\/bç\|<\/strongç/\\e[00;37m/g' |
sed -e 's/<a[^§]*§\([^\"]*\)\"[^ç]*ç\([^£]*\)[^£]*£/\\e[01;32m\2\\e[00;37m \\e[01;34m[ \\e[01;35m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g' |
sed -e 's/<liç/\n \\e[01;34m*\\e[00;37m /g' |
sed -e 's/<[^>]*>/ /g' |
sed -e 's/<[^ç]*ç//g' |
sed -e 's/[磧]//g')\n\n"
}
}}}
== Disable monitor blank for 2 hours ==
**# Use with** blank
{{{code: lang="texinfo" linenumbers="True"
blank () {
DUR="$(xset q | grep Standby | cut -d' ' -f4)"
xset s off
case $DUR in
7200) xset dpms 600 600 600;notify-send "Display" "Screen blank set to 10 mins.";;
*) xset dpms 7200 7200 7200;notify-send "Display" "Screen blank set to 2 hours.";;
esac
}
}}}
== Get current weather + forecast in some sweet output! ==
**# Use with **//weather <CITY_NAME>//
{{{code: lang="texinfo" linenumbers="True"
weather () {
curl -4 http://wttr.in/$1
}
}}}