HISTCONTROL=ignoredups
# works in addition to HISTCONTROL to do more flexible things
# it could also do the same things as HISTCONTROL and thus replace it,
-# but meh
-HISTIGNORE='k *; *'
+# but meh. dunno why, but just " *" does glob expansion, so use [ ] to avoid it.
+HISTIGNORE='k *:[ ]*'
export BC_LINE_LENGTH=0
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; }
done < <(find "$@" -print0);
}
+faf() { # find all files
+ find $@ -type f
+}
+
+fastboot() { /a/opt/androidsdk/platform-tools/fastboot "$@"; }
ff() {
if type -P firefox &>/dev/null; then
echo
}
+hrcat() { local f; for f; do [[ -f $f ]] || continue; hr; echo "$f"; cat "$f"; done }
+
i() { git "$@"; }
# modified from ~/local/bin/git-completion.bash
git commit -am "$*"
}
+idea() {
+ /a/opt/idea-IC-163.7743.44/bin/idea.sh "$@" &r
+}
ifn() {
# insensitive find
grep -Il "" "$@" &>/dev/null
}
+jtail() {
+ journalctl -n 10000 -f "$@" | grep -Evi "^(\S+\s+){4}(sudo|ovpn|sshd|cron)"
+}
+
l() {
if [[ $PWD == /[iap] ]]; then
mkdir() { command mkdir -p "$@"; }
pithos() {
- cd /a/opt/Pithosfly/
+ cd /
+ export PYTHONPATH=/a/opt/Pithosfly
python3 -m pithos&r
}
pwgen() {
+ # -m = min length
+ # -x = max length
+ # -t = print pronunciation
apg -m 12 -x 16 -t
}
}
rlu() { # [OPTS] HOST PATH
- # eg rlu -opts frodo testpath
+ # eg rlu -opts frodo /testpath
# useful for selectively sending dirs which have been synced with unison,
# where the path is the same on both hosts.
opts=("${@:1:$#-2}") # 1 to last -2
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
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
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
prompt_command() {
local return=$? # this MUST COME FIRST
- local psc pst
- local ps_char ps_color
+ local psc pst ps_char ps_color stale_subvol
unset IFS
history -a # save history
+
+ # for titlebar
if [[ ! $DESKTOP_SESSION == xmonad && $TERM == *(screen*|xterm*|rxvt*) ]]; then
# from the screen man page
if [[ $TERM == screen* ]]; then
echo -ne "$title_escape${PWD/#$HOME/~} $USER@$HOSTNAME\007"
fi
+
case $return in
0) ps_color="$(get_term_color blue)"
ps_char='\$'
ps_color="$(get_term_color bold green)"
fi
fi
+ # I would set nullglob, but bash has had bugs where that
+ # doesn't work if not in top level.
+ 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)\] "
# emacs completion doesn't like the git prompt atm, so disabling it.
#PS1="${PS1%"${PS1#*[wW]}"}$(__git_ps1 ' (%s)') \[$ps_color\]$ps_char\[$(get_term_color nocolor)\] "