-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncs.sh
47 lines (38 loc) · 783 Bytes
/
funcs.sh
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
#!/bin/bash
px() {
printf "%x\n" $@
}
pd() {
num=0x$(echo $@ | sed 's/^0x//')
printf "%d\n" $num
}
htons() {
python -c 'import socket; print "%d" % socket.htons('$@')'
}
htonl() {
python -c 'import socket; print "%x" % socket.htonl('$@')'
}
ip2num() {
python -c "
import socket
import struct
a = socket.inet_aton('$@')
print '%#x' % struct.unpack('<L', a)[0]
"
}
num2ip() {
python -c 'import socket; print socket.inet_ntoa('$@')'
}
=() {
ex=$(echo "$@" | sed 's/ //g')
echo $(($ex))
}
git_branch() {
br=$(git branch 2> /dev/null)
if [[ $? -eq "0" ]]; then
brr=$(git branch 2> /dev/null | grep '^*' | colrm 1 2)
echo :${brr}
fi
}
#export PS1="\w (oracle1)\$(git_branch) --# "
#export PS1="\e[1m\033[38;5;226m\w\033[38;5;201m\$(git_branch)\033[0m --$ \033[0m"