diff options
Diffstat (limited to 'sh/shrc.d/tor.sh')
-rw-r--r-- | sh/shrc.d/tor.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sh/shrc.d/tor.sh b/sh/shrc.d/tor.sh new file mode 100644 index 00000000..e6e31341 --- /dev/null +++ b/sh/shrc.d/tor.sh @@ -0,0 +1,33 @@ +# Manage Torsocks for the current shell +tor() { + + # Check first argument to figure out operation + case $1 in + + # Show whether Torsocks + show|'') + case $LD_PRELOAD: in + (*/libtorsocks.so:*) + printf 'on\n' + ;; + (*) + printf 'off\n' + ;; + esac + ;; + + # Turn Torsocks on or off + on|off) + command -v torsocks >/dev/null 2>&1 || return + . "$(command -v torsocks)" + ;; + + # Command not found + *) + printf >&2 \ + 'tor(): %s: Unknown command (try "help")\n' \ + "$1" + return 2 + ;; + esac +} |