small fix and additions
authorIan Kelling <ian@iankelling.org>
Sun, 15 Jan 2017 15:33:26 +0000 (07:33 -0800)
committerIan Kelling <ian@iankelling.org>
Thu, 4 May 2017 23:42:08 +0000 (16:42 -0700)
brc

diff --git a/brc b/brc
index 1da002401cabee7634f6b6043615b752b12e5dd1..69d54ad36ef79ac6b3e1ff2b23614b46620654b6 100644 (file)
--- a/brc
+++ b/brc
@@ -64,7 +64,7 @@ shopt -s cmdhist
 shopt -s globstar
 
 
-# inside emacs fixes
+# inside emcas fixes
 if [[ $RLC_INSIDE_EMACS ]]; then
     # EMACS is used by bash on startup, but we don't need it anymore.
     # plus I hit a bug in a makefile which inherited it
@@ -327,11 +327,21 @@ btc() {
     bitcoin-cli -$(s grep rpcuser= $f) -$(s grep rpcpassword= $f) "$@"
 }
 
+btcusd() {
+    local price
+    price="$(curl -s https://blockchain.info/ticker | jq .USD.last)"
+    printf "$%s\n" "$price"
+    if [[ $1 ]]; then
+        printf "$%.2f\n" "$(echo "scale=2; $price * $1"| bc -l)"
+    fi
+}
+
+# c. better cd
 if [[ $RLC_INSIDE_EMACS ]]; then
-    c() { wcd -z 50 -o "$@"; }
+    c() { wcd -c -z 50 -o "$@"; }
 else
     # lets see what the fancy terminal does from time to time
-    c() { wcd -z 50 "$@"; }
+    c() { wcd -c -z 50 "$@"; }
 fi
 
 caa() { git commit --amend --no-edit -a; }
@@ -646,8 +656,15 @@ and works in older versions of git which did not have that."
     echo "${p%%/.git}"
 }
 
-# quit will prompt if the program crashes.
-gmacs() { gdb -ex=r -ex=quit --args emacs "$@"; r; }
+gmacs() {
+    # quit will prompt if the program crashes.
+    gdb -ex=r -ex=quit --args emacs "$@"; r;
+}
+
+gdkill() {
+    # kill the emacs daemon
+    pk1 emacs --daemon
+}
 
 gse() {
     git send-email --notes '--envelope-sender=<ian@iankelling.org>' \
@@ -846,6 +863,21 @@ pfind() { #find *$1* in $PATH
     find "${pathArray[@]}" -iname "*$1*"
 }
 
+pk1() {
+    local pid
+    pid=($(pgrep -f "$*"))
+    case ${#pid[@]} in
+        1)
+            ps -F $pid
+            m kill $pid
+            ;;
+        0) echo "no pid found" ;;
+        *)
+            ps -F ${pid[@]}
+            ;;
+    esac
+}
+
 pick-trash() {
     # trash-restore lists everything that has been trashed at or below CWD
     # This picks out files just in CWD, not subdirectories,
@@ -1149,37 +1181,6 @@ tm() {
     (sleep $(calc "$@ * 60") && mpv --volume 50 /a/bin/data/alarm.mp3 --loop=no) > /dev/null 2>&1 &
 }
 
-ts() { # start editing a new file
-    [[ $# != 1 ]] && echo "I need a filename." && return 1
-    local quiet
-    if [[ $- != *i* ]]; then
-        quiet=true
-    fi
-    if [[ $1 == *.c ]]; then
-        e '#include <stdio.h>' >"$1"
-        e '#include <stdlib.h>' >>"$1"
-        e 'int main(int argc, char * argv[]) {' >>"$1"
-        e '    printf( "hello world\n");' >>"$1"
-        e '    return 0;' >>"$1"
-        e '}' >>"$1"
-        e "${1%.c}: $1" > Makefile
-        e "    g++ -ggdb -std=gnu99 -o ${1%.c} $<" >> Makefile
-        e "#!/bin/bash" >run.sh
-        e "./${1%.c}" >>run.sh
-        chmod +x run.sh
-    elif [[ $1 == *.java ]]; then
-        e "public class ${1%.*} {" >"$1"
-        e '    public static void main(String[] args) {' >>"$1"
-        e '            System.out.println("Hello, world!");' >>"$1"
-        e '    }' >>"$1"
-        e '}' >>"$1"
-    else
-        echo "#!/bin/bash" > "$1"
-        chmod +x "$1"
-    fi
-    [[ $quiet ]] || g "$1"
-}
-
 
 tu() {
     local s;