remove kinsis / unused input settings
[distro-setup] / brc
diff --git a/brc b/brc
index ca9a78682a4d3ee5dd53c98abb2c246894be0949..fbc1acb2f653cc50467d6aeb9f6ff036cfc32c7a 100644 (file)
--- a/brc
+++ b/brc
@@ -109,18 +109,24 @@ if [[ $- == *i* ]]; then
         bind 'set print-completions-horizontally on'
         bind '"\C-i": self-insert'
     else
-        # arrow keys. for other terminals, see http://unix.stackexchange.com/questions/10806/how-to-change-previous-next-word-shortcut-in-bash
+        # sakura == xterm-256color
+        # konsole == xterm
         if [[ $TERM == "xterm" ]]; then
+            # control + arrow keys. for other terminals, see http://unix.stackexchange.com/questions/10806/how-to-change-previous-next-word-shortcut-in-bash
             bind '"\e[1;5C": shell-forward-word' 2>/dev/null
             bind '"\e[1;5D": shell-backward-word' 2>/dev/null
         else
+            # make ctrl-backspace work. for konsole, i fixed it through
+# /home/iank/.local/share/konsole/default.keytab
+            stty werase '^h'
             bind '"\eOc": shell-forward-word'
             bind '"\eOd": shell-backward-word'
         fi
-        # terminal keys: C-c, C-z. the rest defined by stty -a are, at least in
+        # i can't 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
-        stty werase undef lnext undef stop undef start undef
-
+        stty  lnext undef stop undef start undef
     fi
 
 fi
