diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2022-03-26 19:07:55 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2022-03-26 19:30:06 +1300 |
commit | 5d392afb872e1f3be3141cb983d6eedf027a7118 (patch) | |
tree | c8ad9990979df2cc9e4b377a741b1f04966822bd /sh/shrc.d/tor.sh | |
parent | Shorten some long lines in path.sh (diff) | |
download | dotfiles-5d392afb872e1f3be3141cb983d6eedf027a7118.tar.gz dotfiles-5d392afb872e1f3be3141cb983d6eedf027a7118.zip |
Add Torsocks management function `tor`
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 +} |