ack() { ack-grep "$@"; }
+anki() {
+ if which anki &>/dev/null; then
+ command anki
+ else
+ schroot -c anki -- anki
+ fi
+}
+
astudio() {
# googling android emulator libGL error: failed to load driver: r600
# lead to http://stackoverflow.com/a/36625175/14456
bfg() { java -jar /a/opt/bfg-1.12.14.jar "$@"; }
+bigclock() {
+ xclock -digital -update 1 -face 'arial black-80:bold'
+}
+
btc() {
local f=/etc/bitcoin/bitcoin.conf
# importprivkey will timeout if using the default of 15 mins.
bitcoin-cli -rpcclienttimeout=60000 -$(s grep rpcuser= $f) -$(s grep rpcpassword= $f) "$@"
}
-btcusd() {
+btcusd() { # $1 btc in usd
local price
price="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
printf "$%s\n" "$price"
printf "$%.2f\n" "$(echo "scale=4; $price * $1"| bc -l)"
fi
}
-usdbtc() {
+usdbtc() { # $1 usd in btc
local price
price="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
printf "$%s\n" "$price"
printf "%.8f btc\n" "$(echo "scale=10; $1 / $price "| bc -l)"
fi
}
-satoshi() {
+satoshi() { # $1 satoshi in usd
local price
price="$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | jq -r .data.amount)"
price=$(echo "scale=10; $price * 0.00000001"| bc -l)
}
chrome() {
- CHROMIUM_FLAGS='--enable-remote-extensions' chromium &r
+ if type -p chromium &>/dev/null; then
+ cmd=chromium
+ else
+ cd
+ cmd="schroot -c stretch chromium"
+ CHROMIUM_FLAGS='--enable-remote-extensions' $cmd &r
+ fi
}
d() { builtin bg; }
-o -name .undo-tree-history -prune \) 2>/dev/null
}
-fastboot() { /a/opt/androidsdk/platform-tools/fastboot "$@"; }
+# one that comes with distros is too old for newer devices
+fastboot() {
+ /a/opt/android-platform-tools/fastboot "$@";
+}
# List of apps to install/update
echo "${p%%/.git}"
}
+gitian() {
+ git config user.email ian@iankelling.org
+}
+
gmacs() {
# quit will prompt if the program crashes.
gdb -ex=r -ex=quit --args emacs "$@"; r;
set +x
}
+mdt() {
+ markdown -o /tmp/mdtest.html "$1"
+ firefox /tmp/mdtest.html
+}
+
mkc() {
mkdir "$1"
mkdir() { command mkdir -p "$@"; }
+mo() { xset dpms force off; } # monitor off
+
otp() {
- echo "oathtool --totp -b"
- oathtool --totp -b "$@"
+ oathtool --totp -b "$@" | xclip -selection clipboard
}
+# pithosfly is broken due to bitrot.
pithos() {
cd /
export PYTHONPATH=/a/opt/Pithosfly
sgo() { # service go
service=$1
- ser restart $service
+ ser restart $service || return 1
if type -p systemctl &>/dev/null; then
ser enable $service
fi
sss() { # ssh solo
ssh -oControlMaster=no -oControlPath=/ "$@"
}
+ssk() {
+ local -a opts=()
+ while [[ $1 == -* ]]; do
+ opts+=("$1")
+ shift
+ done
+ m pkill -f "^ssh: /tmp/ssh_mux_${USER}_${1#*@}_22_"
+ m ssh "${opts[@]}" "$@"
+}
swap() {
local tmp
vpncmd() {
- m s nsenter -t $(pgrep -f "/usr/sbin/openvpn --suppress-timestamps --nobind --config /etc/openvpn/client/client.conf") -n -m "$@"
+ m s nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/client/client.conf") -n -m "$@"
}
vpnf() {
vpncmd gksudo -u ian "firefox -no-remote -P firefox-main-profile" &r
vpn() {
+ if [[ -e /lib/systemd/system/openvpn-client@.service ]]; then
+ local vpn_service=openvpn-client
+ else
+ local vpn_service=openvpn
+ fi
+
[[ $1 ]] || { echo need arg; return 1; }
- journalctl --unit=openvpn-client@$1 -f -n0 &
- s systemctl start openvpn-client@$1
+ journalctl --unit=$vpn_service@$1 -f -n0 &
+ s systemctl start $vpn_service@$1
# sometimes the ask-password agent does not work and needs a delay.
sleep .5
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=779240
vpnoff() {
[[ $1 ]] || { echo need arg; return 1; }
- s systemctl stop openvpn-client@$1
+ if [[ -e /lib/systemd/system/openvpn-client@.service ]]; then
+ local vpn_service=openvpn-client
+ else
+ local vpn_service=openvpn
+ fi
+ s systemctl stop $vpn_service@$1
}
xl() {
# this succeeds even if gnome-screensaver isn\'t running.
gnome-screensaver-command --exit &>/dev/null
+ mate-screensaver-command --exit &>/dev/null
if ! pidof xscreensaver; then
pushd /
xscreensaver &