aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-08-07 10:48:37 +0200
committerEgor Tensin <egor@tensin.name>2026-08-07 10:48:37 +0200
commit0e43c4a9fcc7ab18cb6328947362983c26dd1262 (patch)
tree260cf4600aa9c9eeac9ce8635236fe1ee3fa7d18
parent*.sh -> scripts/ (diff)
downloadlinux-home-0e43c4a9fcc7ab18cb6328947362983c26dd1262.tar.gz
linux-home-0e43c4a9fcc7ab18cb6328947362983c26dd1262.zip
bash: add net.sh
-rw-r--r--%HOME%/.bash_utils/net.sh24
-rw-r--r--%HOME%/.bashrc1
2 files changed, 25 insertions, 0 deletions
diff --git a/%HOME%/.bash_utils/net.sh b/%HOME%/.bash_utils/net.sh
new file mode 100644
index 0000000..6d4f74b
--- /dev/null
+++ b/%HOME%/.bash_utils/net.sh
@@ -0,0 +1,24 @@
+# Copyright (c) 2026 Egor Tensin <egor@tensin.name>
+# This file is part of the "linux-home" project.
+# For details, see https://github.com/egor-tensin/linux-home.
+# Distributed under the MIT License.
+
+_curl() {
+ curl -sS --connect-timeout 5 "$@"
+}
+
+whatsmyip() (
+ set -o errexit -o nounset -o pipefail
+ shopt -s inherit_errexit 2> /dev/null || true
+ shopt -s lastpipe
+
+ _curl "https://ifconfig.co/"
+)
+
+whatsmycountry() (
+ set -o errexit -o nounset -o pipefail
+ shopt -s inherit_errexit 2> /dev/null || true
+ shopt -s lastpipe
+
+ _curl "https://ifconfig.co/country"
+)
diff --git a/%HOME%/.bashrc b/%HOME%/.bashrc
index 1778af6..19b2940 100644
--- a/%HOME%/.bashrc
+++ b/%HOME%/.bashrc
@@ -33,6 +33,7 @@ export HISTSIZE=20000
[ -r "$HOME/.bash_utils/cxx.sh" ] && source "$HOME/.bash_utils/cxx.sh"
[ -r "$HOME/.bash_utils/distr.sh" ] && source "$HOME/.bash_utils/distr.sh"
[ -r "$HOME/.bash_utils/git.sh" ] && source "$HOME/.bash_utils/git.sh"
+[ -r "$HOME/.bash_utils/net.sh" ] && source "$HOME/.bash_utils/net.sh"
[ -r "$HOME/.bash_utils/path.sh" ] && source "$HOME/.bash_utils/path.sh"
[ -r "$HOME/.bashrc_local" ] && source "$HOME/.bashrc_local"