-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions
86 lines (75 loc) · 2.02 KB
/
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
function ii() {
MY_IP=$(/sbin/ifconfig wlp58s0 | awk "/inet/ { print $2 } " | sed -e s/addr://)
echo -e "\nYou are logged on ${RED}$HOST"
echo -e "\nAdditionnal information:$NC " ; uname -a
echo -e "\n${RED}Users logged on:$NC " ; w -h
echo -e "\n${RED}Current date :$NC " ; date
echo -e "\n${RED}Machine stats :$NC " ; uptime
echo -e "\n${RED}Memory stats :$NC " ; free
my_ip 2>&- ;
echo -e "\n${RED}Local IP Address :$NC" ; echo ${MY_IP:-"Not connected"}
echo
}
function myps() {
ps $@ -u $USER -o pid,%cpu,%mem,bsdtime,command ;
}
function pp() {
myps f | awk '!/awk/ && $0~var' var=${1:-".*"} ;
}
# extract various archive formats
function extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar 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
}
# catch common scp mistake
scp(){ if [[ "$@" =~ : ]];then /usr/bin/scp $@ ; else echo 'You forgot the colon dumbass!'; fi;}
sprunge () {
if [ "$*" ]; then
local prompt="$(PS1="$PS1" bash -i <<<$'\nexit' 2>&1 | head -n1)"
( echo "$(sed 's/\o033\[[0-9]*;[0-9]*m//g' <<<"$prompt")$@"; exec $@; )
else
cat
fi | curl -F 'sprunge=<-' http://sprunge.us
}
# cd & ls
function cl() {
cd "$@" && la;
}
# save path on cd
function cd {
builtin cd $@
pwd > ~/.last_dir
}
# restore last saved path
function lastd {
if [ -f ~/.last_dir ]
then cd `cat ~/.last_dir`
fi
}
# copy file with progressbar
cpstat () {
sudo tar cf - "$1" | pv | (cd "$2";tar xf -)
}
# network connection
wifi-connect() {
nmcli device wifi connect $1 password $2
}
set-wallpaper() {
feh --bg-scale ~/Pictures/this_one_flies.png
}