@@ -552,7 +558,7 @@ fa() {
 }
 
 faf() { # find all files
-    find -L $1 -type f -not \( -name .svn -prune -o -name .git -prune \
+    find -L $1 -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
 }
@@ -963,6 +969,11 @@ jtail() {
     journalctl -n 10000 -f "$@" | grep -Evi "^(\S+\s+){4}(sudo|sshd|cron)"
 }
 
+kff() { # keyboardio firmware flash
+    pushd /a/opt/sketches/Model01-Firmware
+    yes $'\n' | make flash
+    popd
+}
 
 l() {
     if [[ $PWD == /[iap] ]]; then
@@ -1306,6 +1317,28 @@ ser() {
     fi
 }
 
+setini() { # set a value in a .ini style file
+    key="$1" value="$2" section="$3" file="$4"
+    if [[ -s $file ]]; then
+        sed -ri -f - "$file" <<EOF
+# remove existing keys
+/ *\[$section\]/,/^ *\[[^]]+\]/{/^\s*$key[[:space:]=]/d}
+# add key
+/^\s*\[$section\]/a $key=$value
+# from section to eof, do nothing
+/^\s*\[$section\]/,\$b
+# on the last line, if we haven't found section yet, add section and key
+\$a [$section]\\
+$key=$value
+EOF
+    else
+        cat >"$file" <<EOF
+[$section]
+$key=$value
+EOF
+    fi
+}
+
 sgo() { # service go
     service=$1
     ser restart $service || return 1
@@ -1318,7 +1351,7 @@ sgo() { # service go
 shellck() {
     # 2086 = unquoted $var
     # 2046 = unquoted $(cmd)
-    # i had -x as an arg, but debian testing(stretch) doesn't support it
+    # i had -x as an arg, but debian testing(stretch) doesn\'t support it
     shellcheck -e 2086,2046,2068,2006,2119 "$@"
 }
 
@@ -1439,142 +1472,142 @@ t() {
             fi
         done
         [[ ! ${args[@]} ]] || trash-put "${args[@]}"
-      else
-          rm -rf "$@"
-fi
-}
-
-
-tclock() {
-    clear
-    date +%l:%_M
-    len=60
-    # this goes to full width
-    #len=${1:-$((COLUMNS -7))}
-    x=1
-    while true; do
-        if (( x == len )); then
-            end=true
-            d="$(date +%l:%_M)   "
-        else
-            end=false
-            d=$(date +%l:%M:%_S)
-        fi
-        echo -en "\r"
-        echo -n "$d"
-        for ((i=0; i<x; i++)); do
-            if (( i % 6 )); then
-                echo -n _
-            else
-                echo -n .
-            fi
-        done
-        if $end; then
-            echo
-            x=1
-        else
-            x=$((x+1))
-        fi
-        sleep 5
-    done
-}
-
-
-te() {
-    # test existence / exists
-    local ret=0
-    for x in "$@"; do
-        [[ -e "$x" || -L "$x" ]] || ret=1
-    done
-    return $ret
-}
-
-# mail related
-testmail() {
-    declare -gi _seq; _seq+=1
-    echo "test body" | m mail -s "test mail from $HOSTNAME, $_seq" "${@:-root@localhost}"
-    # for testing to send from an external address, you can do for example
-    # -aFrom:ian@iank.bid web-6fnbs@mail-tester.com
-    # note in exim, you can retry a deferred message
-    # s exim -M MSG_ID
-    # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN
-}
-
-# to test sieve, use below command. for fsf mail, see fsf-get-mail script.
-# make modifications, then copy to live file, use -eW to actually modify mailbox
-# 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 with output filter. arg is mailbox, like INBOX.
-# This depends on dovecot conf, notably mail_location in /etc/dovecot/conf.d/10-mail.conf
-
-testsievelist() {
-    sieve-filter ~/sieve/maintest.sieve "$@" >/tmp/testsieve.log 2> >(tail) && sed -rn '/^Performed actions:/{n;n;p}' /tmp/testsieve.log | sort -u
-}
-
-
-# mail related
-# plain sieve
-testsieve() {
-    sieve-filter ~/sieve/main.sieve "$@"
-}
-
-# 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
-    # 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
-    #
-    # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.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'
+                           else
+                               rm -rf "$@"
+                          fi
+}
+
+
+ tclock() {
+     clear
+     date +%l:%_M
+     len=60
+     # this goes to full width
+     #len=${1:-$((COLUMNS -7))}
+     x=1
+     while true; do
+         if (( x == len )); then
+             end=true
+             d="$(date +%l:%_M)   "
+         else
+             end=false
+             d=$(date +%l:%M:%_S)
+         fi
+         echo -en "\r"
+         echo -n "$d"
+         for ((i=0; i<x; i++)); do
+             if (( i % 6 )); then
+                 echo -n _
+             else
+                 echo -n .
+             fi
+         done
+         if $end; then
+             echo
+             x=1
+         else
+             x=$((x+1))
+         fi
+         sleep 5
+     done
+ }
+
+
+ te() {
+     # test existence / exists
+     local ret=0
+     for x in "$@"; do
+         [[ -e "$x" || -L "$x" ]] || ret=1
+     done
+     return $ret
+ }
+
+ # mail related
+ testmail() {
+     declare -gi _seq; _seq+=1
+     echo "test body" | m mail -s "test mail from $HOSTNAME, $_seq" "${@:-root@localhost}"
+     # for testing to send from an external address, you can do for example
+     # -aFrom:ian@iank.bid web-6fnbs@mail-tester.com
+     # note in exim, you can retry a deferred message
+     # s exim -M MSG_ID
+     # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN
+ }
+
+ # to test sieve, use below command. for fsf mail, see fsf-get-mail script.
+ # make modifications, then copy to live file, use -eW to actually modify mailbox
+ # 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 with output filter. arg is mailbox, like INBOX.
+ # This depends on dovecot conf, notably mail_location in /etc/dovecot/conf.d/10-mail.conf
+
+ testsievelist() {
+     sieve-filter ~/sieve/maintest.sieve "$@" >/tmp/testsieve.log 2> >(tail) && sed -rn '/^Performed actions:/{n;n;p}' /tmp/testsieve.log | sort -u
+ }
+
+
+ # mail related
+ # plain sieve
+ testsieve() {
+     sieve-filter ~/sieve/main.sieve "$@"
+ }
+
+ # 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
+     # 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
+     #
+     # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.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
 Subject: Testing Exim
 
 This is a test message.
 EOF
-}
-
-tm() {
-    # timer in minutes
-    # --no-config
-    (sleep $(calc "$@ * 60") && mpv --no-config --volume 50 /a/bin/data/alarm.mp3) > /dev/null 2>&1 &
-}
-
-trg() { transmission-remote-gtk&r; }
-trc() {
-    # example, set global upload limit to 100 kilobytes:
-    # trc -u 100
-    TR_AUTH=":$(jq -r .profiles[0].password ~/.config/transmission-remote-gtk/config.json)" transmission-remote transmission.lan -ne "$@"
-}
-
-
-tu() {
-    local s;
-    local dir="$(dirname "$1")"
-    if [[ -e $1 && ! -w $1 || ! -w $(dirname "$1") ]]; then
-        s=s;
-    fi
-    $s teeu "$@"
-}
-
-tx() { # toggle set -x, and the prompt so it doesn't spam
-       if [[ $- == *x* ]]; then
-           set +x
-           PROMPT_COMMAND=prompt_command
-       else
-           unset PROMPT_COMMAND
-           PS1="\w \$ "
-           set -x
-       fi
+ }
+
+ tm() {
+     # timer in minutes
+     # --no-config
+     (sleep $(calc "$@ * 60") && mpv --no-config --volume 50 /a/bin/data/alarm.mp3) > /dev/null 2>&1 &
+ }
+
+ trg() { transmission-remote-gtk&r; }
+ trc() {
+     # example, set global upload limit to 100 kilobytes:
+     # trc -u 100
+     TR_AUTH=":$(jq -r .profiles[0].password ~/.config/transmission-remote-gtk/config.json)" transmission-remote transmission.lan -ne "$@"
+ }
+
+
+ tu() {
+     local s;
+     local dir="$(dirname "$1")"
+     if [[ -e $1 && ! -w $1 || ! -w $(dirname "$1") ]]; then
+         s=s;
+     fi
+     $s teeu "$@"
+ }
+
+ tx() { # toggle set -x, and the prompt so it doesn't spam
+        if [[ $- == *x* ]]; then
+            set +x
+            PROMPT_COMMAND=prompt-command
+        else
+            unset PROMPT_COMMAND
+            PS1="\w \$ "
+            set -x
+        fi
 }
 
 psnetns() {
@@ -1676,8 +1709,11 @@ vspicy() { # usage: VIRSH_DOMAIN
 wtr() { curl wttr.in/boston; }
 
 xl() {
-    # this succeeds even if gnome-screensaver isn\'t running.
+    if pgrep gnome-screensav &>/dev/null; then
+    # this command actually starts gnome-screensaver if it isn't running.
+    # lololol, what crap
     gnome-screensaver-command --exit &>/dev/null
+    fi
     mate-screensaver-command --exit &>/dev/null
     if ! pidof xscreensaver; then
         pushd /
@@ -1686,7 +1722,7 @@ xl() {
         # 1 was not long enough
         sleep 3
     fi
-    xscreensaver-command -lock
+    xscreensaver-command -activate
 }
 
 #############################
@@ -1823,22 +1859,15 @@ if [[ $- == *i* ]]; then
         PS1="\h $PS1"
     fi
 
-    prompt_command() {
+
+
+
+    prompt-command() {
         local return=$? # this MUST COME FIRST
         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
-                local title_escape="\033]..2;"
-            else
-                local title_escape="\033]0;"
-            fi
-           echo -ne "$title_escape${PWD/#$HOME/~}  $USER@$HOSTNAME\007"
-       fi
 
 
         case $return in
@@ -1868,9 +1897,70 @@ if [[ $- == *i* ]]; then
         # 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)\] "
     }
-    PROMPT_COMMAND=prompt_command
+    PROMPT_COMMAND=prompt-command
+
+    settitle () {
+        if [[ $TERM == screen* ]]; then
+            local title_escape="\033]..2;"
+        else
+            local title_escape="\033]0;"
+        fi
+        if [[ $* != prompt-command ]]; then
+           echo -ne "$title_escape$USER@$HOSTNAME ${PWD/#$HOME/~} $*\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
+
 fi
 
+reset-konsole() {
+    # we also have a file in /a/c/...konsole...
+    local f=$HOME/.config/konsolerc
+    setini DefaultProfile profileian.profile "Desktop Entry" $f
+    setini Favorites profileian.profile "Favorite Profiles" $f
+    setini ShowMenuBarByDefault false KonsoleWindow $f
+    setini TabBarPosition Top TabBar $f
+}
+
+reset-sakura() {
+    while read k v; do
+        setini $k $v sakura /a/c/subdir_files/.config/sakura/sakura.conf
+    done <<'EOF'
+colorset1_back rgb(33,37,39
+less_questions true
+audible_bell No
+visible_bell No
+disable_numbered_tabswitch true
+scroll_lines 10000000
+scrollbar true
+EOF
+}
+
+reset-xscreensaver() {
+    # except for spash, i set these by setting gui options in
+    # xscreensaver-command -demo
+    # then finding the corresponding option in .xscreensaver
+    # spash, i happened to notice in .xscreensaver
+    cat > /home/iank/.xscreensaver <<'EOF'
+mode:          blank
+dpmsEnabled:   True
+dpmsStandby:   0:01:00
+dpmsSuspend:   0:01:00
+dpmsOff:       0:02:00
+timeout:       0:01:00
+lock:           True
+lockTimeout:   0:02:00
+splash:                False
+EOF
+
+}
 
 
 ###########################################
@@ -1918,6 +2008,7 @@ fi
 export GOPATH=$HOME/go
 path_add $GOPATH/bin
 
+export ARDUINO_PATH=/a/opt/Arduino/build/linux/work
 
 path_add --end ~/.npm-global