aboutsummaryrefslogtreecommitdiffstats
path: root/_zshrc
diff options
context:
space:
mode:
Diffstat (limited to '_zshrc')
-rw-r--r--_zshrc10
1 files changed, 10 insertions, 0 deletions
diff --git a/_zshrc b/_zshrc
index 085e6c1..0a27cc7 100644
--- a/_zshrc
+++ b/_zshrc
@@ -230,6 +230,16 @@ hex2ip() {
printf '%d.%d.%d.%d' $(echo "${1#0[xX]}" | sed 's/\(..\)/0x\1 /g')
}
+## Convert IP between dotted-decimal and decimal notation
+# Credit: https://stackoverflow.com/a/24136051
+ip2dec() {
+ echo "$1" | awk 'BEGIN { RS = "." } { d = d * 256 + $1 } END { print d }'
+}
+# Credit: https://stackoverflow.com/a/31281331
+dec2ip() {
+ printf '%d.%d.%d.%d' $(echo "obase=256; $1" | bc)
+}
+
#
# Terminal settings
#