dot

packages and services management
Log | Files | Refs | README

commit 5c8e38cf889eb5eaa4f28c01cfc957f3c6a564b4
parent c4eb2b80c4ef44afa47c6248cdcb2307e8ea103d
Author: josuah <mail@josuah.net>
Date:   Tue, 20 Dec 2016 13:08:25 +0000

cleaner

Diffstat:
M.local/bin/build | 6+++---
M.local/bin/dna | 83++++++++++++++++++++++++++++---------------------------------------------------
M.local/bin/git-prompt | 19+++++++++----------
3 files changed, 41 insertions(+), 67 deletions(-)

diff --git a/.local/bin/build b/.local/bin/build @@ -123,7 +123,7 @@ download() remove() ( info "$1" "removing" - rm -rf "$PROGRAMS/$1" + rm -rf "${PROGRAMS:?}/$1" ) @@ -162,9 +162,9 @@ main() index "$2" ;; l | link ) - ls "$PROGRAMS" | while IFS='' read -r name + find "$PROGRAMS" ! -name . | while IFS='' read -r name do - index "$name" + index "${name#$PROGRAMS}" done ;; v | view ) diff --git a/.local/bin/dna b/.local/bin/dna @@ -1,28 +1,10 @@ -# | -# .--| ---. ,--. -# | | | | ,--| -# `--` ' ' `--` 2016-10-07 -#------------------------------------------------------------------------------- -# Prints $dna with full structure, sequentially +# Prints nucleotides with full structure, sequentially -# USAGE: -# dna [ATCG] -# -# with ATCG a string of one of these characters +# Usage: dna [ATCG]... -# COLOR CODES -#------------------------------------------------------------------------------- - -# Reset # Bold R='' B='' - -# Red Green Yellow Blue Magenta Cyan Grey -f1=''; f2=''; f3=''; f4=''; f5=''; f6=''; f7='' - - -# DNA BASES -#------------------------------------------------------------------------------- +f1=''; f2=''; f3=''; f4=''; f5=''; f6=''; f7='' A="\ ${f1}O${R} ${f1}O${R} *---* @@ -84,46 +66,39 @@ T="\ | | " -random() -{ - local nucleotide i=1 - while date +%s | md5sum | cut -c $i | tr [0-9]abcdef ATCGATCGATCGATCG | - while IFS='' read -r nucleotide - do - show_nucleotide "$nucleotide" - done +random() +( + while date +%s | md5sum | tr -cd '0-9a-f\n' | fold -w 1 | + tr 0-9a-f ATCGATCGATCGATCG do - [ $i -ge 32 ] && i=1 || i=$(($i + 1)) - sleep 0.3 + sleep 1 + done | while read -r n + do + nucleotide "$n" + sleep 0.1 done -} +) + -show_nucleotide() -{ - local nucleotide="$1" +nucleotide() +( + nucleotide="$1" case $nucleotide in - A) printf '%s' "$A" ;; - C) printf '%s' "$C" ;; - T) printf '%s' "$T" ;; - G) printf '%s' "$G" ;; + A) printf %s "$A" ;; + C) printf %s "$C" ;; + T) printf %s "$T" ;; + G) printf %s "$G" ;; esac -} - +) -main() -{ - local dna="$1" - - [ -z "$dna" ] && random - - while [ ! -z "$dna" ]; do - nucleotide=$(printf '%s' "$dna" | cut -c 1) - show_nucleotide "$nucleotide" - dna=$(printf '%s' $dna | cut -c 2-) - done -} +[ -z "$1" ] && random -main $@ +while [ ! -z "$dna" ]; do + i=$((i + 1)) + nucleotide=$(printf '%s' "$dna" | cut -c 1) + nucleotide "$nucleotide" + dna=$(printf '%s' "$dna" | cut -c 2-) +done diff --git a/.local/bin/git-prompt b/.local/bin/git-prompt @@ -16,18 +16,17 @@ git rev-parse 2> /dev/null && git status --porcelain -b | awk ' sub(/\].*|, .*/, "", behind); } - m = 1; + next; } -m == 0 && /^\?\? / { untracked++; m = 1; } -m == 0 && /^U. / { conflicts++; m = 1; } -m == 0 && /^.U / { conflicts++; m = 1; } -m == 0 && /^DD / { conflicts++; m = 1; } -m == 0 && /^AA / { conflicts++; m = 1; } -m == 0 && /^.M / { changed++; } -m == 0 && /^.D / { changed++; } -m == 0 && /^[^ ]. / { staged++; } -m == 1 { m = 0; } +/^\?\? / { untracked++; next; } +/^U. / { conflicts++; next; } +/^.U / { conflicts++; next; } +/^DD / { conflicts++; next; } +/^AA / { conflicts++; next; } +/^.M / { changed++; } +/^.D / { changed++; } +/^[^ ]. / { staged++; } END { printf(" \033[1m%s\033[0m", branch);