intermediate commit
authorIan Kelling <ian@iankelling.org>
Sun, 25 Dec 2016 06:07:14 +0000 (22:07 -0800)
committerIan Kelling <ian@iankelling.org>
Thu, 4 May 2017 23:42:08 +0000 (16:42 -0700)
.bashrc

diff --git a/.bashrc b/.bashrc
index 75a323231008485c9593a8a1257487f115ada86d..d63c6bd6d663075bf3918cab547725d1a18f5acf 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -359,6 +359,13 @@ bashrcpush () {
     cd "$startdir"
 }
 
+bfg() { java -jar /a/opt/bfg-1.12.14.jar "$@"; }
+
+btc() {
+    local f=/etc/bitcoin/bitcoin.conf
+    bitcoin-cli -$(s grep rpcuser= $f) -$(s grep rpcpassword= $f) "$@"
+}
+
 caa() { git commit --amend --no-edit -a; }
 
 calc() { echo "scale=3; $*" | bc -l; }
@@ -513,7 +520,7 @@ faf() { # find all files
     find $@ -type f
 }
 
-fastboot() { /home/ian/Android/Sdk/platform-tools/fastboot "$@"; }
+fastboot() { /a/opt/androidsdk/platform-tools/fastboot "$@"; }
 
 ff() {
     if type -P firefox &>/dev/null; then
@@ -742,6 +749,9 @@ ic() {
     git commit -am "$*"
 }
 
+idea() {
+    /a/opt/idea-IC-163.7743.44/bin/idea.sh "$@" &r
+}
 
 ifn() {
     # insensitive find
@@ -782,7 +792,7 @@ istext() {
 }
 
 jtail() {
-    journalctl -f "$@" | grep -Evi "^(\S+\s+){4}(sudo|ovpn|sshd|cron)"
+    journalctl -n 10000 -f "$@" | grep -Evi "^(\S+\s+){4}(sudo|ovpn|sshd|cron)"
 }
 
 
@@ -840,7 +850,8 @@ mkc() {
 mkdir() { command mkdir -p "$@"; }
 
 pithos() {
-    cd /a/opt/Pithosfly/
+    cd /
+    export PYTHONPATH=/a/opt/Pithosfly
     python3 -m pithos&r
 }
 
@@ -897,6 +908,9 @@ whatismyip() { pubip; }
 
 
 pwgen() {
+    # -m = min length
+    # -x = max length
+    # -t = print pronunciation
     apg -m 12 -x 16 -t
 }
 
@@ -1078,6 +1092,14 @@ srun() {
     ssh $1 /tmp/${2##*/} "${@:2}"
 }
 
+swap() {
+    local tmp
+    tmp=$(mktemp)
+    mv $1 $tmp
+    mv $2 $1
+    mv $tmp $2
+}
+
 t() {
     local x
     local -a args
@@ -1196,8 +1218,18 @@ tx() { # toggle set -x, and the prompt so it doesn't spam
     fi
 }
 
-vc() {
-    [[ $1 ]] || { e "$0: error, expected cmd to run"; return 1; }
+psnsvpn() {
+    # show all processes in the vpn network namespace.
+    # blank entries appear to be subprocesses/threads of transmission daemon
+    ps -w | head -n 1
+    s find -L /proc/[1-9]*/task/*/ns/net -samefile /run/netns/vpn | cut -d/ -f5 | \
+        while read l; do
+            x=$(ps -w --no-headers -p $l);
+            if [[ $x ]]; then echo "$x"; else echo $l; fi;
+        done
+}
+
+netnsvpn() {
     # manually run vpn so it stays within a network namespace,
     # until I get it all wired up with systemd.
     newns vpn start
@@ -1212,10 +1244,27 @@ vc() {
         fi
     fi
     $vpn_on || s ip netns exec vpn /usr/sbin/openvpn --daemon ovpn --config /etc/openvpn/client.conf --cd /etc/openvpn --writepid /run/openvpn/client.pid
+}
+
+
+vc() {
+    [[ $1 ]] || { e "$0: error, expected cmd to run"; return 1; }
     gksudo -- ip netns exec vpn gksudo -u ${SUDO_USER:-$USER} "$@"
 }
 
+transmission-stop() {
+    local pid=$(cat /var/lib/transmission-daemon/transmission-daemon.pid)
+    if [[ $pid ]]; then
+        sudo kill $pid
+    else
+        psg transmission-daemon
+    fi
+}
+
+
+
 transmission() {
+    netnsvpn
     vc transmission-gtk&
     i=0
     while true; do
@@ -1449,7 +1498,7 @@ if [[ $- == *i* ]]; then
         fi
         # I would set nullglob, but bash has had bugs where that
         # doesn't work if not in top level.
-        if ((`ls -AUq /nocow/btrfs-stale|wc -l`)); then
+        if [[ -e /nocow/btrfs-stale ]] && ((`ls -AUq /nocow/btrfs-stale|wc -l`)); then
             ps_char="! $ps_char"
         fi
         PS1="${PS1%"${PS1#*[wW]}"} \[$ps_color\]$ps_char\[$(get_term_color nocolor)\] "