From: Ian Kelling Date: Sun, 15 Jan 2017 15:33:26 +0000 (-0800) Subject: small fix and additions X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=commitdiff_plain;h=951447c9f8aa1f4fcf35f376a9233fed787b5fff small fix and additions --- diff --git a/brc b/brc index 1da0024..69d54ad 100644 --- 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=' \ @@ -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 ' >"$1" - e '#include ' >>"$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;