unalias -a
# remove gnome keyring warning messages
-# there is probably a more proper way, but I didn't find any easily on google
+# there is probably a more proper way, but I didnt find any easily on google
# now using xfce+xmonad instead of vanilla xmonad, so disabling this
#unset GNOME_KEYRING_CONTROL
shopt -s extglob
# include .files when globbing, but ignore files name . and ..
# setting this also sets dotglob.
-# Note, this doesn't work in bash 4.4 anymore, for paths with
+# Note, this doesnt work in bash 4.4 anymore, for paths with
# more than 1 directory, like a/b/.foo, since * is fixed to not match /
export GLOBIGNORE=*/.:*/..
-# broken with bash_completion package. Saw a bug for this once. Don't anymore.
+# broken with bash_completion package. Saw a bug for this once. dont anymore.
# still broken in wheezy
# still buggered in latest stable from the web, version 2.1
# perhaps its fixed in newer git version, which fails to make for me
# advanced completion
# http://bash-completion.alioth.debian.org/
-# might be sourced by the system already, but I've noticed it not being sourced before
+# might be sourced by the system already, but ive noticed it not being sourced before
if ! type _init_completion &> /dev/null && [[ -r "/usr/share/bash-completion/bash_completion" ]]; then
. /usr/share/bash-completion/bash_completion
fi
# inside emcas fixes
if [[ $RLC_INSIDE_EMACS ]]; then
- # EMACS is used by bash on startup, but we don't need it anymore.
+ # EMACS is used by bash on startup, but we dont need it anymore.
# plus I hit a bug in a makefile which inherited it
unset EMACS
export RLC_INSIDE_EMACS
export PAGER=cat
export MANPAGER=cat
- # scp completion does not work, but this doesn't fix it. todo, figure this out
+ # scp completion does not work, but this doesnt fix it. todo, figure this out
complete -r scp &> /dev/null
# todo, remote file completion fails, figure out how to turn it off
export NODE_DISABLE_COLORS=1
- # This get's rid of ugly terminal escape chars in node repl
- # sometime, I'd like to have completion working in emacs shell for node
+ # This gets rid of ugly terminal escape chars in node repl
+ # sometime, Id like to have completion working in emacs shell for node
# the offending chars can be found in lib/readline.js,
# things that do like:
# stream.write('\x1b[' + (x + 1) + 'G');
# no prompt, or else readline complete seems to be confused, based
# on our column being different? node probably needs to send
# different kind of escape sequence that is not ugly. Anyways,
- # completion doesn't work yet even with the ugly prompt, so whatever
+ # completion doesnt work yet even with the ugly prompt, so whatever
#
export NODE_NO_READLINE=1
bind '"\eOc": shell-forward-word'
bind '"\eOd": shell-backward-word'
fi
- # i can't remember why i did this, probably to free up some keys to bind
+ # i cant remember why i did this, probably to free up some keys to bind
# to other things in bash.
# other than C-c and C-z, the rest defined by stty -a are, at least in
# gnome-terminal, overridden by bash, or disabled by the system
# also, setting this makes the history file record time
# of each command as seconds from the epoch
HISTTIMEFORMAT="%I:%M %p %m/%d "
-# consecutive duplicate lines don't go in history
+# consecutive duplicate lines dont go in history
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,
export BC_LINE_LENGTH=0
-# note, if I use a machine I don't want files readable by all users, set
+# note, if I use a machine I dont want files readable by all users, set
# umask 077 # If fewer than 4 digits are entered, leading zeros are assumed
C_DEFAULT_DIR=/a
+# i for insensitive. the rest from
+# https://superuser.com/questions/366930/how-do-i-get-the-git-pager-to-clean-up-screen-output-after-exit
+# and reading the man
+export LESS=RXi
# * include files
for _x in /a/bin/distro-functions/src/* /a/bin/!(githtml)/*-function?(s); do
for x in /a/bin/bash_unpublished/source-!(.#*); do source $x; done
source $(dirname $(readlink -f $BASH_SOURCE))/path_add-function
source /a/bin/log-quiet/logq-function
+if [[ -e /a/bin/errhandle/err ]]; then
+ source /a/bin/errhandle/err
+ err-allow
+fi
path_add /a/exe
+# pip3 --user things go here:
+path_add --end ~/.local/bin
+path_add --ifexists --end /a/work/libremanage
path_add --ifexists --end /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools
+path_add --ifexists --end /a/opt/scancode-toolkit-2.9.2
export WCDHOME=/a
# based on readme.debian. dunno if this will break on other distros.
_x=/usr/share/wcd/wcd-include.sh
# file cut copy and paste, like the text buffers :)
-# I havn't tested these.
+# I havnt tested these.
_fbufferinit() { # internal use by
! [[ $my_f_tempdir ]] && my_f_tempdir=$(mktemp -d)
rm -rf "$my_f_tempdir"/*
}
_khfix_common() {
- local h=${1##*@}
- local x
- ssh-keygen -R $h -f $(readlink -f ~/.ssh/known_hosts)
- x=$(timeout 1 ssh -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $1 |& sed -rn "s/debug1: Connecting to $h \[([^\]*)].*/\1/p")
- if [[ ! $x ]]; then
+ local host=${1##*@}
+ local ip port
+ read -r ip port < <(timeout 1 ssh -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $1 |& sed -rn "s/debug1: Connecting to $host \[([^\]*)] port ([0-9]+).*/\1 \2/p")
+ if [[ ! $ip ]]; then
echo "khfix: ssh failed"
return 1
fi
- echo "khfix: removing key for $x"
- ssh-keygen -R $x -f $(readlink -f ~/.ssh/known_hosts)
+ if [[ $port != 22 ]]; then
+ ip_entry="[$ip]:$port"
+ host_entry="[$host]:$port"
+ else
+ ip_entry=$ip
+ host_entry=$host
+ fi
+ ssh-keygen -R "$host_entry" -f $(readlink -f ~/.ssh/known_hosts)
+ echo "khfix: removing key for $ip_entry"
+ ssh-keygen -R "$ip_entry" -f $(readlink -f ~/.ssh/known_hosts)
}
khfix() { # known hosts fix
_khfix_common "$@" || return 1
}
a() {
- beet "${@}"
+ local x=$(readlink -nf "$@")
+ # yes, its kinda dumb that xclip/xsel cant do this in one invocation
+ echo -n "$x" | xclip -selection clipboard
+ echo -n "$x" | xclip
}
ack() { ack-grep "$@"; }
_cdiff-prep "$2" "$f2"
cat "$f1" "$f2" | grep -Po '^[^=]+=' | sort | uniq > "$unified"
while IFS= read -r line; do
- # the default bright red / blue doesn't work in emacs shell
+ # the default bright red / blue doesnt work in emacs shell
dwdiff -cblue,red -A best -d " ," <(grep "^$line" "$f1" || echo ) <(grep "^$line" "$f2" || echo ) | colordiff
done < "$unified"
}
da() { # do all
local host
"$@"
- for host in x2 tp treetowl; do
+ for host in x2 tp kd; do
ssh $host "$@"
done
}
debian_pick_mirror () {
# netselect-apt finds a fast mirror.
# but we need to replace the mirrors ourselves,
- # because it doesn't do that. best it can do is
+ # because it doesnt do that. best it can do is
# output a basic sources file
# here we get the server it found, get the main server we use
# then substitute all instances of one for the other in the sources file
# fdroidcl search -i, then manually removing
# automatically installed/preinstalled apps
-# firefox updater. commented out, firefox depends on nonfree opengl.
-# de.marmaro.krt.ffupdater
-# # causes replicant to die on install and go into a boot loop
-# me.ccrama.redditslide
#
# # my attempt at recovering from boot loop:
# # in that case, boot to recovery (volume up, home button, power, let go of power after samsun logo)
# org.quantumbadger.redreader
# org.kde.kdeconnect_tp
-# not broke, but won't work without gps
+# not broke, but wont work without gps
#com.zoffcc.applications.zanavi
# not broke, but not using atm
#com.nutomic.syncthingandroid
-#org.fedorahosted.freeotp
# # doesn\'t work on replicant
#net.sourceforge.opencamera
#
fdroid_pkgs=(
+ de.marmaro.krt.ffupdater
+ me.ccrama.redditslide
+ org.fedorahosted.freeotp
at.bitfire.davdroid
com.alaskalinuxuser.justnotes
com.artifex.mupdf.viewer.app
+ com.danielkim.soundrecorder
com.fsck.k9
com.ghostsq.commander
com.ichi2.anki
com.jmstudios.redmoon
com.jmstudios.chibe
+ org.kde.kdeconnect_tp
com.notecryptpro
com.termux
cz.martykan.forecastie
de.danoeh.antennapod
+ de.blinkt.openvpn
+ de.marmaro.krt.ffupdater
+ eu.siacs.conversations
+ free.rm.skytube.oss
im.vector.alpha # riot
info.papdt.blackblub
me.tripsit.tripmobile
net.gaast.giggity
+ net.minetest.minetest
net.osmand.plus
org.isoron.uhabits
+ org.linphone
+ org.gnu.icecat
org.smssecure.smssecure
org.yaaic
+ sh.ftp.rocketninelabs.meditationassistant.opensource
)
# https://forum.xda-developers.com/android/software-hacking/wip-selinux-capable-superuser-t3216394
# for maru,
}
gh() {
- # i got an error, gh not found when doing a pull request, it seems like it wants itself in it's path.
+ # i got an error, gh not found when doing a pull request, it seems like it wants itself in it\'s path.
local _oldpath="$PATH"
PATH="$PATH:~/node_modules/.bin"
command gh "$@"
grep -iIP --color=auto "$@"
}
-grr() {
+grr() { # grep recursive
if [[ ${#@} == 1 ]]; then
- grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@" .
+ grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -RiIP --color=auto "$@" .
else
- grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@"
+ grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -RiIP --color=auto "$@"
fi
}
history -a # save history
max_lines=$HISTFILELINES
[[ $max_lines =~ ^[0-9]+$ ]] || { echo "error in hl: failed to get max line count"; return 1; }
- linecount=$(wc -l < $HISTFILE) # pipe so it doesn't output a filename
+ linecount=$(wc -l < $HISTFILE) # pipe so it doesnt output a filename
[[ $linecount =~ ^[0-9]+$ ]] || { echo "error in hl: wc failed"; return 1; }
if (($linecount > $max_lines)); then
prune_lines=$(($linecount - $max_lines))
hrcat() { local f; for f; do [[ -f $f ]] || continue; hr; echo "$f"; cat "$f"; done }
-hub() { /nocow/t/hub-linux-amd64-2.3.0-pre10/bin/hub "$@"; }
+# get latest hub and run it
+# main command to use:
+# hub pull-request
+# on first use, you input username/pass and it gets an oath token so you dont have to repeat
+# it\'s at ~/.config/hub
+hub() {
+ local up uptar updir p
+ p=/github/hub/releases/
+ up=https://github.com/$(curl -s https://github.com$p| grep -o $p'download/[^/]*/hub-linux-amd64[^"]*' | head -n1)
+ uptar=${up##*/}
+ updir=${uptar%.tgz}
+ if [[ ! -e /a/opt/$updir ]]; then
+ rm -rf /a/opt/hub-linux-amd64*
+ wget -P /a/opt $up
+ tar -C /a/opt -zxf /a/opt/$uptar
+ rm -f /a/opt/$uptar
+ s /a/opt/$updir/install
+ fi
+
+ # save token across computers
+ if [[ ! -L ~/.config/hub ]]; then
+ if [[ -e ~/.config/hub ]]; then
+ mv ~/.config/hub /p/c/subdir_files/.config/
+ fi
+ if [[ -e /p/c/subdir_files/.config/hub ]]; then
+ conflink
+ fi
+ fi
+ command hub "$@"
+}
i() { git "$@"; }
# modified from ~/local/bin/git-completion.bash
if ! sudo cryptsetup luksOpen $l $base; then
sudo losetup -d $l
return 1
- fi
+ fi
sudo mkdir -p /mnt/$base
sudo mount /dev/mapper/$base /mnt/$base
sudo chown $USER:$USER /mnt/$base
c "$1"
}
+mkct() {
+ mkc `mktemp -d`
+}
+
mkt() { # mkdir and touch file
local path="$1"
mkdir -p "$(dirname "$path")"
}
pubip() { curl -4s https://icanhazip.com; }
+pubip6() { curl -6s https://icanhazip.com; }
whatismyip() { pubip; }
pumpa() {
# packages catches up on some changes in future (this is written in
# 4/2017)
#
- # geekosaur: so you'll want to upgrade to xmonad 0.13 or else use a
- # locally modified XMonad.Hooks.ManageDocks that doesn't set the
- # work area; turns out it's impossible to set correctly if you are
+ # geekosaur: so youll want to upgrade to xmonad 0.13 or else use a
+ # locally modified XMonad.Hooks.ManageDocks that doesnt set the
+ # work area; turns out it\'s impossible to set correctly if you are
# not a fully EWMH compliant desktop environment
#
# geekosaur: chrome shows one failure mode, qt/kde another, other
# gtk apps a third, ... I came up with a setting that works for me
- # locally but apparently doesn't work for others, so we joined the
+ # locally but apparently doesnt work for others, so we joined the
# other tiling window managers in giving up on setting it at all
#
xprop -root -remove _NET_WORKAREA
# -x = max length
# -t = print pronunciation
apg -m 14 -x 17 -t
+ for (( i=0; i<10; i++ )); do
+ shuf -n3 /usr/share/hunspell/en_US.dic | sed 's,/.*,,' | paste -sd . -
+
+ done
}
pwlong() {
rsync -ahvic --delete "$@"
}
rld() {
- # like rlu, but don't delete files on the target end which
+ # like rlu, but dont delete files on the target end which
# do not exist on the original end.
rsync -ahvic "$@"
}
if [[ $path == .* ]]; then
path=$(readlink -f $path)
fi
- # rync here uses checksum instead of time so we don't mess with
+ # rync here uses checksum instead of time so we dont mess with
# unison relying on time as much. g is for group, same reason
# to keep up with unison.
s rsync -rlpchviog --relative "${opts[@]}" "$path" "root@$host:/";
# initial setup of rss2email:
# r2e new r2e@iankelling.org
# that initializes files, and sets default email.
- # symlink to the config doesn't work, so I copied it to /p/c
+ # symlink to the config doesnt work, so I copied it to /p/c
# and then use cli option to specify explicit path.
# Only option changed from default config is to set
# force-from = True
# address, which makes me be a spammer.
r2e add $1 "$2" $1@r2e.iankelling.org
- # get up to date and don't send old entries now:
+ # get up to date and dont send old entries now:
r2e run --no-send $1
}
r2e() { command r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg "$@"; }
}
rmstrips() {
- ssh fencepost head -n 300 /gd/gnuorg/EventAndTravelInfo/rms-current-trips.txt
+ ssh fencepost head -n 300 /gd/gnuorg/EventAndTravelInfo/rms-current-trips.txt | less
}
s() {
# background
- # I use a function because otherwise we can't use in a script,
- # can't assign to variable.
+ # I use a function because otherwise we cant use in a script,
+ # cant assign to variable.
#
# note: gksudo is recommended for X apps because it does not set the
# home directory to the same, and thus apps writing to ~ fuck things up
fi
}
-safe_rename() { # warn and don't rename if file exists.
- # mv -n exists, but it's silent
+safe_rename() { # warn and dont rename if file exists.
+ # mv -n exists, but it\'s silent
if [[ $# != 2 ]]; then
echo safe_rename error: $# args, need 2 >2
return 1
$s service $2 $1
fi
}
+serstopnm() {
+ ser stop NetworkManager
+ ser stop dnsmasq
+ s resolvconf -d NetworkManager
+ ser start dnsmasq
+}
setini() { # set a value in a .ini style file
key="$1" value="$2" section="$3" file="$4"
local x
local -a args
if type -t trash-put >/dev/null; then
- # skip args that don't exist, or else trash-put will have an error
+ # skip args that dont exist, or else trash-put will have an error
for x in "$@"; do
if [[ -e $x || -L $x ]]; then
args+=("$x")
# cp /p/c/subdir_files/sieve/personal{test,}.sieve; testsievelist -eW INBOX
#
# Another option is to use sieve-test SCRIPT MAIL_FILE. note,
-# sieve-test doesn't know about envelopes, I'm not sure if sieve-filter does.
+# sieve-test doesnt know about envelopes, Im not sure if sieve-filter does.
# sieve with output filter. arg is mailbox, like INBOX.
# This depends on dovecot conf, notably mail_location in /etc/dovecot/conf.d/10-mail.conf
# mail related
testexim() {
# testmail above calls sendmail, which is a link to exim/postfix.
- # it's docs don't say a way of adding an argument
+ # its docs dont say a way of adding an argument
# to sendmail to turn on debug output. We could make a wrapper, but
# that is a pain. Exim debug args are documented here:
# http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
# note, for exim daemon, you can turn on debug options by
# adding -d, etc to COMMONOPTIONS in
# /etc/default/exim4
- # for testing external mail, you need the to address as final cmdline arg
- exim -d+tls -t <<'EOF'
-From: root@frodo.lan
-To: ian@mail.iankelling.org
+ exim -d -t <<'EOF'
+From: root@gnu.org
+To: ian@iankelling.org
Subject: Testing Exim
This is a test message.
EOF
}
+# toggle keyboard
+tk() {
+ # based on
+ # https://askubuntu.com/questions/160945/is-there-a-way-to-disable-a-laptops-internal-keyboard
+ id=$(xinput --list --id-only 'AT Translated Set 2 keyboard')
+ if xinput list | grep -F '∼ AT Translated Set 2 keyboard' &>/dev/null; then
+ echo enabling keyboard
+ # find the first slave keyboard number, they are all the same in my output.
+ # if they werent, worst case we would need to save the slave number somewhere
+ # when it got disabled.
+ slave=$(xinput list | sed -n 's/.*slave \+keyboard (\([0-9]*\)).*/\1/p' | head -n1)
+ xinput reattach $id $slave
+ else
+ xinput float $id
+ fi
+}
+
tm() {
# timer in minutes
# --no-config
$s teeu "$@"
}
-tx() { # toggle set -x, and the prompt so it doesn't spam
+tx() { # toggle set -x, and the prompt so it doesnt spam
if [[ $- == *x* ]]; then
set +x
PROMPT_COMMAND=prompt-command
+ # disabled due to issue on stretch, running ll we get error. something
+ # about the DEBUG trap is broken
+ # if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then
+ # trap 'settitle "$BASH_COMMAND"' DEBUG
+ # fi
else
+ # normally, i would just execute these commands in the function.
+ # however, DEBUG is not inherited, so we need to run it outside a function.
+ # And we want to run set -x afterwards to avoid spam, so we cram everything
+ # in here, and then it will run after this function is done.
+ #PROMPT_COMMAND='trap DEBUG; unset PROMPT_COMMAND; PS1="\w \$ "; set -x'
+
unset PROMPT_COMMAND
PS1="\w \$ "
set -x
xl() {
if pgrep gnome-screensav &>/dev/null; then
- # this command actually starts gnome-screensaver if it isn't running.
+ # this command actually starts gnome-screensaver if it isn\'t running.
# lololol, what crap
gnome-screensaver-command --exit &>/dev/null
fi
# fedora/debian source
[[ -r /usr/share/git-core/contrib/completion/git-prompt.sh ]] && source /usr/share/git-core/contrib/completion/git-prompt.sh
- # in case we didn't source git-prompt.sh
+ # in case we didnt source git-prompt.sh
if ! declare -f __git_ps1 > /dev/null; then
__git_ps1() {
:
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
+ # doesnt work if not in top level.
+ if [[ -e /nocow/btrfs-stale ]] && ((`command 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.
+ # emacs completion doesnt like the git prompt atm, so disabling it.
#PS1="${PS1%"${PS1#*[wW]}"}$(__git_ps1 ' (%s)') \[$ps_color\]$ps_char\[$(get_term_color nocolor)\] "
}
PROMPT_COMMAND=prompt-command
local title_escape="\033]0;"
fi
if [[ $* != prompt-command ]]; then
- echo -ne "$title_escape$USER@$HOSTNAME ${PWD/#$HOME/~}"; printf "%s" "$*"; echo -ne "\007"
+ echo -ne "$title_escape$USER@$HOSTNAME ${PWD/#$HOME/~} "
+ printf "%s" "$*"
+ echo -ne "\007"
fi
}
- # for titlebar
- # condition from the screen man page i think
- if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then
- trap 'settitle "$BASH_COMMAND"' DEBUG
- else
- trap DEBUG
- fi
+ # for titlebar.
+ # condition from the screen man page i think.
+ # note: duplicated in tx()
+ # disabled. see note in tx
+ # if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then
+ # trap 'settitle "$BASH_COMMAND"' DEBUG
+ # else
+ # trap DEBUG
+ # fi
fi
errcatch
fi
-# I'd prefer to have system-wide, plus user ruby, due to bug in it
+# for mitmproxy to get a newer python.
+# commented until i want to use it because it
+# noticably slows bash startup
+#
+#if [[ $EUID != 0 && -e ~/.pyenv/bin ]]; then
+# export PATH="~/.pyenv/bin:$PATH"
+# eval "$(pyenv init -)"
+# eval "$(pyenv virtualenv-init -)"
+#fi
+
+# id prefer to have system-wide, plus user ruby, due to bug in it
# https://github.com/rubygems/rubygems/pull/1002
# further problems: installing multi-user ruby and user ruby,
-# you don't get multi-user ruby when you sudo to root, unless its sudo -i.
+# you dont get multi-user ruby when you sudo to root, unless its sudo -i.
# There a third hybrid form, which passenger error suggested I use,
-# but it didn't actually work.
+# but it didnt actually work.
# in cased I never need this
# rvm for non-interactive shell: modified from https://rvm.io/rvm/basics
path_add --end ~/.npm-global
+export BASEFILE_DIR=/a/bin/fai-basefiles
-# didn't get drush working, if I did, this seems like the
+# didnt get drush working, if I did, this seems like the
# only good thing to include for it.
# Include Drush completion.
# if [ -f "/home/ian/.drush/drush.complete.sh" ] ; then