X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc;h=f003263c7e37a8a187def9b2a3994003c39e9394;hb=8a6b446c7e336596af614c853e1c6177e55a7983;hp=046edbed75a35594cde84f4cc3101bf8e9e5e7bd;hpb=b857462732e15f455e41f26e3048a390d7b399c0;p=distro-setup diff --git a/brc b/brc index 046edbe..f003263 100644 --- a/brc +++ b/brc @@ -18,7 +18,7 @@ set -o pipefail 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 @@ -26,11 +26,11 @@ unalias -a 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 @@ -43,7 +43,7 @@ shopt -s no_empty_cmd_completion # 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 @@ -63,18 +63,18 @@ shopt -s globstar # 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'); @@ -90,7 +90,7 @@ if [[ $RLC_INSIDE_EMACS ]]; then # 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 @@ -123,7 +123,7 @@ if [[ $- == *i* ]]; then 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 @@ -147,22 +147,28 @@ HISTFILE=$HOME/.bh # the time format display when doing the history command # 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 +HISTTIMEFORMAT="%Y-%m-%d %I:%M %p " +# 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, # but meh. dunno why, but just " *" does glob expansion, so use [ ] to avoid it. -HISTIGNORE='pass *:k *:[ ]*:lom ' +HISTIGNORE='pass *:[ ]*:lom*:gram*' export BC_LINE_LENGTH=0 +export PROFILE_TASKS_TASK_OUTPUT_LIMIT=100 -# 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 +export SYSTEMD_LESS=$LESS # * include files for _x in /a/bin/distro-functions/src/* /a/bin/!(githtml)/*-function?(s); do @@ -173,8 +179,24 @@ unset _x 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 +# if someone exported $SOE (stop on error), catch errors +if [[ $SOE ]]; then + err-catch +fi + path_add /a/exe +# add this with absolute paths as needed for better security +#path_add --end /path/to/node_modules/.bin + +# 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 @@ -218,7 +240,7 @@ unalias ls ll grep &>/dev/null ||: # 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"/* @@ -264,16 +286,23 @@ _cdiff-prep() { } _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 @@ -285,7 +314,10 @@ khcopy() { } a() { - beet "${@}" + local x=$(readlink -nf "${1:-$PWD}") + # 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 "$@"; } @@ -298,6 +330,23 @@ anki() { fi } +ap() { + # pushd in case current directory has an ansible.cfg file + pushd /a/xans >/dev/null + ansible-playbook -v -l ${1:- $(hostname -f)} site.yml + popd >/dev/null +} +aw() { + pushd /a/work/ansible-configs >/dev/null + time ansible-playbook -v -i inventory adhoc.yml "$@" + popd >/dev/null +} +ad() { + pushd /a/bin/distro-setup/a >/dev/null + ansible-playbook site.yml + popd >/dev/null +} + astudio() { # googling android emulator libGL error: failed to load driver: r600 # lead to http://stackoverflow.com/a/36625175/14456 @@ -310,9 +359,22 @@ b() { c - } -bkrun() { - # use -p from interactive shell - btrbk-run -p "$@" +bbk() { + c / + local active=true + if systemctl is-active btrbk.service; then + echo "cron btrbk is already running" + return 1 + fi + systemctl is-active btrbk.timer || active=false + if $active; then + ser disable btrbk.timer + fi + # run latest + install-my-scripts + if ! btrbk-run "$@" && $active; then + ser enable btrbk.timer + fi } bfg() { java -jar /a/opt/bfg-1.12.14.jar "$@"; } @@ -321,6 +383,22 @@ bigclock() { xclock -digital -update 1 -face 'arial black-80:bold' } +bpull() { + [[ $1 ]] || return 1 + c / + # run latest + install-my-scripts + switch-mail-host $1 $HOSTNAME +} +bpush() { + [[ $1 ]] || return 1 + c / + # run latest + install-my-scripts + switch-mail-host $HOSTNAME $1 +} + + btc() { local f=/etc/bitcoin/bitcoin.conf # importprivkey will timeout if using the default of 15 mins. @@ -386,6 +464,8 @@ cam() { git commit -am "$*" } +cbfstool () { /a/opt/coreboot/build/cbfstool "$@"; } + ccat () { # config cat. see a config without extra lines. grep '^\s*[^;[:space:]#]' "$@" } @@ -403,7 +483,7 @@ cdiff() { _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" } @@ -416,6 +496,7 @@ cgpl() cp /a/bin/data/COPYING . fi } + capache() { if (($#)); then @@ -424,6 +505,20 @@ capache() cp /a/bin/data/LICENSE . fi } + +cat-new-files() { + local start=$SECONDS + local dir="$1" + inotifywait -m "$dir" -e create -e moved_to | + while read filedir _ file; do + cat "$filedir$file" + hr + calc $((SECONDS - start)) / 60 + sleep 5 + done + +} + chown() { # makes it so chown -R symlink affects the symlink and its target. if [[ $1 == -R ]]; then @@ -463,7 +558,7 @@ dat() { # do all tee, for more complex scripts da() { # do all local host "$@" - for host in x2 tp treetowl; do + for host in x2 tp kd; do ssh $host "$@" done } @@ -475,7 +570,7 @@ dc() { 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 @@ -529,7 +624,7 @@ envload() { # load environment from a previous: export > file # mail related etail() { - sudo tail -f /var/log/exim4/mainlog + sudo tail -F /var/log/exim4/mainlog -n 50 } f() { @@ -547,7 +642,7 @@ fa() { } faf() { # find all files - find -L $1 -not \( -name .svn -prune -o -name .git -prune \ + find -L $1 -type f -not \( -name .svn -prune -o -name .git -prune \ -o -name .hg -prune -o -name .editor-backups -prune \ -o -name .undo-tree-history -prune \) 2>/dev/null } @@ -565,10 +660,6 @@ kdecd() { /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd; } # 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) @@ -584,35 +675,47 @@ kdecd() { /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd; } # 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, @@ -837,7 +940,7 @@ gitian() { } 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 "$@" @@ -860,7 +963,11 @@ gpg() { } gse() { - git send-email --notes '--envelope-sender=' \ + local email=ian@iankelling.org + if readlink ~/.mu | grep fsf &>/dev/null; then + email=iank@fsf.org + fi + git send-email --notes "--envelope-sender=<$email>" \ --suppress-cc=self "$@" } @@ -868,11 +975,11 @@ gr() { 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 } @@ -906,7 +1013,7 @@ hl() { # history limit. Write extra history to archive file. 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)) @@ -922,7 +1029,38 @@ hr() { # horizontal row. used to break up output 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 --no-edit +# --no-edit means to use the first commit\'s message as the pull request message. +# Also, you need to use a feature branch, not master in your fork. +# 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 @@ -942,6 +1080,7 @@ ic() { git commit -am "$*" } + idea() { /a/opt/idea-IC-163.7743.44/bin/idea.sh "$@" &r } @@ -983,23 +1122,20 @@ ipdrop() { s iptables -A INPUT -s $1 -j DROP } -net-dev-info() { - e "lspci -nnk|gr -iA2 net" - lspci -nnk|gr -iA2 net - hr - e "s lshw -C network" - hr - s lshw -C network - -} istext() { grep -Il "" "$@" &>/dev/null } +jfilter() { + grep -Evi -e "^(\S+\s+){4}(sudo|sshd|cron)\[\S*:" \ + -e "^(\S+\s+){4}systemd\[\S*: (starting|started) (btrfsmaintstop|dynamicipupdate|spamd dns bug fix cronjob|rss2email)\.*$" +} jtail() { - journalctl -n 10000 -f "$@" | grep -Evi "^(\S+\s+){4}(sudo|sshd|cron)" + journalctl -n 10000 -f "$@" | jfilter } +jr() { journalctl "$@" | jfilter | less ; } +jrf() { journalctl -f "$@" | jfilter; } kff() { # keyboardio firmware flash pushd /a/bin/distro-setup/Arduino/Model01-Firmware @@ -1018,6 +1154,8 @@ l() { lcn() { locate -i "*$**"; } +lg() { LC_COLLATE=C.UTF-8 ll --group-directories-first; } + lt() { ll -tr "$@"; } lld() { ll -d "$@"; } @@ -1025,13 +1163,16 @@ lld() { ll -d "$@"; } lom() { local l base if [[ $1 == /* ]]; then + base=${1##*/} + if mountpoint /mnt/$base; then + return 0 + fi l=$(sudo losetup -f) sudo losetup $l $1 - base=${1##*/} 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 @@ -1039,7 +1180,7 @@ lom() { base=$1 sudo umount /mnt/$base l=$(sudo cryptsetup status /dev/mapper/$base|sed -rn 's/^\s*device:\s*(.*)/\1/p') - sudo cryptsetup luksClose /dev/mapper/$base + sudo cryptsetup luksClose /dev/mapper/$base || return 1 sudo losetup -d $l fi } @@ -1088,6 +1229,7 @@ mbenable() { dst=/m/4e/$1 src=/m/md/$1 set -x + [[ -e $src ]] || { set +x; return 1; } mv -T $src $dst || { set +x; return 1; } ln -s -T $dst $src /a/exe/lnf /p/.mu ~ @@ -1099,6 +1241,7 @@ mbdisable() { dst=/m/md/$1 src=/m/4e/$1 set -x + [[ -e $src ]] || { set +x; return 1; } if [[ -L $dst ]]; then rm $dst; fi mv -T $src $dst set +x @@ -1116,6 +1259,10 @@ mkc() { c "$1" } +mkct() { + mkc `mktemp -d` +} + mkt() { # mkdir and touch file local path="$1" mkdir -p "$(dirname "$path")" @@ -1126,6 +1273,15 @@ mkdir() { command mkdir -p "$@"; } mo() { xset dpms force off; } # monitor off +net-dev-info() { + e "lspci -nnk|gr -iA2 net" + lspci -nnk|gr -iA2 net + hr + e "s lshw -C network" + hr + s lshw -C network + +} nopanic() { sudo tee -a /var/log/exim4/paniclog-archive 2 return 1 @@ -1366,13 +1552,30 @@ scssl() { } ser() { - local s; [[ $EUID != 0 ]] && s=sudo + local s; [[ $EUID != 0 ]] && s=s if type -p systemctl &>/dev/null; then $s systemctl $1 $2 else $s service $2 $1 fi } +# like restart, but do nothing if its not already started +srestart() { + local service=$1 + if [[ $(s systemctl --no-pager show -p ActiveState $service ) == ActiveState=active ]]; then + systemctl restart $service + fi +} +stopnm() { + ser stop NetworkManager + ser stop dnsmasq + s resolvconf -d NetworkManager + ser start dnsmasq +} +startnm() { + ser start NetworkManager + s nmtui-connect +} setini() { # set a value in a .ini style file key="$1" value="$2" section="$3" file="$4" @@ -1474,6 +1677,10 @@ splay() { # script replay scriptreplay "$1.t" "$1.s" } +smeld() { # ssh meld usage host1 host2 file + meld <(ssh $1 cat $3) <(ssh $2 cat $3) +} + spd() { PATH=/usr/local/spdhackfix:$PATH command spd "$@" } @@ -1526,7 +1733,7 @@ t() { 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") @@ -1599,7 +1806,7 @@ testmail() { # 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 @@ -1618,7 +1825,7 @@ testsieve() { # 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 @@ -1627,30 +1834,38 @@ testexim() { # 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: ian@iankelling.org +To: root@lists0p.fsf.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 (sleep $(calc "$@ * 60") && mpv --no-config --volume 50 /a/bin/data/alarm.mp3) > /dev/null 2>&1 & } -tpx2() { - case $HOSTNAME in - tp) target=x2 ;; - x2) target=tp ;; - esac - btrbk-run -t $target -pv && switch-mail-host $HOSTNAME $target -} - trg() { transmission-remote-gtk&r; } trc() { # example, set global upload limit to 100 kilobytes: @@ -1668,11 +1883,22 @@ tu() { $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 @@ -1778,12 +2004,15 @@ vspicy() { # usage: VIRSH_DOMAIN sed -r "s/.*port='([0-9]+).*/\1/") } +wian() { + cat-new-files /m/4e/INBOX/new +} wtr() { curl wttr.in/boston; } 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 @@ -1798,6 +2027,8 @@ xl() { xscreensaver-command -activate } +xevkb() { xev -event keyboard; } + # * misc stuff # from curl cheat.sh/:bash_completion @@ -1902,7 +2133,7 @@ if [[ $- == *i* ]]; then # 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() { : @@ -1921,13 +2152,10 @@ if [[ $- == *i* ]]; then bind -m vi-command W:shell-forward-word fi - if [[ $SSH_CLIENT ]]; then + if [[ $SSH_CLIENT || $SUDO_USER ]]; then PS1="\h $PS1" fi - - - prompt-command() { local return=$? # this MUST COME FIRST local psc pst ps_char ps_color stale_subvol @@ -1955,12 +2183,15 @@ if [[ $- == *i* ]]; then 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 + if [[ ! $SSH_CLIENT && $MAIL_HOST != $HOSTNAME ]]; 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 @@ -1972,17 +2203,21 @@ if [[ $- == *i* ]]; then 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 @@ -2014,12 +2249,14 @@ reset-xscreensaver() { # xscreensaver-command -demo # then finding the corresponding option in .xscreensaver # spash, i happened to notice in .xscreensaver + # + # dpmsOff, monitor doesnt come back on using old free software supported nvidia card cat > /home/iank/.xscreensaver <<'EOF' mode: blank dpmsEnabled: True dpmsStandby: 0:02:00 -dpmsSuspend: 0:02:00 -dpmsOff: 0:03:00 +dpmsSuspend: 0:03:00 +dpmsOff: 0:00:00 timeout: 0:02:00 lock: True lockTimeout: 0:03:00 @@ -2042,42 +2279,39 @@ fi unset IFS -# if someone exported $SOE, catch errors -if [[ $SOE ]]; then - errcatch -fi - -# I'd 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. -# There a third hybrid form, which passenger error suggested I use, -# but it didn't actually work. - -# in cased I never need this -# rvm for non-interactive shell: modified from https://rvm.io/rvm/basics -#if [[ $(type -t rvm) == file && ! $(type -t ruby) ]]; then -# source $(rvm 1.9.3 do rvm env --path) +# 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 -# based on warning from rvmsudo -export rvmsudo_secure_path=1 -if [[ -s "/usr/local/rvm/scripts/rvm" ]]; then - source "/usr/local/rvm/scripts/rvm" -elif [[ -s $HOME/.rvm/scripts/rvm ]]; then - source $HOME/.rvm/scripts/rvm -fi export GOPATH=$HOME/go path_add $GOPATH/bin +path_add /usr/local/go/bin -export ARDUINO_PATH=/a/opt/Arduino/build/linux/work +# I have the git repo and a release. either one should work. +# I have both because I was trying to solve an issue that +# turned out to be unrelated. +# ARDUINO_PATH=/a/opt/Arduino/build/linux/work +export ARDUINO_PATH=/a/opt/arduino-1.8.9 path_add --end ~/.npm-global +# taken from default changes to bashrc and bash_profile +path_add --end $HOME/.rvm/bin +[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* + +export BASEFILE_DIR=/a/bin/fai-basefiles + +export ANDROID_HOME=/opt/android -# 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